merb_app_config 1.0.6 → 1.0.7
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/Rakefile +1 -1
- data/lib/application_config/config_builder.rb +29 -1
- data/lib/application_config/view_helpers.rb +3 -10
- data/lib/merb_app_config.rb +1 -0
- metadata +2 -2
data/Rakefile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
require 'yaml'
|
3
3
|
require 'erb'
|
4
|
-
require 'deep_merge'
|
5
4
|
|
6
5
|
module ApplicationConfig
|
7
6
|
# == Summary
|
@@ -129,5 +128,34 @@ module ApplicationConfig
|
|
129
128
|
return new_config.uniq
|
130
129
|
end
|
131
130
|
|
131
|
+
# Cycles through the array of single element hashes
|
132
|
+
# and deep merges any duplicates it finds
|
133
|
+
#
|
134
|
+
# This is needed so you can define stylesheet keys
|
135
|
+
# in multiple config files
|
136
|
+
def self.merge_assets(list)
|
137
|
+
assets = Array(list).map do |i|
|
138
|
+
if i.is_a?(OpenStruct)
|
139
|
+
i.marshal_dump
|
140
|
+
else
|
141
|
+
i
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# filter out the duplicate single hash keys
|
146
|
+
hash_keys = assets.select{|i| i.is_a?(Hash) and i.keys.size == 1}.group_by{|i| i.keys[0]}
|
147
|
+
hash_keys.each do |key, value|
|
148
|
+
if Array(value).size > 1
|
149
|
+
merged = value.inject({}){|merged, v| DeepMerge.deep_merge!(v,merged)}
|
150
|
+
value[0].replace(merged)
|
151
|
+
value[1..-1].each do |v|
|
152
|
+
v.clear
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
assets.select{|i| !i.blank? }
|
158
|
+
end
|
159
|
+
|
132
160
|
end
|
133
161
|
end
|
@@ -4,11 +4,8 @@ module ApplicationConfig
|
|
4
4
|
html = ""
|
5
5
|
only = [options.delete(:only)].flatten.compact.map{|i| i.to_s}
|
6
6
|
if defined?(AppConfig) and AppConfig.javascripts
|
7
|
-
|
8
|
-
|
9
|
-
javascript = javascript.marshal_dump
|
10
|
-
end
|
11
|
-
|
7
|
+
|
8
|
+
ConfigBuilder.merge_assets(AppConfig.javascripts).each do |javascript|
|
12
9
|
if javascript.is_a? Hash
|
13
10
|
javascript.each do |key, val|
|
14
11
|
next unless only.empty? || only.include?(key.to_s)
|
@@ -43,11 +40,7 @@ module ApplicationConfig
|
|
43
40
|
html = ""
|
44
41
|
only = [options.delete(:only)].flatten.compact.map{|i| i.to_s}
|
45
42
|
if defined?(AppConfig) and AppConfig.stylesheets
|
46
|
-
AppConfig.stylesheets.each do |stylesheet|
|
47
|
-
if stylesheet.is_a?(OpenStruct)
|
48
|
-
stylesheet = stylesheet.marshal_dump
|
49
|
-
end
|
50
|
-
|
43
|
+
ConfigBuilder.merge_assets(AppConfig.stylesheets).each do |stylesheet|
|
51
44
|
if stylesheet.is_a? Hash
|
52
45
|
stylesheet.each do |key, val|
|
53
46
|
next unless only.empty? || only.include?(key.to_s)
|
data/lib/merb_app_config.rb
CHANGED
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.0.
|
4
|
+
version: 1.0.7
|
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-07-
|
12
|
+
date: 2009-07-31 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|