bosher 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d420c3c7a89275b18c496bb1cda9865af86c68d1
4
- data.tar.gz: 0f2ce3282c3101d80eba4144c2ebd0265b491fa7
3
+ metadata.gz: 959bbae35b4386a4e73c4b6270074438205b5516
4
+ data.tar.gz: 6175adb4f2a1e25851702f883166c821e9040cf6
5
5
  SHA512:
6
- metadata.gz: dd08a9cac8c655c1d9b39e9fa30463cf7ebc2734b541a75da50aa541275977b2b01511b933188fc8c7121f479f2a8eb0a50287ceb88052011062e9ce1ab129d7
7
- data.tar.gz: 3aa4a71b948987fe288a9115178e8bc9731a6f5c496668b32ac97fe07246050057109793baa1632f4d28aa6c86b5ddc39ad44ea225354b2757e5600394fc6cc5
6
+ metadata.gz: 3e27e907719061901f28ac375b8ce00d2c97eb6495cd41eb1890e47d10b808fb3425e78ba719ad82efbdfc3699c12437a5a2d9954b7db808651030fddaaca886
7
+ data.tar.gz: b434ae1a46510902b1d9fe25796829a76bba81a6b3916db8b33db25b1d14075970acb83c4be6c862905a30bfe2b2eeb12e838a3e46382548272867528f3ba316
@@ -3,14 +3,21 @@ require 'ostruct'
3
3
  require 'yaml'
4
4
  require 'active_support/core_ext'
5
5
 
6
+ class MissingPropertyInSpec < StandardError
7
+ end
8
+
6
9
  module Bosher
7
10
  class Bosher
8
11
  class ErbalT < OpenStruct
9
- def render(template)
12
+ def render(template, keys)
13
+ @spec_keys = keys
10
14
  ERB.new(template).result(binding)
11
15
  end
12
16
 
13
17
  def p(key)
18
+ if !@spec_keys.include?(key)
19
+ raise MissingPropertyInSpec
20
+ end
14
21
  key.split('.').reduce(self) do |memo, k|
15
22
  memo[k]
16
23
  end
@@ -29,7 +36,7 @@ module Bosher
29
36
  def bosh(manifest, spec, template, job_name)
30
37
  spec_defaults = spec_defaults(spec)
31
38
  defaults = nestify(spec_defaults)
32
- ErbalT.new(defaults.deep_merge(properties(manifest, job_name))).render(template)
39
+ ErbalT.new(defaults.deep_merge(properties(manifest, job_name))).render(template, spec_defaults.keys)
33
40
  end
34
41
 
35
42
  private
@@ -1,3 +1,3 @@
1
1
  module Bosher
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -44,4 +44,33 @@ three
44
44
  ["6.6.6.6"]
45
45
  ASSET
46
46
  end
47
+
48
+ it "blows up if spec doesn't have a property" do
49
+ manifest = YAML.load(<<MANIFEST)
50
+ ---
51
+ jobs:
52
+ - name: the-job
53
+ properties:
54
+ property1: 7
55
+ missing:
56
+ from:
57
+ spec: 5
58
+ missing_from_spec: 17
59
+ bosh:
60
+ dns: [8.8.8.8]
61
+ MANIFEST
62
+ spec = YAML.load(<<SPEC)
63
+ ---
64
+ properties:
65
+ property1:
66
+ description: whatever
67
+ SPEC
68
+ template = <<TEMPLATE
69
+ <%= p('missing.from.spec') %>
70
+ TEMPLATE
71
+
72
+ expect {
73
+ Bosher::Bosher.new.bosh manifest, spec, template, 'the-job'
74
+ }.to raise_error(MissingPropertyInSpec)
75
+ end
47
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luan Santos and Serguei Filimonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-17 00:00:00.000000000 Z
11
+ date: 2014-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -113,4 +113,3 @@ specification_version: 4
113
113
  summary: bosh simulator
114
114
  test_files:
115
115
  - spec/bosher_spec.rb
116
- has_rdoc: