rack-config-flexible 0.1.3 → 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/lib/rack/config/flexible.rb +8 -8
- metadata +1 -1
data/lib/rack/config/flexible.rb
CHANGED
@@ -132,18 +132,18 @@ class Config
|
|
132
132
|
@values = {}
|
133
133
|
raise ArgumentError.new('`options\' must be a Hash') unless options.is_a?(Hash)
|
134
134
|
|
135
|
-
if options.has_key?(:from_file) && File.directory?(options[:from_file])
|
135
|
+
if options.has_key?(:from_file) && ::File.directory?(options[:from_file])
|
136
136
|
# Load from a directory tree
|
137
137
|
Dir[options[:from_file] + '/*'].each { |env|
|
138
|
-
next unless File.directory?(env)
|
139
|
-
environment File.basename(env)
|
138
|
+
next unless ::File.directory?(env)
|
139
|
+
environment ::File.basename(env)
|
140
140
|
|
141
141
|
Dir[env + '/*.yaml'].each { |sec|
|
142
|
-
next unless File.file?(sec)
|
143
|
-
section File.basename(sec,'.yaml'),sec
|
142
|
+
next unless ::File.file?(sec)
|
143
|
+
section ::File.basename(sec,'.yaml'),sec
|
144
144
|
}
|
145
145
|
}
|
146
|
-
elsif options.has_key?(:from_file) && File.exist?(options[:from_file])
|
146
|
+
elsif options.has_key?(:from_file) && ::File.exist?(options[:from_file])
|
147
147
|
# Load from a single file
|
148
148
|
@values = Hash[YAML.load_file(options[:from_file]).map { |k,v|
|
149
149
|
[k.to_sym, Hash[v.map { |k,v| [ k.to_sym,v ]}]] if k.is_a?(String) && v.is_a?(Hash)
|
@@ -187,7 +187,7 @@ class Config
|
|
187
187
|
@values[@env] = {} unless @values.has_key?(@env) && @values[@env].is_a?(Hash)
|
188
188
|
|
189
189
|
# Load from a file, or hash, if specified
|
190
|
-
if data.is_a?(String) && File.exist?(data)
|
190
|
+
if data.is_a?(String) && ::File.exist?(data)
|
191
191
|
@values[@env].merge!(Hash[YAML.load_file(data).map { |k,v| [k.to_sym, v] if k.is_a?(String) }])
|
192
192
|
@sec = @values[@env].keys.last
|
193
193
|
elsif data.is_a?(Hash)
|
@@ -212,7 +212,7 @@ class Config
|
|
212
212
|
@values[@env][@sec].merge!(vals) if vals.is_a?(Hash)
|
213
213
|
|
214
214
|
# If vals is a string, it's assumed to be a YAML file
|
215
|
-
@values[@env][@sec].merge!(YAML.load_file(vals)) if vals.is_a?(String) && File.exist?(vals)
|
215
|
+
@values[@env][@sec].merge!(YAML.load_file(vals)) if vals.is_a?(String) && ::File.exist?(vals)
|
216
216
|
end
|
217
217
|
|
218
218
|
# :category:DSL
|