lono 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 413f2dec340c5b134b099eecfd6b9967de951392
4
+ data.tar.gz: 5b42248ae771ea16ab77813f58313aa88799d818
5
+ SHA512:
6
+ metadata.gz: 4a996fe637be6f8c862604bc0036000f9218fe2be73f4446d0c56c05886b0bcc6acec28b6b9253bee7b2e3efcd06fbbfd6cbe9cf1957728cf2b9a3333ebb5870
7
+ data.tar.gz: 92d051f6da1e9e26d81eff2bac01eaf7f426caef827f27b836388552663e24c34631d3c5c3ca9757b3b37bb05d554f40e1adf6d7f0e66d8e85c005f294d5bf71
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -1 +1 @@
1
- 1.9.3
1
+ 2.3.1
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 1.9.3
5
- - 2.0.0
4
+ - 2.2.5
5
+ - 2.3.1
@@ -0,0 +1,10 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
+
6
+ ## [0.5.0]
7
+
8
+ - Update use newer ruby syntax.
9
+ - Get rid of the core Hash extension that is causing issues with aws-sdk version 2. I original did this because the output of the generated json files was no deterministic with ruby 1.8.7. No longer supporting ruby 1.8.7.
10
+ - Gem has been tested with ruby 2.2.5+
data/Gemfile CHANGED
@@ -2,5 +2,5 @@ source "https://rubygems.org"
2
2
  gemspec
3
3
 
4
4
  group :development do
5
- gem 'coveralls', :require => false
6
- end
5
+ gem 'coveralls', require: false
6
+ end
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Lono
2
2
 
3
+ [![ReadmeCI](http://www.readmeci.com/images/readmeci-badge.svg)](http://www.readmeci.com/tongueroo/lono)
3
4
  [![Gem Version](https://badge.fury.io/rb/lono.png)](http://badge.fury.io/rb/lono)
4
5
  [![Build History][2]][1]
5
6
  [![Code Climate][3]][4]
@@ -34,21 +35,21 @@ template "prod-api-app.json" do
34
35
  env,app,role = name.sub('.json','').split('-')
35
36
  source "app.json.erb"
36
37
  variables(
37
- :env => env,
38
- :app => app,
39
- :role => role,
40
- :ami => "ami-123",
41
- :instance_type => "m1.small",
42
- :port => "80",
43
- :high_threshold => "15",
44
- :high_periods => "4",
45
- :low_threshold => "5",
46
- :low_periods => "10",
47
- :max_size => "24",
48
- :min_size => "6",
49
- :down_adjustment => "-3",
50
- :up_adjustment => "3",
51
- :ssl_cert => "arn:aws:iam::12345:server-certificate/wildcard"
38
+ env: env,
39
+ app: app,
40
+ role: role,
41
+ ami: "ami-123",
42
+ instance_type: "m1.small",
43
+ port: "80",
44
+ high_threshold: "15",
45
+ high_periods: "4",
46
+ low_threshold: "5",
47
+ low_periods: "10",
48
+ max_size: "24",
49
+ min_size: "6",
50
+ down_adjustment: "-3",
51
+ up_adjustment: "3",
52
+ ssl_cert: "arn:aws:iam::12345:server-certificate/wildcard"
52
53
  )
53
54
  end
54
55
  ```
@@ -61,12 +62,12 @@ There are helper methods that are available in templates.
61
62
 
62
63
  * partial - can be use to embed other files in a template. The partial should be placed in the templates/partial folder of the project. So:
63
64
  * partial('launch_config.json.erb') -> templates/partial/launch_config.json.erb
64
- * partial('launch_config.json.erb', :foo => "bar", :hello => "world") - variables can be passed to the partial helper method and will be available to the partial as instance variables. So, in this case @foo and @hello will be available in the launch_config.json.erb partial.
65
+ * partial('launch_config.json.erb', foo: "bar", hello: "world") - variables can be passed to the partial helper method and will be available to the partial as instance variables. So, in this case @foo and @hello will be available in the launch_config.json.erb partial.
65
66
 
66
67
  * user_data - can be used to include a user data script which is written in bash script form. The user data script should be placed in the templates/user_data folder of the project. So:
67
68
  * user_data('bootstrap.sh.erb') -> templates/user_data/bootstrap.sh.erb
68
69
  * user_data('db.sh.erb') -> templates/user_data/db.sh.erb
69
- * user_data('script1.sh.erb', :foo => "bar", :hello => "world") - variables can be passed to the user_data helper method and will be available to the partial as instance variables. So, in this case @foo and @hello will be available in script1.sh.erb.
70
+ * user_data('script1.sh.erb', foo: "bar", hello: "world") - variables can be passed to the user_data helper method and will be available to the partial as instance variables. So, in this case @foo and @hello will be available in script1.sh.erb.
70
71
 
71
72
  Here's how you would call it in the template.
72
73
 
data/Rakefile CHANGED
@@ -2,6 +2,6 @@
2
2
  require "bundler/gem_tasks"
3
3
  require "rspec/core/rake_task"
4
4
 
5
- task :default => :spec
5
+ task default: :spec
6
6
 
7
- RSpec::Core::RakeTask.new
7
+ RSpec::Core::RakeTask.new
@@ -1,12 +1,12 @@
1
1
  require 'json'
2
2
  require 'pp'
3
3
  require 'colorize'
4
+ require 'fileutils'
4
5
 
5
6
  $:.unshift File.dirname(__FILE__)
6
- require 'ext/hash'
7
7
  require 'lono/version'
8
8
  require 'lono/cli'
9
9
  require 'lono/new'
10
10
  require 'lono/template'
11
11
  require 'lono/dsl'
12
- require 'lono/bashify'
12
+ require 'lono/bashify'
@@ -6,18 +6,18 @@ module Lono
6
6
 
7
7
  desc "new [NAME]", "Generates lono starter project"
8
8
  Help.new_long_desc
9
- option :force, :type => :boolean, :aliases => "-f", :desc => "override existing starter files"
10
- option :quiet, :type => :boolean, :aliases => "-q", :desc => "silence the output"
9
+ option :force, type: :boolean, aliases: "-f", desc: "override existing starter files"
10
+ option :quiet, type: :boolean, aliases: "-q", desc: "silence the output"
11
11
  def new(project_root)
12
- Lono::New.new(options.clone.merge(:project_root => project_root)).run
12
+ Lono::New.new(options.clone.merge(project_root: project_root)).run
13
13
  end
14
14
 
15
15
  desc "generate", "Generate the cloud formation templates"
16
16
  Help.generate
17
- option :clean, :type => :boolean, :aliases => "-c", :desc => "remove all output files before generating"
18
- option :project_root, :default => ".", :aliases => "-r", :desc => "project root"
19
- option :quiet, :type => :boolean, :aliases => "-q", :desc => "silence the output"
20
- option :pretty, :type => :boolean, :default => true, :desc => "json pretty the output"
17
+ option :clean, type: :boolean, aliases: "-c", desc: "remove all output files before generating"
18
+ option :project_root, default: ".", aliases: "-r", desc: "project root"
19
+ option :quiet, type: :boolean, aliases: "-q", desc: "silence the output"
20
+ option :pretty, type: :boolean, default: true, desc: "json pretty the output"
21
21
  def generate
22
22
  Lono::DSL.new(options.clone).run
23
23
  end
@@ -25,7 +25,7 @@ module Lono
25
25
  desc "bashify [URL-OR-PATH]", "Convert the UserData section of an existing Cloud Formation Template to a starter bash script that is compatiable with lono"
26
26
  Help.bashify
27
27
  def bashify(path)
28
- Lono::Bashify.new(:path => path).run
28
+ Lono::Bashify.new(path: path).run
29
29
  end
30
30
 
31
31
  desc "version", "Prints version"
@@ -34,4 +34,4 @@ module Lono
34
34
  end
35
35
 
36
36
  end
37
- end
37
+ end
@@ -15,13 +15,13 @@ module Lono
15
15
 
16
16
  # load any templates defined in project/config/lono/*
17
17
  def load_subfolder
18
- Dir.glob("#{File.dirname(@path)}/lono/*").each do |path|
18
+ Dir.glob("#{File.dirname(@path)}/lono/**/*").select{ |e| File.file? e }.each do |path|
19
19
  instance_eval(File.read(path), path)
20
20
  end
21
21
  end
22
22
 
23
23
  def template(name, &block)
24
- @templates << {:name => name, :block => block}
24
+ @templates << {name: name, block: block}
25
25
  end
26
26
 
27
27
  def build
@@ -39,7 +39,10 @@ module Lono
39
39
  path = "#{output_path}/#{name}"
40
40
  puts " #{path}" unless @options[:quiet]
41
41
  validate(json, path)
42
- File.open(path, 'w') {|f| f.write(output_json(json)) }
42
+ ensure_parent_dir(path)
43
+ File.open(path, 'w') do |f|
44
+ f.write(output_json(json))
45
+ end
43
46
  end
44
47
  end
45
48
 
@@ -57,10 +60,15 @@ module Lono
57
60
  @options[:pretty] ? JSON.pretty_generate(JSON.parse(json)) : json
58
61
  end
59
62
 
63
+ def ensure_parent_dir(path)
64
+ dir = File.dirname(path)
65
+ FileUtils.mkdir_p(dir) unless File.exist?(dir)
66
+ end
67
+
60
68
  def run(options={})
61
69
  evaluate
62
70
  build
63
71
  output
64
72
  end
65
73
  end
66
- end
74
+ end
@@ -1,3 +1,3 @@
1
1
  module Lono
2
- VERSION = "0.4.4"
3
- end
2
+ VERSION = "0.5.0"
3
+ end
@@ -7,6 +7,6 @@ guard "lono" do
7
7
  end
8
8
 
9
9
  # Commented out due to CF rate limiting
10
- # guard "cloudformation", :templates_path => "output" do
10
+ # guard "cloudformation", templates_path: "output" do
11
11
  # watch(%r{^output/.+\.json$})
12
- # end
12
+ # end
@@ -2,19 +2,19 @@ template "prod-blog-app.json" do
2
2
  env,app,role = name.sub('.json','').split('-')
3
3
  source "app.json.erb"
4
4
  variables(
5
- :env => env,
6
- :app => app,
7
- :role => role,
8
- :ami => "ami-456",
9
- :instance_type => "m1.small",
10
- :port => "80",
11
- :high_threshold => "35",
12
- :high_periods => "4",
13
- :low_threshold => "20",
14
- :low_periods => "2",
15
- :max_size => "6",
16
- :min_size => "3",
17
- :down_adjustment => "-1",
18
- :up_adjustment => "2"
5
+ env: env,
6
+ app: app,
7
+ role: role,
8
+ ami: "ami-456",
9
+ instance_type: "m1.small",
10
+ port: "80",
11
+ high_threshold: "35",
12
+ high_periods: "4",
13
+ low_threshold: "20",
14
+ low_periods: "2",
15
+ max_size: "6",
16
+ min_size: "3",
17
+ down_adjustment: "-1",
18
+ up_adjustment: "2"
19
19
  )
20
- end
20
+ end
@@ -1,47 +1,58 @@
1
1
  template "prod-api-app.json" do
2
2
  source "app.json.erb"
3
3
  variables(
4
- :ami => "ami-123",
5
- :instance_type => "m1.small",
6
- :port => "80",
7
- :high_threshold => "15",
8
- :high_periods => "4",
9
- :low_threshold => "5",
10
- :low_periods => "10",
11
- :max_size => "24",
12
- :min_size => "6",
13
- :down_adjustment => "-3",
14
- :up_adjustment => "3",
15
- :ssl_cert => "arn:aws:iam::12345:server-certificate/wildcard"
4
+ ami: "ami-123",
5
+ instance_type: "m1.small",
6
+ port: "80",
7
+ high_threshold: "15",
8
+ high_periods: "4",
9
+ low_threshold: "5",
10
+ low_periods: "10",
11
+ max_size: "24",
12
+ min_size: "6",
13
+ down_adjustment: "-3",
14
+ up_adjustment: "3",
15
+ ssl_cert: "arn:aws:iam::12345:server-certificate/wildcard"
16
16
  )
17
17
  end
18
18
 
19
19
  template "prod-api-worker.json" do
20
20
  source "app.json.erb"
21
21
  variables(
22
- :ami => "ami-123",
23
- :instance_type => "m1.small",
24
- :port => "80",
25
- :high_threshold => "15",
26
- :high_periods => "4",
27
- :low_threshold => "5",
28
- :low_periods => "10",
29
- :max_size => "24",
30
- :min_size => "6",
31
- :down_adjustment => "-3",
32
- :up_adjustment => "3",
33
- :user_data_script => "ruby_script.rb.erb",
34
- :ssl_cert => "arn:aws:iam::12345:server-certificate/wildcard"
22
+ ami: "ami-123",
23
+ instance_type: "m1.small",
24
+ port: "80",
25
+ high_threshold: "15",
26
+ high_periods: "4",
27
+ low_threshold: "5",
28
+ low_periods: "10",
29
+ max_size: "24",
30
+ min_size: "6",
31
+ down_adjustment: "-3",
32
+ up_adjustment: "3",
33
+ user_data_script: "ruby_script.rb.erb",
34
+ ssl_cert: "arn:aws:iam::12345:server-certificate/wildcard"
35
35
  )
36
36
  end
37
37
 
38
38
  template "prod-api-redis.json" do
39
39
  source "db.json.erb"
40
40
  variables(
41
- :ami => "ami-456",
42
- :instance_type => "m1.small",
43
- :port => "80",
44
- :volume_size => "20",
45
- :availability_zone => "us-east-1e"
41
+ ami: "ami-456",
42
+ instance_type: "m1.small",
43
+ port: "80",
44
+ volume_size: "20",
45
+ availability_zone: "us-east-1e"
46
46
  )
47
- end
47
+ end
48
+
49
+ template "parent/db-stack.json" do
50
+ source "db.json.erb"
51
+ variables(
52
+ ami: "ami-456",
53
+ instance_type: "m1.small",
54
+ port: "80",
55
+ volume_size: "20",
56
+ availability_zone: "us-east-1e"
57
+ )
58
+ end
@@ -179,7 +179,7 @@
179
179
  },
180
180
  "Type": "AWS::CloudWatch::Alarm"
181
181
  },
182
- <%= partial("host_record.json.erb", :domain => "mydomain.com") %>
182
+ <%= partial("host_record.json.erb", domain: "mydomain.com") %>
183
183
  "LaunchConfig": {
184
184
  "Properties": {
185
185
  "BlockDeviceMappings": [
@@ -34,7 +34,7 @@
34
34
  "Fn::Join": [
35
35
  "",
36
36
  [
37
- <%= user_data('db.sh.erb', :vartest => 'foo') %>,
37
+ <%= user_data('db.sh.erb', vartest: 'foo') %>,
38
38
  <%= user_data('db2.sh.erb') %>
39
39
  ]
40
40
  ]
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- ec2.tags.create(ec2.instances[my_instance_id], "Name", {:value => Facter.hostname})
3
+ ec2.tags.create(ec2.instances[my_instance_id], "Name", {value: Facter.hostname})
4
4
 
5
- find_all{ |record_set| record_set[:name] == record_name }
5
+ find_all{ |record_set| record_set[:name] == record_name }
@@ -11,14 +11,14 @@ describe Lono do
11
11
  end
12
12
 
13
13
  after(:each) do
14
- FileUtils.rm_rf(@project) unless ENV['LEAVE_TMP_PROJECT']
14
+ FileUtils.rm_rf(@project) unless ENV['KEEP_TMP_PROJECT']
15
15
  end
16
16
 
17
17
  describe "bashify" do
18
18
  it "should convert cfn user_data to bash script" do
19
19
  path = "#{$root}/spec/fixtures/cfn.json"
20
20
  out = execute("./bin/lono bashify #{path}")
21
- out.should match /bash -lexv/
21
+ expect(out).to match /bash -lexv/
22
22
  end
23
23
  end
24
24
 
@@ -28,123 +28,123 @@ describe Lono do
28
28
  template = Lono::Template.new("foo", block)
29
29
 
30
30
  line = '0{2345}7'
31
- template.bracket_positions(line).should == [[0,0],[1,6],[7,7]]
31
+ expect(template.bracket_positions(line)).to eq [[0,0],[1,6],[7,7]]
32
32
  line = '0{2}4{6}' # more than one bracket
33
- template.bracket_positions(line).should == [[0,0],[1,3],[4,4],[5,7]]
33
+ expect(template.bracket_positions(line)).to eq [[0,0],[1,3],[4,4],[5,7]]
34
34
  line = '0{2}4{6{8}0}2' # nested brackets
35
- template.bracket_positions(line).should == [[0,0],[1,3],[4,4],[5,11],[12,12]]
35
+ expect(template.bracket_positions(line)).to eq [[0,0],[1,3],[4,4],[5,11],[12,12]]
36
36
 
37
37
  line = '{'
38
- template.decompose(line).should == ['{']
38
+ expect(template.decompose(line)).to eq ['{']
39
39
 
40
40
  ##########################
41
41
  line = '1{"Ref"=>"A"}{"Ref"=>"B"}'
42
- template.decompose(line).should == ['1','{"Ref"=>"A"}','{"Ref"=>"B"}']
42
+ expect(template.decompose(line)).to eq ['1','{"Ref"=>"A"}','{"Ref"=>"B"}']
43
43
 
44
44
  line = '{"Ref"=>"A"}{"Ref"=>"B"}2'
45
- template.decompose(line).should == ['{"Ref"=>"A"}','{"Ref"=>"B"}','2']
45
+ expect(template.decompose(line)).to eq ['{"Ref"=>"A"}','{"Ref"=>"B"}','2']
46
46
 
47
47
  line = '1{"Ref"=>"A"}{"Ref"=>"B"}2'
48
- template.decompose(line).should == ['1','{"Ref"=>"A"}','{"Ref"=>"B"}','2']
48
+ expect(template.decompose(line)).to eq ['1','{"Ref"=>"A"}','{"Ref"=>"B"}','2']
49
49
 
50
50
  line = '{"Ref"=>"A"}{"Ref"=>"B"}'
51
- template.decompose(line).should == ['{"Ref"=>"A"}','{"Ref"=>"B"}']
51
+ expect(template.decompose(line)).to eq ['{"Ref"=>"A"}','{"Ref"=>"B"}']
52
52
 
53
53
  line = 'Ref{"Ref"=>"B"}'
54
- template.decompose(line).should == ['Ref','{"Ref"=>"B"}']
54
+ expect(template.decompose(line)).to eq ['Ref','{"Ref"=>"B"}']
55
55
  ##############################
56
56
 
57
57
  # only allow whitelist
58
58
  line = 'a{b}{"foo"=>"bar"}h'
59
- template.decompose(line).should == ['a{b}{"foo"=>"bar"}h']
59
+ expect(template.decompose(line)).to eq ['a{b}{"foo"=>"bar"}h']
60
60
 
61
61
  line = 'a{b}{"Ref"=>"bar"}h'
62
- template.decompose(line).should == ['a{b}','{"Ref"=>"bar"}','h']
62
+ expect(template.decompose(line)).to eq ['a{b}','{"Ref"=>"bar"}','h']
63
63
  line = 'a{"Ref"=>"bar"}c{"Ref"=>{"cat"=>"mouse"}}e' # nested brackets
64
- template.decompose(line).should == ['a','{"Ref"=>"bar"}','c','{"Ref"=>{"cat"=>"mouse"}}','e']
64
+ expect(template.decompose(line)).to eq ['a','{"Ref"=>"bar"}','c','{"Ref"=>{"cat"=>"mouse"}}','e']
65
65
 
66
66
  line = 'test{"Ref"=>"world"}me' # nested brackets
67
67
  decomposition = template.decompose(line)
68
68
  result = template.recompose(decomposition)
69
- result.should == ["test", {"Ref" => "world"}, "me"]
69
+ expect(result).to eq ["test", {"Ref" => "world"}, "me"]
70
70
 
71
71
  line = 'test{"Ref"=>"world"}me'
72
- template.transform(line).should == ["test", {"Ref" => "world"}, "me\n"]
72
+ expect(template.transform(line)).to eq ["test", {"Ref" => "world"}, "me\n"]
73
73
  line = '{"Ref"=>"world"}'
74
- template.transform(line).should == [{"Ref" => "world"}, "\n"]
74
+ expect(template.transform(line)).to eq [{"Ref" => "world"}, "\n"]
75
75
  line = '{'
76
- template.transform(line).should == ["{\n"]
76
+ expect(template.transform(line)).to eq ["{\n"]
77
77
  line = 'Ref{"Ref"=>"B"}'
78
- template.transform(line).should == ['Ref',{"Ref"=>"B"}, "\n"]
78
+ expect(template.transform(line)).to eq ['Ref',{"Ref"=>"B"}, "\n"]
79
79
  end
80
80
  end
81
81
 
82
82
  describe "ruby specs" do
83
83
  before(:each) do
84
- @dsl = Lono::DSL.new(
85
- :project_root => @project,
86
- :quiet => true
84
+ dsl = Lono::DSL.new(
85
+ project_root: @project,
86
+ quiet: true
87
87
  )
88
- @dsl.run
88
+ dsl.run
89
89
  end
90
90
 
91
91
  it "should generate cloud formation template" do
92
92
  raw = IO.read("#{@project}/output/prod-api-app.json")
93
93
  json = JSON.load(raw)
94
- json['Description'].should == "Api Stack"
95
- json['Mappings']['AWSRegionArch2AMI']['us-east-1']['64'].should == 'ami-123'
94
+ expect(json['Description']).to eq "Api Stack"
95
+ expect(json['Mappings']['AWSRegionArch2AMI']['us-east-1']['64']).to eq 'ami-123'
96
96
  end
97
97
 
98
98
  it "should make trailing options pass to the partial helper available as instance variables" do
99
99
  raw = IO.read("#{@project}/output/prod-api-app.json")
100
100
  json = JSON.load(raw)
101
- json['Resources']['HostRecord']['Properties']['Comment'].should == 'DNS name for mydomain.com'
101
+ expect(json['Resources']['HostRecord']['Properties']['Comment']).to eq 'DNS name for mydomain.com'
102
102
  end
103
103
 
104
104
  it "should generate user data with variables" do
105
105
  raw = IO.read("#{@project}/output/prod-api-redis.json")
106
106
  json = JSON.load(raw)
107
- json['Description'].should == "Api redis"
107
+ expect(json['Description']).to eq "Api redis"
108
108
  user_data = json['Resources']['server']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
109
- user_data.should include("VARTEST=foo\n")
109
+ expect(user_data).to include("VARTEST=foo\n")
110
110
  end
111
111
 
112
112
  it "should include multiple user_data scripts" do
113
113
  raw = IO.read("#{@project}/output/prod-api-redis.json")
114
114
  json = JSON.load(raw)
115
- json['Description'].should == "Api redis"
115
+ expect(json['Description']).to eq "Api redis"
116
116
  user_data = json['Resources']['server']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
117
- user_data.should include("DB2=test\n")
117
+ expect(user_data).to include("DB2=test\n")
118
118
  end
119
119
 
120
120
  it "should generate db template" do
121
121
  raw = IO.read("#{@project}/output/prod-api-redis.json")
122
122
  json = JSON.load(raw)
123
- json['Description'].should == "Api redis"
123
+ expect(json['Description']).to eq "Api redis"
124
124
  user_data = json['Resources']['server']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
125
- user_data.should include({"Ref" => "AWS::StackName"})
126
- user_data.should include({"Ref" => "WaitHandle"})
127
- user_data.should include({
125
+ expect(user_data).to include({"Ref" => "AWS::StackName"})
126
+ expect(user_data).to include({"Ref" => "WaitHandle"})
127
+ expect(user_data).to include({
128
128
  "Fn::FindInMap" => [
129
129
  "EnvironmentMapping",
130
130
  "HostnamePrefix",
131
131
  {"Ref" => "Environment"}
132
132
  ]
133
133
  })
134
- user_data.should include({
134
+ expect(user_data).to include({
135
135
  "Fn::FindInMap" => [
136
136
  "MapName",
137
137
  "TopLevelKey",
138
138
  "SecondLevelKey"
139
139
  ]
140
140
  })
141
- user_data.should include({"Ref" => "DRINK"})
141
+ expect(user_data).to include({"Ref" => "DRINK"})
142
142
 
143
- user_data.should include({"Fn::Base64" => "value to encode"})
144
- user_data.should include({"Fn::GetAtt" => ["server", "PublicDnsName"]})
145
- user_data.should include({"Fn::GetAZs" => "AWS::Region"})
146
- user_data.should include({"Fn::Join" => [ ':', ['a','b','c']]})
147
- user_data.should include({"Fn::Select" => [ '1', ['a','b','c']]})
143
+ expect(user_data).to include({"Fn::Base64" => "value to encode"})
144
+ expect(user_data).to include({"Fn::GetAtt" => ["server", "PublicDnsName"]})
145
+ expect(user_data).to include({"Fn::GetAZs" => "AWS::Region"})
146
+ expect(user_data).to include({"Fn::Join" => [ ':', ['a','b','c']]})
147
+ expect(user_data).to include({"Fn::Select" => [ '1', ['a','b','c']]})
148
148
  end
149
149
 
150
150
  it "should transform bash script to CF template user_data" do
@@ -153,45 +153,46 @@ describe Lono do
153
153
 
154
154
  line = 'echo {"Ref"=>"AWS::StackName"} > /tmp/stack_name ; {"Ref"=>"Ami"}'
155
155
  data = template.transform(line)
156
- data.should == ["echo ", {"Ref"=>"AWS::StackName"}, " > /tmp/stack_name ; ", {"Ref"=>"Ami"}, "\n"]
156
+ expect(data).to eq ["echo ", {"Ref"=>"AWS::StackName"}, " > /tmp/stack_name ; ", {"Ref"=>"Ami"}, "\n"]
157
157
 
158
158
  line = 'echo {"Ref"=>"AWS::StackName"} > /tmp/stack_name'
159
159
  data = template.transform(line)
160
- data.should == ["echo ", {"Ref"=>"AWS::StackName"}, " > /tmp/stack_name\n"]
160
+ expect(data).to eq ["echo ", {"Ref"=>"AWS::StackName"}, " > /tmp/stack_name\n"]
161
161
 
162
162
  line = 'echo {"Fn::FindInMap" => [ "A", "B", {"Ref"=>"AWS::StackName"} ]}'
163
163
  data = template.transform(line)
164
- data.should == ["echo ", {"Fn::FindInMap" => ["A", "B", {"Ref"=>"AWS::StackName"}]}, "\n"]
164
+ expect(data).to eq ["echo ", {"Fn::FindInMap" => ["A", "B", {"Ref"=>"AWS::StackName"}]}, "\n"]
165
165
 
166
166
  line = 'echo {"Fn::FindInMap" => [ "A", "B", {"Ref"=>"AWS::StackName"} ]} > /tmp/stack_name ; {"Ref"=>"Ami"}'
167
167
  data = template.transform(line)
168
- data.should == ["echo ", {"Fn::FindInMap" => ["A", "B", {"Ref"=>"AWS::StackName"}]}, " > /tmp/stack_name ; ", {"Ref"=>"Ami"}, "\n"]
168
+ expect(data).to eq ["echo ", {"Fn::FindInMap" => ["A", "B", {"Ref"=>"AWS::StackName"}]}, " > /tmp/stack_name ; ", {"Ref"=>"Ami"}, "\n"]
169
169
  end
170
170
 
171
171
  it "should not transform user_data ruby scripts" do
172
172
  raw = IO.read("#{@project}/output/prod-api-worker.json")
173
173
  json = JSON.load(raw)
174
174
  user_data = json['Resources']['LaunchConfig']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
175
- user_data.should include(%Q|ec2.tags.create(ec2.instances[my_instance_id], "Name", {:value => Facter.hostname})\n|)
176
- user_data.should include(%Q{find_all{ |record_set| record_set[:name] == record_name }\n})
175
+ expect(user_data).to include(%Q|ec2.tags.create(ec2.instances[my_instance_id], "Name", {value: Facter.hostname})\n|)
176
+ expect(user_data).to include(%Q{find_all{ |record_set| record_set[:name] == record_name }\n})
177
+ end
178
+
179
+ it "should create parent folders for parent/db-stack.json" do
180
+ directory_created = File.exist?("#{@project}/output/parent")
181
+ expect(directory_created).to be true
177
182
  end
178
183
 
179
184
  it "task should generate cloud formation templates" do
180
- Lono::DSL.new(
181
- :project_root => @project,
182
- :quiet => true
183
- ).run
184
185
  raw = IO.read("#{@project}/output/prod-api-app.json")
185
186
  json = JSON.load(raw)
186
- json['Description'].should == "Api Stack"
187
- json['Mappings']['AWSRegionArch2AMI']['us-east-1']['64'].should == 'ami-123'
187
+ expect(json['Description']).to eq "Api Stack"
188
+ expect(json['Mappings']['AWSRegionArch2AMI']['us-east-1']['64']).to eq 'ami-123'
188
189
  end
189
190
  end
190
191
 
191
192
  describe "cli specs" do
192
193
  it "should generate templates" do
193
194
  out = execute("./bin/lono generate -c --project-root #{@project}")
194
- out.should match /Generating Cloud Formation templates/
195
+ expect(out).to match /Generating Cloud Formation templates/
195
196
  end
196
197
  end
197
- end
198
+ end
metadata CHANGED
@@ -1,190 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lono
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
5
- prerelease:
4
+ version: 0.5.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tung Nguyen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-03-11 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: thor
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: guard
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rb-fsevent
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: guard-cloudformation
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: guard-lono
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: colorize
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :runtime
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: rspec
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - ">="
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: guard-rspec
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - ">="
164
144
  - !ruby/object:Gem::Version
165
145
  version: '0'
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ! '>='
150
+ - - ">="
172
151
  - !ruby/object:Gem::Version
173
152
  version: '0'
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: guard-bundler
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ! '>='
157
+ - - ">="
180
158
  - !ruby/object:Gem::Version
181
159
  version: '0'
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ! '>='
164
+ - - ">="
188
165
  - !ruby/object:Gem::Version
189
166
  version: '0'
190
167
  description: Lono is a Cloud Formation Template ruby generator. Lono generates Cloud
@@ -196,17 +173,18 @@ executables:
196
173
  extensions: []
197
174
  extra_rdoc_files: []
198
175
  files:
199
- - .coveralls.yml
200
- - .gitignore
201
- - .ruby-version
202
- - .travis.yml
176
+ - ".coveralls.yml"
177
+ - ".gitignore"
178
+ - ".rspec"
179
+ - ".ruby-version"
180
+ - ".travis.yml"
181
+ - CHANGELOG.md
203
182
  - Gemfile
204
183
  - Guardfile
205
184
  - LICENSE
206
185
  - README.md
207
186
  - Rakefile
208
187
  - bin/lono
209
- - lib/ext/hash.rb
210
188
  - lib/lono.rb
211
189
  - lib/lono/bashify.rb
212
190
  - lib/lono/cli.rb
@@ -234,30 +212,30 @@ files:
234
212
  homepage: http://github.com/tongueroo/lono
235
213
  licenses:
236
214
  - MIT
215
+ metadata: {}
237
216
  post_install_message:
238
217
  rdoc_options: []
239
218
  require_paths:
240
219
  - lib
241
220
  required_ruby_version: !ruby/object:Gem::Requirement
242
- none: false
243
221
  requirements:
244
- - - ! '>='
222
+ - - ">="
245
223
  - !ruby/object:Gem::Version
246
224
  version: '0'
247
225
  required_rubygems_version: !ruby/object:Gem::Requirement
248
- none: false
249
226
  requirements:
250
- - - ! '>='
227
+ - - ">="
251
228
  - !ruby/object:Gem::Version
252
229
  version: '0'
253
230
  requirements: []
254
231
  rubyforge_project:
255
- rubygems_version: 1.8.23
232
+ rubygems_version: 2.6.4
256
233
  signing_key:
257
- specification_version: 3
234
+ specification_version: 4
258
235
  summary: Lono is a Cloud Formation Template ruby generator. Lono generates Cloud
259
236
  Formation templates based on ERB templates.
260
237
  test_files:
261
238
  - spec/fixtures/cfn.json
262
239
  - spec/lib/lono_spec.rb
263
240
  - spec/spec_helper.rb
241
+ has_rdoc:
@@ -1,11 +0,0 @@
1
- class Hash
2
- alias hkeys keys
3
-
4
- def keys
5
- hkeys.sort {|a,b| a.to_s <=> b.to_s }
6
- end
7
-
8
- def each
9
- keys.each { |k| yield k, self[k] }
10
- end
11
- end