refinements 8.2.2 → 8.3.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/README.adoc +24 -0
- data/lib/refinements/arrays.rb +1 -0
- data/lib/refinements/big_decimals.rb +1 -0
- data/lib/refinements/date_times.rb +1 -0
- data/lib/refinements/hashes.rb +11 -4
- data/lib/refinements/identity.rb +1 -1
- data/lib/refinements/ios.rb +1 -0
- data/lib/refinements/pathnames.rb +1 -1
- data/lib/refinements/string_ios.rb +1 -0
- data/lib/refinements/strings.rb +3 -2
- data/lib/refinements/structs.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +3 -3
- 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: d389fcb07d681440a24f0b368c81a76948e15b71287a850e857f8e018fc973da
|
4
|
+
data.tar.gz: 3f7a815dbc49376aad77ab549e77bf9e607bec74ff136b537dfccc371649fe4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7269907e701c6917bb5c096af4bbf1650d03b8ffb752b56c37baa895e8eff649359246b79e0a19b3b790d6dde60711a06aeb0a37b3da0c080a64bbcc54e96bf
|
7
|
+
data.tar.gz: 5cbd5fd8f553c47fa5f77e4145c48af1ac3467927fb09aae8db48639a92c6000c255b75d66d90824474c7dbffd10ef19ee5581e3d5da83f4bb0526d0d8d1a2e1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -288,6 +288,30 @@ example = Hash.with_default []
|
|
288
288
|
example[:b] # => []
|
289
289
|
----
|
290
290
|
|
291
|
+
===== #compress
|
292
|
+
|
293
|
+
Removes empty objects without mutating itself.
|
294
|
+
|
295
|
+
[source,ruby]
|
296
|
+
----
|
297
|
+
object = Object.new
|
298
|
+
example = {a: 1, b: "blueberry", c: nil, d: "", e: [], f: {}, g: object}
|
299
|
+
example.compress # => {a: 1, b: "blueberry", g: object}
|
300
|
+
example # => {a: 1, b: "blueberry", c: nil, d: "", e: [], f: {}, g: object}
|
301
|
+
----
|
302
|
+
|
303
|
+
===== #compress!
|
304
|
+
|
305
|
+
Removes empty objects while mutating itself.
|
306
|
+
|
307
|
+
[source,ruby]
|
308
|
+
----
|
309
|
+
object = Object.new
|
310
|
+
example = {a: 1, b: "blueberry", c: nil, d: "", e: [], f: {}, g: object}
|
311
|
+
example.compress! # => {a: 1, b: "blueberry", g: object}
|
312
|
+
example # => {a: 1, b: "blueberry", g: object}
|
313
|
+
----
|
314
|
+
|
291
315
|
===== #deep_merge
|
292
316
|
|
293
317
|
Merges deeply nested hashes together without mutating itself.
|
data/lib/refinements/arrays.rb
CHANGED
data/lib/refinements/hashes.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Refinements
|
4
|
+
# Provides additional enhancements to the Hash primitive.
|
4
5
|
module Hashes
|
5
6
|
refine Hash.singleton_class do
|
6
7
|
def infinite
|
@@ -11,6 +12,12 @@ module Refinements
|
|
11
12
|
end
|
12
13
|
|
13
14
|
refine Hash do
|
15
|
+
def compress = dup.compress!
|
16
|
+
|
17
|
+
def compress!
|
18
|
+
compact!.delete_if { |_key, value| value.respond_to?(:empty?) && value.empty? }
|
19
|
+
end
|
20
|
+
|
14
21
|
def deep_merge other
|
15
22
|
clazz = self.class
|
16
23
|
|
@@ -62,13 +69,13 @@ module Refinements
|
|
62
69
|
end
|
63
70
|
end
|
64
71
|
|
65
|
-
def stringify_keys =
|
72
|
+
def stringify_keys = transform_keys(&:to_s)
|
66
73
|
|
67
|
-
def stringify_keys! =
|
74
|
+
def stringify_keys! = transform_keys!(&:to_s)
|
68
75
|
|
69
|
-
def symbolize_keys =
|
76
|
+
def symbolize_keys = transform_keys(&:to_sym)
|
70
77
|
|
71
|
-
def symbolize_keys! =
|
78
|
+
def symbolize_keys! = transform_keys!(&:to_sym)
|
72
79
|
|
73
80
|
def use &block
|
74
81
|
return [] unless block
|
data/lib/refinements/identity.rb
CHANGED
data/lib/refinements/ios.rb
CHANGED
data/lib/refinements/strings.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Refinements
|
4
|
+
# Provides additional enhancements to the String primitive.
|
4
5
|
module Strings
|
5
6
|
DELIMITERS = %r([a-z][A-Z]|\s*-\s*|\s*/\s*|\s*:+\s*|\s*_\s*|\s+)
|
6
7
|
|
7
8
|
refine String do
|
8
|
-
def blank? = match?(/\A
|
9
|
+
def blank? = empty? || match?(/\A[[:space:]]*\z/)
|
9
10
|
|
10
11
|
def camelcase
|
11
12
|
return up unless match? DELIMITERS
|
@@ -35,7 +36,7 @@ module Refinements
|
|
35
36
|
def indent multiplier = 1, padding: " "
|
36
37
|
return self if multiplier.negative?
|
37
38
|
|
38
|
-
padding * multiplier + self
|
39
|
+
(padding * multiplier) + self
|
39
40
|
end
|
40
41
|
|
41
42
|
def last number = 0
|
data/lib/refinements/structs.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
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: 8.
|
4
|
+
version: 8.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
28
28
|
lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
|
29
29
|
W2A=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2021-09-
|
31
|
+
date: 2021-09-26 00:00:00.000000000 Z
|
32
32
|
dependencies: []
|
33
33
|
description:
|
34
34
|
email:
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
rubygems_version: 3.2.
|
78
|
+
rubygems_version: 3.2.28
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: A collection of refinements to core Ruby objects.
|
metadata.gz.sig
CHANGED
Binary file
|