rna 0.2.3 → 0.2.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/README.md +27 -1
- data/lib/rna/dsl.rb +19 -1
- data/lib/rna/version.rb +1 -1
- data/spec/lib/rna_spec.rb +9 -0
- data/spec/project/config/rna/api.rb +1 -0
- data/spec/project/config/rna/masta.rb +1 -0
- data/spec/project/config/rna.rb +6 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -204,4 +204,30 @@ If you have a lot of roles, the config/rna.rb file can get unwieldy long. You c
|
|
204
204
|
An example is in the spec/project folder:
|
205
205
|
|
206
206
|
* config/rna/api.rb
|
207
|
-
* config/rna/masta.rb
|
207
|
+
* config/rna/masta.rb
|
208
|
+
|
209
|
+
#### Shared Settings
|
210
|
+
|
211
|
+
You might want a shared settings hash that you can use in only some of your roles.
|
212
|
+
|
213
|
+
```ruby
|
214
|
+
settings(
|
215
|
+
'foo' => 1
|
216
|
+
)
|
217
|
+
```
|
218
|
+
|
219
|
+
You can use this any where in your roles.
|
220
|
+
|
221
|
+
```ruby
|
222
|
+
role 'role1' do
|
223
|
+
set 'foo', settings['foo']
|
224
|
+
end
|
225
|
+
|
226
|
+
role 'role2' do
|
227
|
+
set 'foo', settings['foo']
|
228
|
+
end
|
229
|
+
|
230
|
+
role 'role3' do
|
231
|
+
# dont set foo here
|
232
|
+
end
|
233
|
+
```
|
data/lib/rna/dsl.rb
CHANGED
@@ -23,6 +23,16 @@ module Rna
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def settings(*data)
|
27
|
+
# reader method
|
28
|
+
if data.empty?
|
29
|
+
@settings
|
30
|
+
# writer method
|
31
|
+
else
|
32
|
+
@settings = data[0]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
26
36
|
def global(options={},&block)
|
27
37
|
@global = {:options => options, :block => block}
|
28
38
|
end
|
@@ -129,10 +139,18 @@ module Rna
|
|
129
139
|
|
130
140
|
class Builder
|
131
141
|
def build
|
132
|
-
|
142
|
+
if @block
|
143
|
+
@dsl = eval "self", @block.binding
|
144
|
+
instance_eval(&@block)
|
145
|
+
end
|
133
146
|
@data
|
134
147
|
end
|
135
148
|
|
149
|
+
# http://www.dan-manges.com/blog/ruby-dsls-instance-eval-with-delegation
|
150
|
+
def settings(*args, &block)
|
151
|
+
@dsl.settings(*args, &block)
|
152
|
+
end
|
153
|
+
|
136
154
|
def set(key, value)
|
137
155
|
@data['attributes'][key] = value
|
138
156
|
end
|
data/lib/rna/version.rb
CHANGED
data/spec/lib/rna_spec.rb
CHANGED
@@ -92,6 +92,15 @@ describe Rna do
|
|
92
92
|
json['masta_app'].should == 123
|
93
93
|
end
|
94
94
|
|
95
|
+
it "should be able to read shared settings" do
|
96
|
+
@dsl.run
|
97
|
+
File.exist?("#{@project_root}/output/masta-app.json").should be_false
|
98
|
+
File.exist?("#{@project_root}/output/prod-masta-android.json").should be_true
|
99
|
+
json = JSON.load(IO.read("#{@project_root}/output/prod-masta-android.json"))
|
100
|
+
json['relayhost'].should == "smtp.sendgrid.net"
|
101
|
+
json = JSON.load(IO.read("#{@project_root}/output/prod-api-app.json"))
|
102
|
+
json['relayhost'].should == "smtp.sendgrid.net"
|
103
|
+
end
|
95
104
|
###################
|
96
105
|
|
97
106
|
# only run when S3=1, will need to setup spec/project/config/s3.yml
|
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.2.
|
4
|
+
version: 0.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -207,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
207
207
|
version: '0'
|
208
208
|
segments:
|
209
209
|
- 0
|
210
|
-
hash:
|
210
|
+
hash: 3576656030338073956
|
211
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
212
|
none: false
|
213
213
|
requirements:
|
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
216
|
version: '0'
|
217
217
|
segments:
|
218
218
|
- 0
|
219
|
-
hash:
|
219
|
+
hash: 3576656030338073956
|
220
220
|
requirements: []
|
221
221
|
rubyforge_project:
|
222
222
|
rubygems_version: 1.8.24
|