merb_app_config 1.0.7 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/application_config/config_builder.rb +2 -1
- data/lib/application_config/deep_merge.rb +7 -7
- metadata +3 -3
data/Rakefile
CHANGED
@@ -21,6 +21,7 @@ module ApplicationConfig
|
|
21
21
|
|
22
22
|
# add singleton method to our AppConfig that reloads its settings from the load_paths options
|
23
23
|
def config.reload!
|
24
|
+
|
24
25
|
conf = {}
|
25
26
|
ConfigBuilder.load_paths.to_a.each do |path|
|
26
27
|
file_conf = YAML.load(ERB.new(IO.read(path)).result) if path and File.exists?(path)
|
@@ -34,7 +35,7 @@ module ApplicationConfig
|
|
34
35
|
conf[expand_path] = ApplicationConfig::ConfigBuilder.expand(conf[expand_path], "#{ConfigBuilder.root_path}/public/#{expand_path}")
|
35
36
|
end
|
36
37
|
end
|
37
|
-
|
38
|
+
|
38
39
|
# load all the new values into the openstruct
|
39
40
|
marshal_load(ApplicationConfig::ConfigBuilder.convert(conf).marshal_dump)
|
40
41
|
|
@@ -62,17 +62,17 @@ module DeepMerge
|
|
62
62
|
merge_debug = options[:merge_debug] || false
|
63
63
|
overwrite_unmergeable = !options[:preserve_unmergeables]
|
64
64
|
knockout_prefix = options[:knockout_prefix] || nil
|
65
|
-
if knockout_prefix == ""
|
66
|
-
if knockout_prefix && !overwrite_unmergeable
|
65
|
+
if knockout_prefix == ""; raise InvalidParameter, "knockout_prefix cannot be an empty string in deep_merge!"; end
|
66
|
+
if knockout_prefix && !overwrite_unmergeable; raise InvalidParameter, "overwrite_unmergeable must be true if knockout_prefix is specified in deep_merge!"; end
|
67
67
|
# if present: we will split and join arrays on this char before merging
|
68
68
|
array_split_char = options[:unpack_arrays] || false
|
69
69
|
# request that we sort together any arrays when they are merged
|
70
70
|
sort_merged_arrays = options[:sort_merged_arrays] || false
|
71
71
|
di = options[:debug_indent] || ''
|
72
72
|
# do nothing if source is nil
|
73
|
-
if !source || (source.respond_to?(:blank?) && source.blank?)
|
73
|
+
if !source || (source.respond_to?(:blank?) && source.blank?); return dest; end
|
74
74
|
# if dest doesn't exist, then simply copy source to it
|
75
|
-
if !(dest) && overwrite_unmergeable
|
75
|
+
if !(dest) && overwrite_unmergeable; dest = source; return dest; end
|
76
76
|
|
77
77
|
puts "#{di}Source class: #{source.class.inspect} :: Dest class: #{dest.class.inspect}" if merge_debug
|
78
78
|
if source.kind_of?(Hash)
|
@@ -106,10 +106,10 @@ module DeepMerge
|
|
106
106
|
if array_split_char
|
107
107
|
puts "#{di} split/join on source: #{source.inspect}" if merge_debug
|
108
108
|
source = source.join(array_split_char).split(array_split_char)
|
109
|
-
if dest.kind_of?(Array)
|
109
|
+
if dest.kind_of?(Array); dest = dest.join(array_split_char).split(array_split_char); end
|
110
110
|
end
|
111
111
|
# if there's a naked knockout_prefix in source, that means we are to truncate dest
|
112
|
-
if source.index(knockout_prefix)
|
112
|
+
if source.index(knockout_prefix); dest = clear_or_nil(dest); source.delete(knockout_prefix); end
|
113
113
|
if dest.kind_of?(Array)
|
114
114
|
if knockout_prefix
|
115
115
|
print "#{di} knocking out: " if merge_debug
|
@@ -129,7 +129,7 @@ module DeepMerge
|
|
129
129
|
end
|
130
130
|
puts "#{di} merging arrays: #{source.inspect} :: #{dest.inspect}" if merge_debug
|
131
131
|
dest = dest | source
|
132
|
-
if sort_merged_arrays
|
132
|
+
if sort_merged_arrays; dest.sort!; end
|
133
133
|
elsif overwrite_unmergeable
|
134
134
|
puts "#{di} overwriting dest: #{source.inspect} -over-> #{dest.inspect}" if merge_debug
|
135
135
|
dest = overwrite_unmergeables(source, dest, options)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb_app_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: "1.1"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacques Crocker
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-27 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements: []
|
65
65
|
|
66
66
|
rubyforge_project: merb
|
67
|
-
rubygems_version: 1.3.
|
67
|
+
rubygems_version: 1.3.5
|
68
68
|
signing_key:
|
69
69
|
specification_version: 3
|
70
70
|
summary: Merb plugin that provides easy to use Application Configurations via YAML
|