bosher 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bosher/bosher.rb +9 -2
- data/lib/bosher/version.rb +1 -1
- data/spec/bosher_spec.rb +29 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 959bbae35b4386a4e73c4b6270074438205b5516
|
4
|
+
data.tar.gz: 6175adb4f2a1e25851702f883166c821e9040cf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e27e907719061901f28ac375b8ce00d2c97eb6495cd41eb1890e47d10b808fb3425e78ba719ad82efbdfc3699c12437a5a2d9954b7db808651030fddaaca886
|
7
|
+
data.tar.gz: b434ae1a46510902b1d9fe25796829a76bba81a6b3916db8b33db25b1d14075970acb83c4be6c862905a30bfe2b2eeb12e838a3e46382548272867528f3ba316
|
data/lib/bosher/bosher.rb
CHANGED
@@ -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
|
data/lib/bosher/version.rb
CHANGED
data/spec/bosher_spec.rb
CHANGED
@@ -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.
|
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-
|
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:
|