ecology 0.0.14 → 0.0.18
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/.gitignore +2 -0
- data/.yardopts +1 -0
- data/Gemfile.lock +2 -2
- data/README.md +78 -9
- data/TODO +2 -5
- data/bin/with_ecology +75 -0
- data/ecology.gemspec +2 -0
- data/lib/ecology.rb +58 -39
- data/lib/ecology/test_methods.rb +20 -0
- data/lib/ecology/version.rb +1 -1
- data/lib/ecology/version.rb~ +1 -1
- data/test/ecology_test.rb +47 -0
- data/test/test_helper.rb +2 -14
- metadata +106 -76
- data/ecology.gemspec~ +0 -36
data/.gitignore
CHANGED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--no-private --protected -- **/*.rb
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ecology (0.0.
|
4
|
+
ecology (0.0.17)
|
5
5
|
erubis
|
6
6
|
multi_json
|
7
7
|
|
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
erubis (2.7.0)
|
12
12
|
minitest (2.3.0)
|
13
13
|
mocha (0.9.12)
|
14
|
-
multi_json (1.0.
|
14
|
+
multi_json (1.0.4)
|
15
15
|
rake (0.9.2)
|
16
16
|
scope (0.2.1)
|
17
17
|
minitest
|
data/README.md
CHANGED
@@ -103,9 +103,58 @@ the :as option:
|
|
103
103
|
Ecology.property("logging:extra_json_fields", :as => Symbol) # error!
|
104
104
|
Ecology.property("logging:file_path", :as => :path) # "/home/theuser/sub/log_to"
|
105
105
|
|
106
|
+
Embedded Ruby
|
107
|
+
=============
|
108
|
+
|
109
|
+
If instead of a .ecology file, you have a .ecology.erb file, it will
|
110
|
+
be parsed using Erubis and *then* parsed using JSON. This makes it
|
111
|
+
easy to have conditional properties.
|
112
|
+
|
113
|
+
Using outside Ruby
|
114
|
+
==================
|
115
|
+
|
116
|
+
Use the with_ecology binary to pre-parse, pre-use Erb and then run
|
117
|
+
another binary with the Ecology data put into environment variables.
|
118
|
+
|
119
|
+
For example, assume you have a my.ecology.erb that looks like:
|
120
|
+
|
121
|
+
{
|
122
|
+
"application": "<%= "bob" %>",
|
123
|
+
"property1": {
|
124
|
+
"foo": "bar",
|
125
|
+
"baz": 7
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
Now run the following:
|
130
|
+
|
131
|
+
$ with_ecology my.ecology env | grep ECOLOGY
|
132
|
+
|
133
|
+
You'll see:
|
134
|
+
|
135
|
+
ECOLOGY_application=bob
|
136
|
+
ECOLOGY_application_TYPE=string
|
137
|
+
ECOLOGY_property1_foo=bar
|
138
|
+
ECOLOGY_property1_foo_TYPE=string
|
139
|
+
ECOLOGY_property1_baz=7
|
140
|
+
ECOLOGY_property1_baz_TYPE=int
|
141
|
+
|
142
|
+
This is just a translations of the ecology fields into environment
|
143
|
+
variable names. You can usually ignore the types, but (rarely) this
|
144
|
+
can be important if you need to know whether the ecology specified a
|
145
|
+
number directly or as a string, or to find out whether a field was
|
146
|
+
a null or the empty string.
|
147
|
+
|
148
|
+
This can be useful to pass variables to non-Ruby programs, or any time
|
149
|
+
you don't want to have to link with Erubis and a JSON parser. You'll
|
150
|
+
need to parse the properties from environment variables yourself,
|
151
|
+
though.
|
152
|
+
|
106
153
|
Environment-Specific Data
|
107
154
|
=========================
|
108
155
|
|
156
|
+
(Note: this section is mostly obsolete. You can use Erb for this)
|
157
|
+
|
109
158
|
Often you'll want to supply a different path, hostname or other
|
110
159
|
configuration variable depending on what environment you're
|
111
160
|
currently deployed to - staging may want a different MemCacheD
|
@@ -180,14 +229,20 @@ Ecology.read Etiquette
|
|
180
229
|
======================
|
181
230
|
|
182
231
|
If you're writing an application, try to call Ecology.read early.
|
183
|
-
Libraries depending on it can then initialize themselves
|
184
|
-
|
185
|
-
|
186
|
-
If you're writing a library, call Ecology.
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
232
|
+
Libraries depending on it can then initialize themselves since they
|
233
|
+
know where your Ecology data is.
|
234
|
+
|
235
|
+
If you're writing a library, call Ecology.read as late as you can. If
|
236
|
+
your applications that use your library also use Ecology, maybe you can
|
237
|
+
go without using it at all. But if you're calling Ecology.read with
|
238
|
+
no filename to make sure data is initialized, do it as late as you can
|
239
|
+
possibly get away with it.
|
240
|
+
|
241
|
+
But in a library, call Ecology.on_initialize early to make sure you
|
242
|
+
get initialized as soon as possible. You'll probably need your own
|
243
|
+
Ecology.read call since your containing application may not use
|
244
|
+
Ecology, or have an Ecology file. Try to make Ecology.read happen as
|
245
|
+
late as you can - the first time you genuinely need the data, for
|
191
246
|
instance.
|
192
247
|
|
193
248
|
For test purposes, if you set a bunch of data with
|
@@ -195,9 +250,23 @@ Ecology.on_initialize, try to register Ecology.on_reset to clear that
|
|
195
250
|
same data. Then a test using Ecology.reset can test your library with
|
196
251
|
different settings.
|
197
252
|
|
253
|
+
Ecology and Libraries
|
254
|
+
=====================
|
255
|
+
|
256
|
+
In Rails 3, Ecology.read belongs somewhere like config/application.rb.
|
257
|
+
In Rails 2, Ecology.read should probably be in config/environment.rb,
|
258
|
+
early on. In Sinatra, you want it in your configure block. In
|
259
|
+
general, it should go with configuration information and it should be
|
260
|
+
executed as soon as possible.
|
261
|
+
|
198
262
|
Testing with an Ecology
|
199
263
|
=======================
|
200
264
|
|
265
|
+
The Ecology library provides a simple hook for setting up an ecology
|
266
|
+
for your application. Just require "ecology/test_methods" into your
|
267
|
+
test or test_helper, then call set_up_ecology with the text of the
|
268
|
+
ecology as the first argument.
|
269
|
+
|
201
270
|
In production use, you'll probably never reset the ecology. However,
|
202
271
|
in testing you may frequently want to, especially if you're testing a
|
203
272
|
library that ties closely into the ecology.
|
@@ -234,7 +303,7 @@ Releasing within Ooyala
|
|
234
303
|
|
235
304
|
Ooyalans, to release Ecology to gems.sv2, use the following:
|
236
305
|
|
237
|
-
|
306
|
+
rake build
|
238
307
|
rake _0.8.7_ -f ../ooyala_gems.rake gem:push ecology-0.0.1.gem
|
239
308
|
|
240
309
|
Change the version to the actual version you'd like to push.
|
data/TODO
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
* On Ecology.read calls, make sure ecology filename hasn't changed (and warn if it has)
|
2
|
-
|
3
1
|
* Have Ecology.read try to do a read relative to the executable's directory first rather than relative to cwd.
|
4
2
|
|
5
|
-
*
|
6
|
-
|
7
|
-
* Allow setting environment variables based on Ecology
|
3
|
+
* Allow registration of properties by top-level tag - a particular gem can say "these are the permitted properties
|
4
|
+
under this top-level tag".
|
data/bin/with_ecology
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "ecology"
|
5
|
+
require "multi_json"
|
6
|
+
|
7
|
+
if ARGV.size == 0
|
8
|
+
$stderr.puts <<USAGE
|
9
|
+
Usage: with_ecology [-simple] <ecology-name>.ecology[.erb] <binary> [<args>]
|
10
|
+
|
11
|
+
Use "-simple" to exclude ECOLOGY_property_LENGTH and _TYPE fields.
|
12
|
+
USAGE
|
13
|
+
exit -1
|
14
|
+
end
|
15
|
+
|
16
|
+
@exclude_fields = false
|
17
|
+
|
18
|
+
ARGS = ["-simple"]
|
19
|
+
|
20
|
+
arg = ARGV.shift
|
21
|
+
|
22
|
+
while ARGS.include?(arg)
|
23
|
+
if arg == "-simple"
|
24
|
+
@exclude_fields = true
|
25
|
+
arg = ARGV.shift
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
arg = ARGV.shift if arg == "--"
|
30
|
+
|
31
|
+
Ecology.read(arg)
|
32
|
+
|
33
|
+
def export_prefix_key_value(prefix, key, value)
|
34
|
+
env_var_name = "#{prefix}#{key}"
|
35
|
+
|
36
|
+
type = case value
|
37
|
+
when Fixnum
|
38
|
+
"int"
|
39
|
+
when String
|
40
|
+
"string"
|
41
|
+
when Float
|
42
|
+
"float"
|
43
|
+
when TrueClass
|
44
|
+
"bool"
|
45
|
+
when FalseClass
|
46
|
+
"bool"
|
47
|
+
when NilClass
|
48
|
+
"null"
|
49
|
+
else
|
50
|
+
"unknown"
|
51
|
+
end
|
52
|
+
|
53
|
+
ENV[env_var_name] = value.to_s
|
54
|
+
|
55
|
+
unless @exclude_fields
|
56
|
+
ENV[env_var_name + "_TYPE"] = type
|
57
|
+
ENV[env_var_name + "_LENGTH"] = value.to_s.length.to_s
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def export_properties(data, prefix)
|
62
|
+
data.each do |key, value|
|
63
|
+
if value.is_a?(Hash)
|
64
|
+
export_properties(value, "#{prefix}#{key}_")
|
65
|
+
elsif value.is_a?(Array)
|
66
|
+
export_prefix_key_value prefix, key, MultiJSON.encode(value)
|
67
|
+
else
|
68
|
+
export_prefix_key_value prefix, key, value
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
export_properties(Ecology.data, "ECOLOGY_")
|
74
|
+
|
75
|
+
exec ARGV.join(" ")
|
data/ecology.gemspec
CHANGED
@@ -24,7 +24,9 @@ EOS
|
|
24
24
|
dotfiles = Dir[".*"]
|
25
25
|
s.files = Dir["**/*"].reject {|f| File.directory?(f) || ignores.any? {|i| File.fnmatch(i, f) } } + dotfiles
|
26
26
|
s.test_files = s.files.grep(/^test\//)
|
27
|
+
s.executables << "with_ecology"
|
27
28
|
|
29
|
+
s.bindir = "bin"
|
28
30
|
s.require_paths = ["lib"]
|
29
31
|
|
30
32
|
s.add_dependency "multi_json"
|
data/lib/ecology.rb
CHANGED
@@ -24,32 +24,34 @@ module Ecology
|
|
24
24
|
@environment = nil
|
25
25
|
@data = nil
|
26
26
|
@ecology_initialized = nil
|
27
|
+
@ecology_path = nil
|
27
28
|
|
28
29
|
publish_event :reset
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
@triggers = {}
|
33
|
-
end
|
34
|
-
|
32
|
+
# This function is called in applications or libraries to initialize the ecology
|
35
33
|
def read(ecology_pathname = nil)
|
36
|
-
|
34
|
+
filelist = [ENV["ECOLOGY_SPEC"], ecology_pathname, default_ecology_name]
|
35
|
+
ecology_path = filelist.detect { |file_path|
|
36
|
+
file_path && (File.exist?(file_path) || File.exist?(file_path + ".erb"))
|
37
|
+
}
|
38
|
+
|
39
|
+
if @ecology_initialized
|
40
|
+
if ecology_path != nil && File.expand_path(ecology_path) != File.expand_path(@ecology_path)
|
41
|
+
raise "You've tried to load both #{ecology_path.inspect || "nothing"} and " +
|
42
|
+
"#{@ecology_path.inspect || "nothing"} as ecology files since last reset!"
|
43
|
+
end
|
44
|
+
return
|
45
|
+
end
|
37
46
|
|
38
47
|
should_publish_event = false
|
39
48
|
|
40
49
|
mutex.synchronize do
|
41
50
|
return if @ecology_initialized
|
42
51
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
@data = {}
|
47
|
-
contents = merge_with_overrides(file_path)
|
48
|
-
true
|
49
|
-
else
|
50
|
-
false
|
51
|
-
end
|
52
|
-
end
|
52
|
+
@ecology_path = ecology_path
|
53
|
+
@data ||= {}
|
54
|
+
merge_with_overrides!(@ecology_path) if @ecology_path
|
53
55
|
|
54
56
|
@application ||= File.basename($0)
|
55
57
|
@environment ||= ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development"
|
@@ -60,10 +62,13 @@ module Ecology
|
|
60
62
|
end
|
61
63
|
|
62
64
|
# Do this outside the mutex to reduce the likelihood
|
63
|
-
# of deadlocks.
|
65
|
+
# of deadlocks. This will run all of the on_initialize triggers.
|
64
66
|
publish_event(:initialize) if should_publish_event
|
67
|
+
nil
|
65
68
|
end
|
66
69
|
|
70
|
+
# These functions are called to set and remove triggers that are called when
|
71
|
+
# the specified event has occurred.
|
67
72
|
def on_initialize(token = nil, &block)
|
68
73
|
on_event(:initialize, token, &block)
|
69
74
|
end
|
@@ -79,6 +84,10 @@ module Ecology
|
|
79
84
|
end
|
80
85
|
end
|
81
86
|
|
87
|
+
def clear_triggers
|
88
|
+
@triggers = {}
|
89
|
+
end
|
90
|
+
|
82
91
|
private
|
83
92
|
|
84
93
|
def on_event(event, token = nil, &block)
|
@@ -96,6 +105,8 @@ module Ecology
|
|
96
105
|
end
|
97
106
|
end
|
98
107
|
|
108
|
+
# This function tells Ecology that a certain event (i.e. intialization) has happened.
|
109
|
+
# It will then proceed to run all of the triggers that have been set in the application for this event.
|
99
110
|
def publish_event(event)
|
100
111
|
@triggers ||= {}
|
101
112
|
|
@@ -108,7 +119,11 @@ module Ecology
|
|
108
119
|
end
|
109
120
|
end
|
110
121
|
|
111
|
-
|
122
|
+
# This function populates the @data, @application, and @environment objects,
|
123
|
+
# which are populated from the ecology file. It prefers earlier values (top-level first),
|
124
|
+
# to values defined in inherited ecologies. This function does not return anything,
|
125
|
+
# but modifies @data directly.
|
126
|
+
def merge_with_overrides!(file_path)
|
112
127
|
if File.exist?(file_path + ".erb")
|
113
128
|
contents = File.read(file_path + ".erb")
|
114
129
|
|
@@ -121,7 +136,7 @@ module Ecology
|
|
121
136
|
else
|
122
137
|
contents = File.read(file_path)
|
123
138
|
end
|
124
|
-
file_data = MultiJson.
|
139
|
+
file_data = MultiJson.load(contents);
|
125
140
|
|
126
141
|
return unless file_data
|
127
142
|
|
@@ -133,28 +148,29 @@ module Ecology
|
|
133
148
|
if !@environment && file_data["environment-from"]
|
134
149
|
from = file_data["environment-from"]
|
135
150
|
if from.respond_to?(:map)
|
136
|
-
@environment ||= from.map {|
|
151
|
+
@environment ||= from.map {|env_var| ENV[env_var]}.compact.first
|
137
152
|
else
|
138
|
-
@environment
|
153
|
+
@environment ||= ENV[from] ? ENV[from].to_s : nil
|
139
154
|
end
|
140
155
|
end
|
141
156
|
|
142
157
|
# Next, filter the data by the current environment
|
143
158
|
file_data = environmentize_data(file_data)
|
144
159
|
|
145
|
-
# Merge the file data into @data
|
160
|
+
# Merge the file data into @data, preferring previous values in @data to new values from the file.
|
146
161
|
@data = deep_merge(@data, file_data)
|
147
162
|
|
148
|
-
# Finally, process any inheritance
|
163
|
+
# Finally, process any inheritance, without overriding already set values.
|
149
164
|
if file_data["uses"]
|
150
165
|
if file_data["uses"].respond_to?(:map)
|
151
|
-
file_data["uses"].map { |file| merge_with_overrides(file) }
|
166
|
+
file_data["uses"].map { |file| merge_with_overrides!(file) }
|
152
167
|
else
|
153
|
-
merge_with_overrides(file_data["uses"])
|
168
|
+
merge_with_overrides!(file_data["uses"])
|
154
169
|
end
|
155
170
|
end
|
156
171
|
end
|
157
172
|
|
173
|
+
# Merge two hashes, resolving conflicts by picking the value from the first.
|
158
174
|
def deep_merge(hash1, hash2)
|
159
175
|
all_keys = hash1.keys | hash2.keys
|
160
176
|
ret = {}
|
@@ -176,32 +192,35 @@ module Ecology
|
|
176
192
|
ret
|
177
193
|
end
|
178
194
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
195
|
+
# This function crawls through input_data, and chooses values for environment-based keys.
|
196
|
+
def environmentize_data(input_data)
|
197
|
+
if input_data.is_a?(Array)
|
198
|
+
input_data.map { |subdata| environmentize_data(subdata) }
|
199
|
+
elsif input_data.is_a?(Hash)
|
200
|
+
if input_data.keys.any? { |k| k =~ /^env:/ }
|
201
|
+
value = input_data["env:#{@environment}"] || input_data["env:*"]
|
185
202
|
return nil unless value
|
186
203
|
environmentize_data(value)
|
187
204
|
else
|
188
|
-
|
189
|
-
|
190
|
-
|
205
|
+
output_data = {}
|
206
|
+
input_data.each { |k, v| output_data[k] = environmentize_data(v) }
|
207
|
+
output_data
|
191
208
|
end
|
192
209
|
else
|
193
|
-
|
210
|
+
input_data
|
194
211
|
end
|
195
212
|
end
|
196
213
|
|
197
214
|
public
|
198
215
|
|
216
|
+
# Returns the value of a specified property, with nestings denoted with colons.
|
217
|
+
# This can be requested with :as => <type> as an option.
|
199
218
|
def property(param, options = {})
|
200
219
|
components = param.split(":").compact.select {|s| s != ""}
|
201
220
|
|
202
|
-
value = components.inject(@data) do |
|
203
|
-
if
|
204
|
-
|
221
|
+
value = components.inject(@data) do |data_hash, component|
|
222
|
+
if data_hash
|
223
|
+
data_hash[component]
|
205
224
|
else
|
206
225
|
nil
|
207
226
|
end
|
@@ -224,12 +243,12 @@ module Ecology
|
|
224
243
|
elsif [:json].include?(options[:as])
|
225
244
|
raise "JSON return type not yet supported!"
|
226
245
|
else
|
227
|
-
raise "Unknown type #{options[:as].inspect} passed to Ecology.
|
246
|
+
raise "Unknown type #{options[:as].inspect} passed to Ecology.property(:as) for property #{param}!"
|
228
247
|
end
|
229
248
|
end
|
230
249
|
|
231
250
|
return value if options[:as] == Hash
|
232
|
-
raise "Couldn't convert JSON fields to #{options[:as].inspect} for property #{
|
251
|
+
raise "Couldn't convert JSON fields to #{options[:as].inspect} for property #{param}!"
|
233
252
|
end
|
234
253
|
|
235
254
|
PATH_SUBSTITUTIONS = {
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Ecology
|
2
|
+
module Test
|
3
|
+
def set_up_ecology(file_contents, filename = "some.ecology", options = {})
|
4
|
+
match = filename.match(/^(.*)\.erb$/)
|
5
|
+
if match
|
6
|
+
ENV["ECOLOGY_SPEC"] = match[1]
|
7
|
+
File.stubs(:exist?).with(match[1]).returns(false)
|
8
|
+
else
|
9
|
+
ENV["ECOLOGY_SPEC"] = filename
|
10
|
+
end
|
11
|
+
|
12
|
+
File.stubs(:exist?).with(filename + ".erb").returns(false)
|
13
|
+
File.stubs(:exist?).with(filename).returns(true)
|
14
|
+
|
15
|
+
unless options[:no_read]
|
16
|
+
File.expects(:read).with(filename).returns(file_contents).at_least_once
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/ecology/version.rb
CHANGED
data/lib/ecology/version.rb~
CHANGED
data/test/ecology_test.rb
CHANGED
@@ -39,5 +39,52 @@ class EcologyTest < Scope::TestCase
|
|
39
39
|
|
40
40
|
assert_equal "whatever_app.rb", Ecology.application
|
41
41
|
end
|
42
|
+
|
43
|
+
should "prevent repeat Ecology.read with different ecology files" do
|
44
|
+
set_up_ecology <<JSON
|
45
|
+
{
|
46
|
+
"application": "bob"
|
47
|
+
}
|
48
|
+
JSON
|
49
|
+
Ecology.read
|
50
|
+
set_up_ecology(<<JSON, "other.ecology", :no_read => true)
|
51
|
+
{
|
52
|
+
"application": "sam"
|
53
|
+
}
|
54
|
+
JSON
|
55
|
+
assert_raises(RuntimeError) do
|
56
|
+
Ecology.read
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
should "allow repeat Ecology.read with same ecology files" do
|
61
|
+
set_up_ecology(<<JSON, "same.ecology")
|
62
|
+
{
|
63
|
+
"application": "bob"
|
64
|
+
}
|
65
|
+
JSON
|
66
|
+
Ecology.read
|
67
|
+
set_up_ecology(<<JSON, "same.ecology", :no_read => true)
|
68
|
+
{
|
69
|
+
"application": "sam"
|
70
|
+
}
|
71
|
+
JSON
|
72
|
+
Ecology.read # should not raise
|
73
|
+
end
|
74
|
+
|
75
|
+
should "allow repeat Ecology.read with different paths to the same ecology files" do
|
76
|
+
set_up_ecology(<<JSON, "same.ecology")
|
77
|
+
{
|
78
|
+
"application": "bob"
|
79
|
+
}
|
80
|
+
JSON
|
81
|
+
Ecology.read
|
82
|
+
set_up_ecology(<<JSON, "./same.ecology", :no_read => true)
|
83
|
+
{
|
84
|
+
"application": "sam"
|
85
|
+
}
|
86
|
+
JSON
|
87
|
+
Ecology.read # should not raise
|
88
|
+
end
|
42
89
|
end
|
43
90
|
end
|
data/test/test_helper.rb
CHANGED
@@ -7,20 +7,8 @@ require "minitest/autorun"
|
|
7
7
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
8
8
|
|
9
9
|
require "ecology"
|
10
|
+
require "ecology/test_methods"
|
10
11
|
|
11
12
|
class Scope::TestCase
|
12
|
-
|
13
|
-
match = filename.match(/^(.*)\.erb$/)
|
14
|
-
if match
|
15
|
-
ENV["ECOLOGY_SPEC"] = match[1]
|
16
|
-
File.stubs(:exist?).with(match[1]).returns(false)
|
17
|
-
else
|
18
|
-
ENV["ECOLOGY_SPEC"] = filename
|
19
|
-
end
|
20
|
-
|
21
|
-
File.stubs(:exist?).with(filename + ".erb").returns(false)
|
22
|
-
File.stubs(:exist?).with(filename).returns(true)
|
23
|
-
File.expects(:read).with(filename).returns(file_contents).at_least_once
|
24
|
-
end
|
25
|
-
|
13
|
+
include Ecology::Test
|
26
14
|
end
|
metadata
CHANGED
@@ -1,102 +1,133 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecology
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.18
|
4
5
|
prerelease:
|
5
|
-
version: 0.0.14
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Noah Gibbs
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-06-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: multi_json
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
24
22
|
type: :runtime
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: erubis
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: erubis
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
30
33
|
none: false
|
31
|
-
requirements:
|
32
|
-
- -
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
35
38
|
type: :runtime
|
36
|
-
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: bundler
|
39
39
|
prerelease: false
|
40
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
41
49
|
none: false
|
42
|
-
requirements:
|
50
|
+
requirements:
|
43
51
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
52
|
+
- !ruby/object:Gem::Version
|
45
53
|
version: 1.0.10
|
46
54
|
type: :development
|
47
|
-
version_requirements: *id003
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: scope
|
50
55
|
prerelease: false
|
51
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.10
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: scope
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
52
65
|
none: false
|
53
|
-
requirements:
|
66
|
+
requirements:
|
54
67
|
- - ~>
|
55
|
-
- !ruby/object:Gem::Version
|
68
|
+
- !ruby/object:Gem::Version
|
56
69
|
version: 0.2.1
|
57
70
|
type: :development
|
58
|
-
version_requirements: *id004
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
|
-
name: mocha
|
61
71
|
prerelease: false
|
62
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.2.1
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: mocha
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
63
81
|
none: false
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version:
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
68
86
|
type: :development
|
69
|
-
version_requirements: *id005
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rake
|
72
87
|
prerelease: false
|
73
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rake
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
74
97
|
none: false
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version:
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
79
102
|
type: :development
|
80
|
-
|
81
|
-
|
82
|
-
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: ! 'Ecology sets configuration data for an application based
|
111
|
+
|
83
112
|
on environment variables and other factors. It is meant
|
113
|
+
|
84
114
|
to unify configuration data for logging, testing, monitoring
|
115
|
+
|
85
116
|
and deployment.
|
86
117
|
|
87
|
-
|
118
|
+
'
|
119
|
+
email:
|
88
120
|
- noah@ooyala.com
|
89
|
-
executables:
|
90
|
-
|
121
|
+
executables:
|
122
|
+
- with_ecology
|
91
123
|
extensions: []
|
92
|
-
|
93
124
|
extra_rdoc_files: []
|
94
|
-
|
95
|
-
|
125
|
+
files:
|
126
|
+
- bin/with_ecology
|
96
127
|
- ecology.gemspec
|
97
|
-
- ecology.gemspec~
|
98
128
|
- Gemfile
|
99
129
|
- Gemfile.lock
|
130
|
+
- lib/ecology/test_methods.rb
|
100
131
|
- lib/ecology/version.rb
|
101
132
|
- lib/ecology/version.rb~
|
102
133
|
- lib/ecology.rb
|
@@ -114,34 +145,32 @@ files:
|
|
114
145
|
- test/trigger_test.rb
|
115
146
|
- TODO
|
116
147
|
- .gitignore
|
148
|
+
- .yardopts
|
117
149
|
homepage: http://www.ooyala.com
|
118
150
|
licenses: []
|
119
|
-
|
120
151
|
post_install_message:
|
121
152
|
rdoc_options: []
|
122
|
-
|
123
|
-
require_paths:
|
153
|
+
require_paths:
|
124
154
|
- lib
|
125
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
156
|
none: false
|
127
|
-
requirements:
|
128
|
-
- -
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version:
|
131
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ! '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
162
|
none: false
|
133
|
-
requirements:
|
134
|
-
- -
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version:
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
137
167
|
requirements: []
|
138
|
-
|
139
168
|
rubyforge_project: ecology
|
140
|
-
rubygems_version: 1.8.
|
169
|
+
rubygems_version: 1.8.24
|
141
170
|
signing_key:
|
142
171
|
specification_version: 3
|
143
172
|
summary: Ruby config variable management
|
144
|
-
test_files:
|
173
|
+
test_files:
|
145
174
|
- test/ecology_test.rb
|
146
175
|
- test/environment_test.rb
|
147
176
|
- test/environment_var_test.rb
|
@@ -151,3 +180,4 @@ test_files:
|
|
151
180
|
- test/property_test.rb
|
152
181
|
- test/test_helper.rb
|
153
182
|
- test/trigger_test.rb
|
183
|
+
has_rdoc:
|
data/ecology.gemspec~
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
|
4
|
-
require "ecology/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "ecology"
|
8
|
-
s.version = Ecology::VERSION
|
9
|
-
s.platform = Gem::Platform::RUBY
|
10
|
-
s.authors = ["Noah Gibbs"]
|
11
|
-
s.email = ["noah@ooyala.com"]
|
12
|
-
s.homepage = "http://www.ooyala.com"
|
13
|
-
s.summary = %q{Ruby config variable management}
|
14
|
-
s.description = <<EOS
|
15
|
-
Ecology sets configuration data for an application based
|
16
|
-
on environment variables and other factors. It is meant
|
17
|
-
to unify configuration data for logging, testing, monitoring
|
18
|
-
and deployment.
|
19
|
-
EOS
|
20
|
-
|
21
|
-
s.rubyforge_project = "ecology"
|
22
|
-
|
23
|
-
ignores = File.readlines(".gitignore").grep(/\S+/).map {|pattern| pattern.chomp }
|
24
|
-
dotfiles = [".gemtest", ".gitignore", ".rspec", ".yardopts"]
|
25
|
-
s.files = Dir["**/*"].reject {|f| File.directory?(f) || ignores.any? {|i| File.fnmatch(i, f) } } + dotfiles
|
26
|
-
s.test_files = s.files.grep(/^spec\//)
|
27
|
-
|
28
|
-
s.require_paths = ["lib"]
|
29
|
-
|
30
|
-
s.add_dependency "multi_json"
|
31
|
-
|
32
|
-
s.add_development_dependency "bundler", "~> 1.0.10"
|
33
|
-
s.add_development_dependency "scope", "~> 0.2.1"
|
34
|
-
s.add_development_dependency "mocha"
|
35
|
-
s.add_development_dependency "rake"
|
36
|
-
end
|