lite-ruby 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +14 -14
- data/docs/HASH.md +18 -5
- data/docs/TIME.md +1 -1
- data/lib/lite/ruby/hash.rb +4 -0
- data/lib/lite/ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5259c7027cc54284ebcdc00f0ae5c2624f6e4832b076802b8c5997ebf3d541e1
|
4
|
+
data.tar.gz: 46442407a045d0ea2b33b0b8875a2c68d116467bfec13ff5885ae4fabe2199f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afb85e87add0403b552c6be760f68a7b1bc0a4b893e8474f5779266d3c3743b2c6164dcf4cf7d71071a03584ccfc5d4bee3c30bbdcc0e44728b600f462721a71
|
7
|
+
data.tar.gz: '098b205a552cb43ea81cef034321119b2452853cac7a42a602e0aa6971c62f18144ed527ab8131333bf46a658c5946cf38ac801049a779065026ccf0551ecfd4'
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.2.0] - 2022-02-17
|
10
|
+
### Added
|
11
|
+
- Added Hash => `deep_fetch`
|
12
|
+
|
9
13
|
## [2.1.0] - 2022-02-09
|
10
14
|
### Added
|
11
15
|
- Added String `domain` to include protocol (more inline with URI method names) [BREAKING]
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lite-ruby (2.
|
4
|
+
lite-ruby (2.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
actionpack (7.0.2)
|
10
|
-
actionview (= 7.0.2)
|
11
|
-
activesupport (= 7.0.2)
|
9
|
+
actionpack (7.0.2.2)
|
10
|
+
actionview (= 7.0.2.2)
|
11
|
+
activesupport (= 7.0.2.2)
|
12
12
|
rack (~> 2.0, >= 2.2.0)
|
13
13
|
rack-test (>= 0.6.3)
|
14
14
|
rails-dom-testing (~> 2.0)
|
15
15
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
16
|
-
actionview (7.0.2)
|
17
|
-
activesupport (= 7.0.2)
|
16
|
+
actionview (7.0.2.2)
|
17
|
+
activesupport (= 7.0.2.2)
|
18
18
|
builder (~> 3.1)
|
19
19
|
erubi (~> 1.4)
|
20
20
|
rails-dom-testing (~> 2.0)
|
21
21
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
22
|
-
activesupport (7.0.2)
|
22
|
+
activesupport (7.0.2.2)
|
23
23
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
24
24
|
i18n (>= 1.6, < 2)
|
25
25
|
minitest (>= 5.1)
|
@@ -37,9 +37,9 @@ GEM
|
|
37
37
|
generator_spec (0.9.4)
|
38
38
|
activesupport (>= 3.0.0)
|
39
39
|
railties (>= 3.0.0)
|
40
|
-
i18n (1.
|
40
|
+
i18n (1.10.0)
|
41
41
|
concurrent-ruby (~> 1.0)
|
42
|
-
loofah (2.
|
42
|
+
loofah (2.14.0)
|
43
43
|
crass (~> 1.0.2)
|
44
44
|
nokogiri (>= 1.5.9)
|
45
45
|
method_source (1.0.0)
|
@@ -60,16 +60,16 @@ GEM
|
|
60
60
|
nokogiri (>= 1.6)
|
61
61
|
rails-html-sanitizer (1.4.2)
|
62
62
|
loofah (~> 2.3)
|
63
|
-
railties (7.0.2)
|
64
|
-
actionpack (= 7.0.2)
|
65
|
-
activesupport (= 7.0.2)
|
63
|
+
railties (7.0.2.2)
|
64
|
+
actionpack (= 7.0.2.2)
|
65
|
+
activesupport (= 7.0.2.2)
|
66
66
|
method_source
|
67
67
|
rake (>= 12.2)
|
68
68
|
thor (~> 1.0)
|
69
69
|
zeitwerk (~> 2.5)
|
70
70
|
rainbow (3.1.1)
|
71
71
|
rake (13.0.6)
|
72
|
-
regexp_parser (2.2.
|
72
|
+
regexp_parser (2.2.1)
|
73
73
|
rexml (3.2.5)
|
74
74
|
rspec (3.11.0)
|
75
75
|
rspec-core (~> 3.11.0)
|
@@ -93,7 +93,7 @@ GEM
|
|
93
93
|
rubocop-ast (>= 1.15.1, < 2.0)
|
94
94
|
ruby-progressbar (~> 1.7)
|
95
95
|
unicode-display_width (>= 1.4.0, < 3.0)
|
96
|
-
rubocop-ast (1.15.
|
96
|
+
rubocop-ast (1.15.2)
|
97
97
|
parser (>= 3.0.1.1)
|
98
98
|
rubocop-performance (1.13.2)
|
99
99
|
rubocop (>= 1.7.0, < 2.0)
|
data/docs/HASH.md
CHANGED
@@ -149,18 +149,20 @@ h1 = { a: [1], b: [1, 2], c: 3, d: [] }
|
|
149
149
|
h1.dearray_singular_values #=> { a: 1, b: [1, 2], c: 3, d: nil }
|
150
150
|
```
|
151
151
|
|
152
|
-
`
|
152
|
+
`deep_fetch`
|
153
153
|
------
|
154
|
-
Returns a
|
154
|
+
Returns a nested value if found or raises an error similar to `fetch`.
|
155
155
|
|
156
156
|
```ruby
|
157
157
|
h1 = { a: true, b: { c: [1, 2, 3] } }
|
158
|
-
h2 = { a: false, b: { x: [3, 4, 5] } }
|
159
158
|
|
160
|
-
h1.
|
159
|
+
h1.deep_fetch(:a) #=> true
|
160
|
+
h1.deep_fetch(:b, :c) #=> [1, 2, 3]
|
161
|
+
h1.deep_fetch(:b, :y) #=> raises KeyError
|
162
|
+
h1.deep_fetch(:b, :y) { nil } #=> nil
|
161
163
|
```
|
162
164
|
|
163
|
-
`deep_key
|
165
|
+
`deep_key?`
|
164
166
|
------
|
165
167
|
Returns if a set of nested keys exists.
|
166
168
|
|
@@ -173,6 +175,17 @@ h1.deep_key?(:x) #=> false
|
|
173
175
|
h1.deep_key?(:a, :c, :x) #=> false
|
174
176
|
```
|
175
177
|
|
178
|
+
`deep_merge(!)`
|
179
|
+
------
|
180
|
+
Returns a new hash with self and other_hash merged recursively.
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
h1 = { a: true, b: { c: [1, 2, 3] } }
|
184
|
+
h2 = { a: false, b: { x: [3, 4, 5] } }
|
185
|
+
|
186
|
+
h1.deep_merge(h2) #=> { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
|
187
|
+
```
|
188
|
+
|
176
189
|
`delete_unless`
|
177
190
|
------
|
178
191
|
Inverse of `delete_if`.
|
data/docs/TIME.md
CHANGED
@@ -112,7 +112,7 @@ Converts a `time` object to a predefined format.
|
|
112
112
|
| Combo | Day 12h datetime | `:day_datetime12` | %B %-d, %Y %H:%M | Sunday, January 9, 2014 12:31 am |
|
113
113
|
| Combo | Day 12h datetime | `:day_datetime12_abbr` | %b %-d, %Y %H:%M | Sun, Jan 9, 2014 12:31 am |
|
114
114
|
| Combo | Day 12h datetime | `:day_datetime12_iso` | %Y-%m-%d %H:%M | Sun, 2014-01-09 12:31 am |
|
115
|
-
| Combo | Day 12h datetime | `:day_datetime12_tzn` | %B %-d, %Y %H:%M %Z |
|
115
|
+
| Combo | Day 12h datetime | `:day_datetime12_tzn` | %B %-d, %Y %H:%M %Z | Sunday, January 9, 2014 12:31 am UTC |
|
116
116
|
| Combo | Day 12h datetime | `:day_datetime12_abbr_tzn` | %b %-d, %Y %H:%M %Z | Sun, Jan 9, 2014 12:31 am UTC |
|
117
117
|
| Combo | Day 12h datetime | `:day_datetime12_iso_tzn` | %Y-%m-%d %H:%M %z | Sun, 2014-01-09 12:31 am +0000 |
|
118
118
|
|
data/lib/lite/ruby/hash.rb
CHANGED
@@ -160,6 +160,10 @@ class Hash
|
|
160
160
|
replace(dearray_singular_values)
|
161
161
|
end
|
162
162
|
|
163
|
+
def deep_fetch(*keys, &block)
|
164
|
+
keys.reduce(self) { |hash_object, key| hash_object.fetch(key, &block) }
|
165
|
+
end
|
166
|
+
|
163
167
|
def deep_key?(*keys)
|
164
168
|
last_hash = self
|
165
169
|
found_key = false
|
data/lib/lite/ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lite-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|