rna 0.1.1 → 0.1.4
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.
- data/.travis.yml +1 -2
- data/README.md +5 -0
- data/lib/files/Guardfile +3 -0
- data/lib/rna/cli.rb +1 -1
- data/lib/rna/dsl.rb +1 -0
- data/lib/rna/outputers.rb +3 -1
- data/lib/rna/tasks.rb +7 -2
- data/lib/rna/version.rb +1 -1
- data/rna.gemspec +1 -0
- data/spec/lib/rna_spec.rb +7 -7
- data/spec/project/config/rna.rb +1 -0
- metadata +25 -2
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
Rna gem
|
2
2
|
===========
|
3
3
|
|
4
|
+
[![Build History][2]][1]
|
5
|
+
|
6
|
+
[1]: http://travis-ci.org/tongueroo/rna
|
7
|
+
[2]: https://secure.travis-ci.org/tongueroo/rna.png?branch=master
|
8
|
+
|
4
9
|
Rna is a ruby gem that provides simple DSL for generating node.json files required by chef-solo.
|
5
10
|
|
6
11
|
Requirements
|
data/lib/files/Guardfile
ADDED
data/lib/rna/cli.rb
CHANGED
@@ -22,7 +22,7 @@ EOL
|
|
22
22
|
method_option :output, :aliases => '-o', :desc => "specify where to output the generated files to", :default => 'filesystem'
|
23
23
|
method_option :public_read, :aliases => '-p', :desc => "make s3 files readable by public, default private", :default => false, :type => :boolean
|
24
24
|
def build
|
25
|
-
Rna::Tasks.build(options.dup)
|
25
|
+
Rna::Tasks.build(options.dup.merge(:verbose => true))
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
data/lib/rna/dsl.rb
CHANGED
data/lib/rna/outputers.rb
CHANGED
@@ -9,9 +9,10 @@ module Rna
|
|
9
9
|
class Filesystem < Outputer
|
10
10
|
def run(jsons)
|
11
11
|
# options[:output_path] only used for specs
|
12
|
-
output_path = options[:output_path] || "
|
12
|
+
output_path = options[:output_path] || "output"
|
13
13
|
FileUtils.mkdir(output_path) unless File.exist?(output_path)
|
14
14
|
jsons.each do |role,json|
|
15
|
+
puts " #{role}.json" if options[:verbose]
|
15
16
|
File.open("#{output_path}/#{role}.json", 'w') {|f| f.write(json) }
|
16
17
|
end
|
17
18
|
end
|
@@ -28,6 +29,7 @@ module Rna
|
|
28
29
|
@s3 = AWS::S3.new
|
29
30
|
bucket = @s3.buckets[@config['bucket']]
|
30
31
|
jsons.each do |role,json|
|
32
|
+
puts " #{role}.json" if options[:verbose]
|
31
33
|
bucket.objects.create("#{@config['folder']}/#{role}.json", json, s3_options)
|
32
34
|
end
|
33
35
|
self # return outputer object for specs
|
data/lib/rna/tasks.rb
CHANGED
@@ -3,9 +3,10 @@ module Rna
|
|
3
3
|
def self.init(project_root=".",options={})
|
4
4
|
puts "Settin up rna project" unless options[:quiet]
|
5
5
|
FileUtils.mkdir("#{project_root}/config") unless File.exist?("#{project_root}/config")
|
6
|
-
%w/rna.rb s3.yml/.each do |name|
|
6
|
+
%w/rna.rb s3.yml Guardfile/.each do |name|
|
7
7
|
source = File.expand_path("../../files/#{name}", __FILE__)
|
8
8
|
dest = "#{project_root}/config/#{File.basename(source)}"
|
9
|
+
dest = "#{project_root}/#{File.basename(source)}" if name == 'Guardfile'
|
9
10
|
if File.exist?(dest)
|
10
11
|
puts "already exists: #{dest}" unless options[:quiet]
|
11
12
|
else
|
@@ -20,7 +21,11 @@ module Rna
|
|
20
21
|
|
21
22
|
def initialize(options={})
|
22
23
|
@options = options
|
23
|
-
|
24
|
+
if options[:config_path]
|
25
|
+
@dsl = DSL.new(options[:config_path])
|
26
|
+
else
|
27
|
+
@dsl = DSL.new
|
28
|
+
end
|
24
29
|
end
|
25
30
|
def build
|
26
31
|
@dsl.evaluate
|
data/lib/rna/version.rb
CHANGED
data/rna.gemspec
CHANGED
data/spec/lib/rna_spec.rb
CHANGED
@@ -94,14 +94,14 @@ describe Rna do
|
|
94
94
|
it "should write json files to outputs folder" do
|
95
95
|
@dsl.build
|
96
96
|
@dsl.output(:output => 'filesystem', :output_path => "#{@project_root}/nodejson")
|
97
|
-
Dir.glob("#{@project_root}/
|
97
|
+
Dir.glob("#{@project_root}/output/*").size.should > 0
|
98
98
|
end
|
99
99
|
|
100
100
|
# complete end to end tests
|
101
101
|
it "base.json should contain correct attributes" do
|
102
102
|
@dsl.build
|
103
103
|
@dsl.output(:output => 'filesystem', :output_path => "#{@project_root}/nodejson")
|
104
|
-
base = JSON.load(IO.read("#{@project_root}/
|
104
|
+
base = JSON.load(IO.read("#{@project_root}/output/base.json"))
|
105
105
|
base['role'].should == 'base'
|
106
106
|
base['run_list'].should == ["role[base]"]
|
107
107
|
end
|
@@ -109,7 +109,7 @@ describe Rna do
|
|
109
109
|
it "base.json should not contain global attributes" do
|
110
110
|
@dsl.build
|
111
111
|
@dsl.output(:output => 'filesystem', :output_path => "#{@project_root}/nodejson")
|
112
|
-
base = JSON.load(IO.read("#{@project_root}/
|
112
|
+
base = JSON.load(IO.read("#{@project_root}/output/base.json"))
|
113
113
|
base['framework_env'].should be_nil
|
114
114
|
base['deploy_code'].should be_nil
|
115
115
|
end
|
@@ -117,7 +117,7 @@ describe Rna do
|
|
117
117
|
it "prod-api-redis.json should contain base and global attributes" do
|
118
118
|
@dsl.build
|
119
119
|
@dsl.output(:output => 'filesystem', :output_path => "#{@project_root}/nodejson")
|
120
|
-
json = JSON.load(IO.read("#{@project_root}/
|
120
|
+
json = JSON.load(IO.read("#{@project_root}/output/prod-api-redis.json"))
|
121
121
|
json['role'].should == 'prod-api-redis'
|
122
122
|
json['run_list'].should == ["role[base]"]
|
123
123
|
json['framework_env'].should == 'production'
|
@@ -127,7 +127,7 @@ describe Rna do
|
|
127
127
|
it "stag-api-redis.json should contain base and global attributes and apply rules" do
|
128
128
|
@dsl.build
|
129
129
|
@dsl.output(:output => 'filesystem', :output_path => "#{@project_root}/nodejson")
|
130
|
-
json = JSON.load(IO.read("#{@project_root}/
|
130
|
+
json = JSON.load(IO.read("#{@project_root}/output/stag-api-redis.json"))
|
131
131
|
json['role'].should == 'stag-api-redis'
|
132
132
|
json['run_list'].should == ["role[base]"]
|
133
133
|
json['deploy_code'].should == false
|
@@ -137,7 +137,7 @@ describe Rna do
|
|
137
137
|
it "prod-api-app.json should contain base and global attributes" do
|
138
138
|
@dsl.build
|
139
139
|
@dsl.output(:output => 'filesystem', :output_path => "#{@project_root}/nodejson")
|
140
|
-
json = JSON.load(IO.read("#{@project_root}/
|
140
|
+
json = JSON.load(IO.read("#{@project_root}/output/prod-api-app.json"))
|
141
141
|
json['role'].should == 'prod-api-app'
|
142
142
|
json['run_list'].should == ["role[base]","role[api_app]"]
|
143
143
|
json['deploy_code'].should == true
|
@@ -182,7 +182,7 @@ describe Rna do
|
|
182
182
|
:config_path => "#{@project_root}/config/rna.rb",
|
183
183
|
:output_path => "#{@project_root}/nodejson"
|
184
184
|
)
|
185
|
-
json = JSON.load(IO.read("#{@project_root}/
|
185
|
+
json = JSON.load(IO.read("#{@project_root}/output/prod-api-app.json"))
|
186
186
|
json['role'].should == 'prod-api-app'
|
187
187
|
json['run_list'].should == ["role[base]","role[api_app]"]
|
188
188
|
json['deploy_code'].should == true
|
data/spec/project/config/rna.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: json
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,6 +176,7 @@ files:
|
|
160
176
|
- README.md
|
161
177
|
- Rakefile
|
162
178
|
- bin/rna
|
179
|
+
- lib/files/Guardfile
|
163
180
|
- lib/files/rna.rb
|
164
181
|
- lib/files/s3.yml
|
165
182
|
- lib/rna.rb
|
@@ -185,12 +202,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
202
|
- - ! '>='
|
186
203
|
- !ruby/object:Gem::Version
|
187
204
|
version: '0'
|
205
|
+
segments:
|
206
|
+
- 0
|
207
|
+
hash: 724117673622561747
|
188
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
209
|
none: false
|
190
210
|
requirements:
|
191
211
|
- - ! '>='
|
192
212
|
- !ruby/object:Gem::Version
|
193
213
|
version: '0'
|
214
|
+
segments:
|
215
|
+
- 0
|
216
|
+
hash: 724117673622561747
|
194
217
|
requirements: []
|
195
218
|
rubyforge_project:
|
196
219
|
rubygems_version: 1.8.24
|