footing 0.1.9 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31c11d069e01d431aa95a5648e2b5fc9bc3f071e
4
- data.tar.gz: 21c75a976572f1c31ea4ea762f5702ab616ed947
3
+ metadata.gz: c2cb11b769adfd12d6ac4f1963680698f75a8bf8
4
+ data.tar.gz: e456c26bd648c7841985cb9735ed91ce5351d17c
5
5
  SHA512:
6
- metadata.gz: 7ad5e918d36cfc0e311af12524deec6f01ad01ed3eff33249312ee75fb7af165b65694d145ce017fe13f73debbf25902b764a2e5a10fc4b2cf194f752f19908f
7
- data.tar.gz: 04f48adb18e68f95c258e1c386cb66ff386648cbc68780c7f75957f6d2f41913b9ed52e67dc1b660968a652cb2639666012a8819adef3e31f0324f068083402f
6
+ metadata.gz: 3af139f94964aee80e85912ed1b6fec49f39d096e7440504c8d292803391a689ff359ae681307a5f1cb91a663816a0dfd82a91f50d21eba6a03f0c68ea3eed8e
7
+ data.tar.gz: 810fb6a30f44121a7088544aa9ff4e063f8ae429639e22e6c45bc03be008d4e8f207e505f727cccd07ccaebb83402a8658c13e8f7dae013fc0808a90c2142e7a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- footing (0.1.9)
4
+ footing (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- inject({}) do |new_hash, (key, value)|
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
- case value
28
- when String
29
- # force encoding then strip all non ascii chars
30
- if block_given?
31
- self[key] = yield(value.force_encoding(encoding))
32
- else
33
- self[key] = value.force_encoding(encoding)
34
- end
35
- when Hash then value.force_encoding!(encoding, &block)
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
@@ -1,3 +1,3 @@
1
1
  module Footing
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: footing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins