collapsium 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3922ea4f400facdd0a8319d6ea4993a5cb64dc54
4
- data.tar.gz: a94ad0feef4ca8399de6c9c65b8037238f26a752
3
+ metadata.gz: 63b5ae2bec3820d536814099c538f53f32ce3d14
4
+ data.tar.gz: d18f3d4bd528f98cf7b92a31a94da97211efb5d2
5
5
  SHA512:
6
- metadata.gz: 2a6d221e5658ff884cbda2078d52eb39a2cf5d3d9167859e43556c4f138ec4b1cc4463b303008c113315325dbdeea0369615e0219be19c4a923e8838183e2f53
7
- data.tar.gz: f6a5238d75f3a44572fa0e45339c31261e65560eb852edeb929698595720b1115f781192b13305a1c2cbcf2681505a4bd0cde91f52a33e0047289d71863aa7d3
6
+ metadata.gz: 1bc5ee36f8b47a7a7e1acffa6d80ef1d4dc400e4459418542e7dfaf99fed4d9fb76493ade6e37f5b50faecaad99a6c641ec7f6f78ece791f225269750ba4e16a
7
+ data.tar.gz: 7c5dc2d3f39681cfb909bc4259ca577707c90884e8bd3a80819ad5b84e79689d57fb1850856b25cf7bc18245a350f24b1037d324ce13e3ea63a090fbef848088
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- collapsium (0.6.0)
4
+ collapsium (0.6.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -41,6 +41,8 @@ that is ActiveSupport...
41
41
  recursively.
42
42
  - The `RecursiveSort` module provides a `#recursive_sort` function which sorts
43
43
  recursively.
44
+ - The `RecursiveFetch` module provides `#recursve_fetch` and `#recursive_fetch_one`
45
+ which searches recursively for all/the first ocurrence(s) of a key respectively.
44
46
  - The `PathedAccess` module provides a pathed access method to nested Hashes:
45
47
 
46
48
  ```ruby
@@ -91,7 +91,7 @@ module Collapsium
91
91
 
92
92
  # Array methods we're modifying here are indexed, so the first argument
93
93
  # must be an integer. Let's make it so :)
94
- if leaf.is_a? Array
94
+ if leaf.is_a? Array and the_args[0][0] =~ /[0-9]/
95
95
  the_args[0] = the_args[0].to_i
96
96
  end
97
97
 
@@ -27,13 +27,20 @@ module Collapsium
27
27
  # the match value passed to the block.
28
28
  def recursive_fetch_one(key, default = nil, &block)
29
29
  # Start simple at the top level.
30
- result = fetch(key, default)
31
- if result != default
32
- if not block.nil?
33
- result = yield self, result, default
30
+ # rubocop:disable Lint/HandleExceptions
31
+ begin
32
+ result = fetch(key, default)
33
+ if result != default
34
+ if not block.nil?
35
+ result = yield self, result, default
36
+ end
37
+ return result
34
38
  end
35
- return result
39
+ rescue TypeError
40
+ # Happens if self is an Array and key is a String that cannot
41
+ # be converted to Integer.
36
42
  end
43
+ # rubocop:enable Lint/HandleExceptions
37
44
 
38
45
  # We have to recurse for nested values
39
46
  result = map do |_, v|
@@ -60,13 +67,20 @@ module Collapsium
60
67
  result = []
61
68
 
62
69
  # Start simple at the top level.
63
- ret = fetch(key, default)
64
- if ret != default
65
- if not block.nil?
66
- ret = yield self, ret, default
70
+ # rubocop:disable Lint/HandleExceptions
71
+ begin
72
+ ret = fetch(key, default)
73
+ if ret != default
74
+ if not block.nil?
75
+ ret = yield self, ret, default
76
+ end
77
+ result << ret
67
78
  end
68
- result << ret
79
+ rescue TypeError
80
+ # Happens if self is an Array and key is a String that cannot
81
+ # be converted to Integer.
69
82
  end
83
+ # rubocop:enable Lint/HandleExceptions
70
84
 
71
85
  # We have to recurse for nested values
72
86
  result += map do |_, v|
@@ -8,5 +8,5 @@
8
8
  #
9
9
  module Collapsium
10
10
  # The current release version
11
- VERSION = "0.6.0".freeze
11
+ VERSION = "0.6.1".freeze
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collapsium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Finkhaeuser