chemtrail 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +1 -1
- data/chemtrail.gemspec +0 -1
- data/lib/chemtrail/mapping.rb +29 -0
- data/lib/chemtrail/reference_presenter.rb +19 -0
- data/lib/chemtrail/version.rb +1 -1
- data/lib/chemtrail.rb +1 -0
- data/script/ci.sh +3 -0
- data/spec/lib/chemtrail/mapping_spec.rb +39 -0
- data/spec/lib/chemtrail/reference_presenter_spec.rb +19 -0
- metadata +8 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d55203c8ed942942243f92d12039a77b7b67c3ef
|
4
|
+
data.tar.gz: 250d2b88925a9991a4016184407e93b76898d7d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79d59fa6a62e829e548636ed4ad6c66a752e9e13fae9aa3db8b8ae5cff377ef80a6de98270c3cd2abf43b00932d387079cc6fc51a3865e963a122c26ff5a1208
|
7
|
+
data.tar.gz: 2287213c61443dd4cf77c078e29b58044e6c9e9e5111c0e25086d724658fc1838b940bec084bc122fece6617a355002814c1654b53c00b1401ebc10109e1385c
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Chemtrail [](https://travis-ci.org/minifast/chemtrail) [](https://codeclimate.com/github/minifast/chemtrail)
|
1
|
+
Chemtrail [](http://badge.fury.io/rb/chemtrail) [](https://travis-ci.org/minifast/chemtrail) [](https://codeclimate.com/github/minifast/chemtrail)
|
2
2
|
==========
|
3
3
|
|
4
4
|
Chemtrail lets you build and test CloudFormation templates.
|
data/chemtrail.gemspec
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "chemtrail/reference_presenter"
|
2
|
+
|
3
|
+
class Chemtrail::Mapping
|
4
|
+
attr_reader :id
|
5
|
+
|
6
|
+
def initialize(id)
|
7
|
+
@id = id
|
8
|
+
end
|
9
|
+
|
10
|
+
def entries
|
11
|
+
@entries ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def find(top_level, second_level)
|
15
|
+
{
|
16
|
+
"Fn::FindInMap" => [
|
17
|
+
id,
|
18
|
+
Chemtrail::ReferencePresenter.new(top_level).to_parameter,
|
19
|
+
Chemtrail::ReferencePresenter.new(second_level).to_parameter
|
20
|
+
]
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_hash
|
25
|
+
{
|
26
|
+
id => entries
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Chemtrail::ReferencePresenter
|
2
|
+
attr_reader :argument
|
3
|
+
|
4
|
+
def initialize(argument)
|
5
|
+
@argument = argument
|
6
|
+
end
|
7
|
+
|
8
|
+
def reference?
|
9
|
+
argument.respond_to?(:to_reference)
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_parameter
|
13
|
+
if reference?
|
14
|
+
argument.to_reference
|
15
|
+
else
|
16
|
+
argument
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/chemtrail/version.rb
CHANGED
data/lib/chemtrail.rb
CHANGED
data/script/ci.sh
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Chemtrail::Mapping do
|
4
|
+
subject(:mapping) { Chemtrail::Mapping.new("atlas") }
|
5
|
+
|
6
|
+
describe "#to_hash" do
|
7
|
+
context "when there are no entries" do
|
8
|
+
its(:to_hash) { should have_key "atlas" }
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when an entry has been added" do
|
12
|
+
before { mapping.entries["teeth"] = {} }
|
13
|
+
|
14
|
+
specify { mapping.to_hash["atlas"].should have_key "teeth" }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#find" do
|
19
|
+
context "when all parameters are strings" do
|
20
|
+
let(:finder) { mapping.find("usa", "tacos") }
|
21
|
+
|
22
|
+
specify { finder["Fn::FindInMap"].should == ["atlas", "usa", "tacos"] }
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when the first parameter is a declaration" do
|
26
|
+
let(:fake_declaration) { double(:declaration, to_reference: "fake eyes") }
|
27
|
+
let(:finder) { mapping.find(fake_declaration, "gag shop") }
|
28
|
+
|
29
|
+
specify { finder["Fn::FindInMap"].should == ["atlas", "fake eyes", "gag shop"] }
|
30
|
+
end
|
31
|
+
|
32
|
+
context "when the second parameter is a declaration" do
|
33
|
+
let(:fake_declaration) { double(:declaration, to_reference: "wheelbarrow") }
|
34
|
+
let(:finder) { mapping.find("pasta", fake_declaration) }
|
35
|
+
|
36
|
+
specify { finder["Fn::FindInMap"].should == ["atlas", "pasta", "wheelbarrow"] }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Chemtrail::ReferencePresenter do
|
4
|
+
subject(:presenter) { Chemtrail::ReferencePresenter.new(argument) }
|
5
|
+
|
6
|
+
context "when the argument is a string literal" do
|
7
|
+
let(:argument) { "literal" }
|
8
|
+
|
9
|
+
it { should_not be_reference }
|
10
|
+
its(:to_parameter) { should == "literal"}
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when the argument can resolve into a reference" do
|
14
|
+
let(:argument) { double(:argument, to_reference: "reference") }
|
15
|
+
|
16
|
+
it { should be_reference }
|
17
|
+
its(:to_parameter) { should == "reference" }
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chemtrail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doc Ritezel
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: hashie
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: thor
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,10 +99,15 @@ files:
|
|
113
99
|
- chemtrail.gemspec
|
114
100
|
- lib/chemtrail.rb
|
115
101
|
- lib/chemtrail/declaration.rb
|
102
|
+
- lib/chemtrail/mapping.rb
|
103
|
+
- lib/chemtrail/reference_presenter.rb
|
116
104
|
- lib/chemtrail/section.rb
|
117
105
|
- lib/chemtrail/template.rb
|
118
106
|
- lib/chemtrail/version.rb
|
107
|
+
- script/ci.sh
|
119
108
|
- spec/lib/chemtrail/declaration_spec.rb
|
109
|
+
- spec/lib/chemtrail/mapping_spec.rb
|
110
|
+
- spec/lib/chemtrail/reference_presenter_spec.rb
|
120
111
|
- spec/lib/chemtrail/section_spec.rb
|
121
112
|
- spec/lib/chemtrail/template_spec.rb
|
122
113
|
- spec/spec_helper.rb
|
@@ -146,6 +137,8 @@ specification_version: 4
|
|
146
137
|
summary: Build, create and maintain your CloudFormation stack
|
147
138
|
test_files:
|
148
139
|
- spec/lib/chemtrail/declaration_spec.rb
|
140
|
+
- spec/lib/chemtrail/mapping_spec.rb
|
141
|
+
- spec/lib/chemtrail/reference_presenter_spec.rb
|
149
142
|
- spec/lib/chemtrail/section_spec.rb
|
150
143
|
- spec/lib/chemtrail/template_spec.rb
|
151
144
|
- spec/spec_helper.rb
|