footing 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/footing/extensions/hash.rb +25 -10
- data/lib/footing/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2cb11b769adfd12d6ac4f1963680698f75a8bf8
|
4
|
+
data.tar.gz: e456c26bd648c7841985cb9735ed91ce5351d17c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3af139f94964aee80e85912ed1b6fec49f39d096e7440504c8d292803391a689ff359ae681307a5f1cb91a663816a0dfd82a91f50d21eba6a03f0c68ea3eed8e
|
7
|
+
data.tar.gz: 810fb6a30f44121a7088544aa9ff4e063f8ae429639e22e6c45bc03be008d4e8f207e505f727cccd07ccaebb83402a8658c13e8f7dae013fc0808a90c2142e7a
|
data/Gemfile.lock
CHANGED
@@ -13,7 +13,7 @@ module Footing
|
|
13
13
|
# @param [Symbol] name The method name to invoke on the existing keys.
|
14
14
|
# @return [Hash] A new Hash that has been re-keyed.
|
15
15
|
def rekey(method_name)
|
16
|
-
|
16
|
+
reduce({}) do |new_hash, (key, value)|
|
17
17
|
new_hash[key.public_send(method_name)] = value
|
18
18
|
new_hash
|
19
19
|
end
|
@@ -24,15 +24,20 @@ module Footing
|
|
24
24
|
# @yield [value] Yields the value after the encoding has been applied.
|
25
25
|
def force_encoding!(encoding, &block)
|
26
26
|
each do |key, value|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
if value.respond_to?(:force_encoding!)
|
28
|
+
value.force_encoding!(encoding, &block)
|
29
|
+
elsif value.is_a?(Enumerable)
|
30
|
+
value.each do |val|
|
31
|
+
next unless val.respond_to?(:force_encoding!)
|
32
|
+
val.force_encoding!(encoding, &block)
|
33
|
+
end
|
34
|
+
elsif value.is_a?(String)
|
35
|
+
# force encoding then strip all non ascii chars
|
36
|
+
if block_given?
|
37
|
+
self[key] = yield(value.force_encoding(encoding))
|
38
|
+
else
|
39
|
+
self[key] = value.force_encoding(encoding)
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
@@ -50,6 +55,11 @@ module Footing
|
|
50
55
|
each do |key, value|
|
51
56
|
if value.respond_to?(:adjust_values!)
|
52
57
|
value.adjust_values!(&block)
|
58
|
+
elsif value.is_a?(Enumerable)
|
59
|
+
value.each do |val|
|
60
|
+
next unless val.respond_to?(:adjust_values!)
|
61
|
+
val.adjust_values!(&block)
|
62
|
+
end
|
53
63
|
else
|
54
64
|
self[key] = yield(value)
|
55
65
|
end
|
@@ -63,6 +73,11 @@ module Footing
|
|
63
73
|
each do |key, value|
|
64
74
|
if value.respond_to?(:cast_values!)
|
65
75
|
value.cast_values!
|
76
|
+
elsif value.is_a?(Enumerable)
|
77
|
+
value.each do |val|
|
78
|
+
next unless val.respond_to?(:cast_values!)
|
79
|
+
val.cast_values!
|
80
|
+
end
|
66
81
|
elsif value.respond_to?(:cast)
|
67
82
|
self[key] = value.cast
|
68
83
|
end
|
data/lib/footing/version.rb
CHANGED