refinements 7.5.0 → 7.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.adoc +12 -1
- data/lib/refinements/hashes.rb +10 -0
- data/lib/refinements/identity.rb +1 -1
- metadata +7 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b33464363d548d0cc888f7f3b1efac924eb2490a3846353589d892900d03de0d
|
4
|
+
data.tar.gz: da1d401505c092c0b2e8850f476affb1932b79db770b4f11c263300e208f3457
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c8072c3a3d8348e871ed72c7519295fb4ade95e2463bf56424f42689909dc7113805fbc817012196a395442af811f4d215a5bc89cf8952bd4506b0a4cd49536
|
7
|
+
data.tar.gz: 7797a5f506eb95d5999234c6e506ef9b0f4b949cfa41f831fcf883425fea7cb3da3b3ff3ef72f5c218236c006c38aeb2a957127ccf5177748fc3cac4291498ba
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -27,6 +27,8 @@ toc::[]
|
|
27
27
|
** `#rewrite` - When given a file path and a block, it provides the contents of the recently read
|
28
28
|
file for manipulation and immediate writing back to the same file.
|
29
29
|
* *Hashes*:
|
30
|
+
** `.infinite` - Answers new hash where missing keys, even deeply nested, answer an empty hash.
|
31
|
+
** `.with_default` - Answers new hash where every top-level missing key has the same default value.
|
30
32
|
** `#except` - Answers new hash with given keys removed without modifying itself.
|
31
33
|
** `#except!` - Answers new hash with given keys removed while modifying itself.
|
32
34
|
** `#symbolize_keys` - Converts keys to symbols without modifying itself.
|
@@ -70,7 +72,7 @@ manipulation and immediate writing back to the same file.
|
|
70
72
|
|
71
73
|
== Requirements
|
72
74
|
|
73
|
-
. https://www.ruby-lang.org[Ruby
|
75
|
+
. https://www.ruby-lang.org[Ruby].
|
74
76
|
. A solid understanding of link:https://www.alchemists.io/articles/ruby_refinements[Ruby refinements
|
75
77
|
and lexical scope].
|
76
78
|
|
@@ -200,6 +202,15 @@ File.rewrite("/test.txt") { |content| content.gsub "[placeholder]", "example" }
|
|
200
202
|
|
201
203
|
[source,ruby]
|
202
204
|
----
|
205
|
+
example = Hash.infinite
|
206
|
+
example[:a] # => {}
|
207
|
+
example[:a][:b][:c] # => {}
|
208
|
+
|
209
|
+
example = Hash.with_default ""
|
210
|
+
example[:a] # => ""
|
211
|
+
example = Hash.with_default []
|
212
|
+
example[:b] # => []
|
213
|
+
|
203
214
|
example = {a: 1, b: 2, c: 3}
|
204
215
|
example.except :a, :b # => {c: 3}
|
205
216
|
example # => {a: 1, b: 2, c: 3}
|
data/lib/refinements/hashes.rb
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
module Refinements
|
4
4
|
module Hashes
|
5
|
+
refine Hash.singleton_class do
|
6
|
+
def infinite
|
7
|
+
new { |new_hash, missing_key| new_hash[missing_key] = new(&new_hash.default_proc) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def with_default value
|
11
|
+
new { |new_hash, missing_key| new_hash[missing_key] = value }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
refine Hash do
|
6
16
|
def except *keys
|
7
17
|
reject { |key, _value| keys.include? key }
|
data/lib/refinements/identity.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
28
28
|
2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
|
29
29
|
QWc=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2020-
|
31
|
+
date: 2020-07-04 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler-audit
|
@@ -50,28 +50,28 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '14.
|
53
|
+
version: '14.2'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '14.
|
60
|
+
version: '14.2'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name: git-
|
62
|
+
name: git-lint
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '1.0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '1.0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: guard-rspec
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|