chemtrail 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec55c365a8264e6d464a846cb9187e47eb1d53d2
4
- data.tar.gz: 22587299703794f1e4d01b6f18d9d83e6e4548e0
3
+ metadata.gz: d55203c8ed942942243f92d12039a77b7b67c3ef
4
+ data.tar.gz: 250d2b88925a9991a4016184407e93b76898d7d3
5
5
  SHA512:
6
- metadata.gz: 2d6c928e51908ba77528aa0daaebf8f01d6a2552c885f5e3660cd659f1e1354cdfe951e2115702cec6351628b21e231a2fb39216944d80a64775762396fddf5b
7
- data.tar.gz: 67b79e1a9312d3aba409ddfb2912b51105ba6412563a47dad5b6d7ba0c911ad66c14ed6bda7709d0d89515c899091c79fffcdc84334f6df16d0863cf326ab3d5
6
+ metadata.gz: 79d59fa6a62e829e548636ed4ad6c66a752e9e13fae9aa3db8b8ae5cff377ef80a6de98270c3cd2abf43b00932d387079cc6fc51a3865e963a122c26ff5a1208
7
+ data.tar.gz: 2287213c61443dd4cf77c078e29b58044e6c9e9e5111c0e25086d724658fc1838b940bec084bc122fece6617a355002814c1654b53c00b1401ebc10109e1385c
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Chemtrail [![Build Status](https://travis-ci.org/minifast/chemtrail.png)](https://travis-ci.org/minifast/chemtrail) [![Code Climate](https://codeclimate.com/github/minifast/chemtrail.png)](https://codeclimate.com/github/minifast/chemtrail)
1
+ Chemtrail [![Gem Version](https://badge.fury.io/rb/chemtrail.png)](http://badge.fury.io/rb/chemtrail) [![Build Status](https://travis-ci.org/minifast/chemtrail.png)](https://travis-ci.org/minifast/chemtrail) [![Code Climate](https://codeclimate.com/github/minifast/chemtrail.png)](https://codeclimate.com/github/minifast/chemtrail)
2
2
  ==========
3
3
 
4
4
  Chemtrail lets you build and test CloudFormation templates.
data/chemtrail.gemspec CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "aws-sdk-core"
22
- spec.add_dependency "hashie"
23
22
  spec.add_dependency "thor"
24
23
 
25
24
  spec.add_development_dependency "bundler", "~> 1.3"
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Chemtrail
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/chemtrail.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require "chemtrail/version"
2
2
  require "chemtrail/template"
3
3
  require "chemtrail/declaration"
4
+ require "chemtrail/mapping"
data/script/ci.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rspec
@@ -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.1
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