lono 0.3.4 → 0.4.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: beee9469d60a5a00f7e155dc2d8564ae63fe40f2
4
+ data.tar.gz: 92b0863abac2d2cef840d96f9a119847df5e8496
5
+ SHA512:
6
+ metadata.gz: 1aa6268aaf19d0d26d26076f164bff2753611150124dd1a7865bc4b20b167a43fdffecf24dfaf6ae1ffad42fd3f2591a877a37616c68b04f80827e4ebc460620
7
+ data.tar.gz: b18cf6fbc929256fff760c419fdc9abbac3df2ae275e9c1cd61c73a2ff744b11071a965a97b150e072be1b7657680121227a367c0c2528e738ad8ab7ff263cb4
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  .DS_Store
2
2
  *.gem
3
3
  .bundle
4
+ coverage
4
5
  Gemfile.lock
5
6
  pkg
6
7
  tmp
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  rvm:
3
- - 1.9.2
4
- - 1.9.3
4
+ - 1.9.3
5
+ - 2.0.0
data/Gemfile CHANGED
@@ -1,2 +1,6 @@
1
1
  source "https://rubygems.org"
2
- gemspec
2
+ gemspec
3
+
4
+ group :development do
5
+ gem 'coveralls', :require => false
6
+ end
data/README.md CHANGED
@@ -1,9 +1,15 @@
1
1
  # Lono
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/lono.png)](http://badge.fury.io/rb/lono)
3
4
  [![Build History][2]][1]
5
+ [![Code Climate][3]][4]
6
+ [![Dependency Status](https://gemnasium.com/tongueroo/lono.png)](https://gemnasium.com/tongueroo/lono)
7
+ [![Coverage Status](https://coveralls.io/repos/tongueroo/lono/badge.png)](https://coveralls.io/r/tongueroo/lono)
4
8
 
5
9
  [1]: http://travis-ci.org/tongueroo/lono
6
10
  [2]: https://secure.travis-ci.org/tongueroo/lono.png?branch=master
11
+ [3]: https://codeclimate.com/repos/51d7f1407e00a4042c010ab4/badges/5273fe6cdb5a13e58554/gpa.png)
12
+ [4]: https://codeclimate.com/repos/51d7f1407e00a4042c010ab4/feed
7
13
 
8
14
  Lono is a Cloud Formation Template ruby generator. Lono generates Cloud Formation templates based on ERB templates.
9
15
 
@@ -63,7 +69,7 @@ There are helper methods that are available in templates.
63
69
  * 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:
64
70
  * user_data('bootstrap.sh.erb') -> templates/user_data/bootstrap.sh.erb
65
71
  * user_data('db.sh.erb') -> templates/user_data/db.sh.erb
66
- * user_data('script1.sh.erb', 'script2.sh.erb') - multiple files can be used to build the user_data script, script1 and script2 will be combined
72
+ * 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.
67
73
 
68
74
  Here's how you would call it in the template.
69
75
 
@@ -35,15 +35,14 @@ module Lono
35
35
  ERB.new(template).result(binding)
36
36
  end
37
37
 
38
- def user_data(*paths)
38
+ def user_data(path, vars={})
39
+ path = "#{@options[:project_root]}/templates/user_data/#{path}"
40
+ template = IO.read(path)
41
+ variables(vars)
42
+ result = ERB.new(template).result(binding)
39
43
  output = []
40
- paths.each do |path|
41
- path = "#{@options[:project_root]}/templates/user_data/#{path}"
42
- template = IO.read(path)
43
- result = ERB.new(template).result(binding)
44
- result.split("\n").each do |line|
45
- output += transform(line)
46
- end
44
+ result.split("\n").each do |line|
45
+ output += transform(line)
47
46
  end
48
47
  output.to_json
49
48
  end
@@ -186,17 +185,11 @@ module Lono
186
185
  end
187
186
 
188
187
  def cfn_object?(s)
189
- whitelist = %w[
190
- Ref
191
- Fn::FindInMap
192
- Fn::Base64
193
- Fn::GetAtt
194
- Fn::GetAZs
195
- Fn::Join
196
- Fn::Select
197
- ]
198
- whitelisted = !!whitelist.detect {|word| s.include?(word)}
199
- whitelisted && s =~ /^{/ && s =~ /=>/
188
+ exact = %w[Ref]
189
+ pattern = %w[Fn::]
190
+ exact_match = !!exact.detect {|word| s.include?(word)}
191
+ pattern_match = !!pattern.detect {|p| s =~ Regexp.new(p)}
192
+ (exact_match || pattern_match) && s =~ /^{/ && s =~ /=>/
200
193
  end
201
194
 
202
195
  def recompose(decomposition)
@@ -1,3 +1,3 @@
1
1
  module Lono
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -33,7 +33,7 @@
33
33
  "Fn::Base64": {
34
34
  "Fn::Join": [
35
35
  "",
36
- <%= user_data('db.sh.erb', 'db2.sh.erb') %>
36
+ <%= user_data('db.sh.erb', :vartest => 'foo') %>
37
37
  ]
38
38
  }
39
39
  }
@@ -11,6 +11,8 @@ GET_AZS=<%= get_azs %>
11
11
  JOIN=<%= join(":", ['a','b','c']) %>
12
12
  SELECT=<%= select("1", ['a','b','c']) %>
13
13
 
14
+ VARTEST=<%= @vartest %>
15
+
14
16
  echo <%= ref("AWS::StackName") %> > /tmp/stack_name
15
17
  # Helper function
16
18
  function error_exit
@@ -98,6 +98,14 @@ describe Lono do
98
98
  json['Resources']['HostRecord']['Properties']['Comment'].should == 'DNS name for mydomain.com'
99
99
  end
100
100
 
101
+ it "should generate user data with variables" do
102
+ raw = IO.read("#{@project}/output/prod-api-redis.json")
103
+ json = JSON.load(raw)
104
+ json['Description'].should == "Api redis"
105
+ user_data = json['Resources']['server']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
106
+ user_data.should include("VARTEST=foo\n")
107
+ end
108
+
101
109
  it "should generate db template" do
102
110
  raw = IO.read("#{@project}/output/prod-api-redis.json")
103
111
  json = JSON.load(raw)
@@ -7,6 +7,9 @@ $root = File.expand_path('../../', __FILE__)
7
7
 
8
8
  require "#{$root}/lib/lono"
9
9
 
10
+ require 'coveralls'
11
+ Coveralls.wear!
12
+
10
13
  module Helpers
11
14
  def execute(cmd)
12
15
  puts "Running: #{cmd}" if ENV['DEBUG']
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.3.4
5
- prerelease:
4
+ version: 0.4.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: 2013-07-21 00:00:00.000000000 Z
11
+ date: 2014-01-27 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: aws-sdk
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: guard
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: rb-fsevent
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-cloudformation
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: guard-lono
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,6 +173,7 @@ executables:
196
173
  extensions: []
197
174
  extra_rdoc_files: []
198
175
  files:
176
+ - .coveralls.yml
199
177
  - .gitignore
200
178
  - .ruby-version
201
179
  - .travis.yml
@@ -222,7 +200,6 @@ files:
222
200
  - lib/starter_project/templates/partial/server.json.erb
223
201
  - lib/starter_project/templates/user_data/app.sh.erb
224
202
  - lib/starter_project/templates/user_data/db.sh.erb
225
- - lib/starter_project/templates/user_data/db2.sh.erb
226
203
  - lib/starter_project/templates/user_data/ruby_script.rb.erb
227
204
  - lono.gemspec
228
205
  - spec/fixtures/cfn.json
@@ -230,27 +207,26 @@ files:
230
207
  - spec/spec_helper.rb
231
208
  homepage: http://github.com/tongueroo/lono
232
209
  licenses: []
210
+ metadata: {}
233
211
  post_install_message:
234
212
  rdoc_options: []
235
213
  require_paths:
236
214
  - lib
237
215
  required_ruby_version: !ruby/object:Gem::Requirement
238
- none: false
239
216
  requirements:
240
- - - ! '>='
217
+ - - '>='
241
218
  - !ruby/object:Gem::Version
242
219
  version: '0'
243
220
  required_rubygems_version: !ruby/object:Gem::Requirement
244
- none: false
245
221
  requirements:
246
- - - ! '>='
222
+ - - '>='
247
223
  - !ruby/object:Gem::Version
248
224
  version: '0'
249
225
  requirements: []
250
226
  rubyforge_project:
251
- rubygems_version: 1.8.25
227
+ rubygems_version: 2.0.14
252
228
  signing_key:
253
- specification_version: 3
229
+ specification_version: 4
254
230
  summary: Lono is a Cloud Formation Template ruby generator. Lono generates Cloud
255
231
  Formation templates based on ERB templates.
256
232
  test_files: