netzke-core 0.4.5.1 → 0.4.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +3 -0
- data/Rakefile +1 -5
- data/javascripts/core.js +0 -1
- data/lib/netzke/base.rb +2 -2
- data/lib/netzke/core_ext.rb +7 -7
- data/test/unit/core_ext_test.rb +4 -1
- metadata +1 -1
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
= v0.4.5.2 - 2009-11-09
|
2
|
+
* Fix: Hash#convert_keys and Array#convert_keys in core extensions are now renamed into deep_convert_keys, and now always plainly do what they're expected to do: recursively convert keys according to given block.
|
3
|
+
|
1
4
|
= v0.4.5.1 - 2009-11-09
|
2
5
|
* Regression: fixing inheritance and caching.
|
3
6
|
* FeedbackGhost is too simple to be a Netzke widget (having no server part), so, moved to static JavaScript.
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
begin
|
2
2
|
require 'jeweler'
|
3
3
|
Jeweler::Tasks.new do |gemspec|
|
4
|
-
gemspec.version = "0.4.5.
|
4
|
+
gemspec.version = "0.4.5.2"
|
5
5
|
gemspec.name = "netzke-core"
|
6
6
|
gemspec.summary = "Build ExtJS/Rails widgets with minimum effort"
|
7
7
|
gemspec.description = "Allows building ExtJS/Rails reusable code in a DRY way"
|
@@ -11,10 +11,6 @@ begin
|
|
11
11
|
gemspec.authors = ["Sergei Kozlov"]
|
12
12
|
end
|
13
13
|
Jeweler::GemcutterTasks.new
|
14
|
-
# Jeweler::RubyforgeTasks.new do |rubyforge|
|
15
|
-
# rubyforge.doc_task = "rdoc"
|
16
|
-
# end
|
17
|
-
|
18
14
|
rescue LoadError
|
19
15
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
16
|
end
|
data/javascripts/core.js
CHANGED
data/lib/netzke/base.rb
CHANGED
@@ -232,7 +232,7 @@ module Netzke
|
|
232
232
|
|
233
233
|
def update_persistent_ext_config(hsh)
|
234
234
|
current_config = persistent_config[:ext_config] || {}
|
235
|
-
current_config.deep_merge!(hsh.
|
235
|
+
current_config.deep_merge!(hsh.deep_convert_keys{ |k| k.to_s }) # first, recursively stringify the keys
|
236
236
|
persistent_config[:ext_config] = current_config
|
237
237
|
end
|
238
238
|
|
@@ -299,7 +299,7 @@ module Netzke
|
|
299
299
|
# So we need to recursively merge it into the final result
|
300
300
|
res.deep_merge!(hsh_levels.first => anchor)
|
301
301
|
end
|
302
|
-
res.
|
302
|
+
res.deep_convert_keys{ |k| k.to_sym } # recursively symbolize the keys
|
303
303
|
end
|
304
304
|
memoize :persistent_config_hash
|
305
305
|
|
data/lib/netzke/core_ext.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
class Hash
|
2
2
|
|
3
3
|
# Recursively convert the keys. Example:
|
4
|
-
#
|
5
|
-
#
|
6
|
-
def
|
4
|
+
# {:bla_bla => 1, "wow_now" => {:look_ma => true}}.deep_convert_keys{|k| k.to_s.camelize.to_sym}
|
5
|
+
# => {:BlaBla => 1, "WowNow" => {:LookMa => true}}
|
6
|
+
def deep_convert_keys(&block)
|
7
7
|
block_given? ? self.inject({}) do |h,(k,v)|
|
8
|
-
h[
|
8
|
+
h[yield(k)] = v.respond_to?('deep_convert_keys') ? v.deep_convert_keys(&block) : v
|
9
9
|
h
|
10
10
|
end : self
|
11
11
|
end
|
@@ -83,10 +83,10 @@ class Array
|
|
83
83
|
self.recursive_delete_if_nil.jsonify.to_json
|
84
84
|
end
|
85
85
|
|
86
|
-
# Applies
|
87
|
-
def
|
86
|
+
# Applies deep_convert_keys to each element which responds to deep_convert_keys
|
87
|
+
def deep_convert_keys(&block)
|
88
88
|
block_given? ? self.map do |i|
|
89
|
-
i.respond_to?('
|
89
|
+
i.respond_to?('deep_convert_keys') ? i.deep_convert_keys(&block) : i
|
90
90
|
end : self
|
91
91
|
end
|
92
92
|
|
data/test/unit/core_ext_test.rb
CHANGED
@@ -19,9 +19,12 @@ class CoreExtTest < ActiveSupport::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
test "convert keys" do
|
22
|
+
assert_equal({:a => 1, :b => {:bb => 2}}, {"a" => 1, "b" => {"bb" => 2}}.deep_convert_keys{ |k| k.to_sym })
|
23
|
+
assert_equal([{"a" => 1}, {"b" => {"bb" => 2}}], [{:a => 1}, {:b => {:bb => 2}}].deep_convert_keys{ |k| k.to_s })
|
24
|
+
|
22
25
|
assert_equal([
|
23
26
|
{:aB => 1, :cDD => [{:lookMa => true},{:wowNow => true}]}
|
24
|
-
],[:a_b => 1, :c_d_d => [{:look_ma => true},{:wow_now => true}]].
|
27
|
+
],[:a_b => 1, :c_d_d => [{:look_ma => true},{:wow_now => true}]].deep_convert_keys{|k| k.to_s.camelize(:lower).to_sym})
|
25
28
|
end
|
26
29
|
|
27
30
|
test "javascript-like access to hash data" do
|