refinements 11.1.0 → 11.1.2
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +43 -41
- data/lib/refinements/hashes.rb +1 -1
- data/refinements.gemspec +2 -2
- data.tar.gz.sig +0 -0
- metadata +7 -4
- 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: 02bd14a370832aff2b0039fe6afbddb3ebc5923aec4c28aa6050e62b48419fec
|
4
|
+
data.tar.gz: c7325e8468e03f988b1c819ee5c2879240b41b8647e4d1643ad9cf625e30f066
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f651e24e9a314db8f298ddf697feb34b7124b4c53ecd6534cdb3958314223aeeb19b4ef126457f409e0d82f586b39786cb0c1d90ff542099bfb2d63a7a8b1ff
|
7
|
+
data.tar.gz: 02d0648d45f362afe1a4abc1d4b8b0f66a5ea3e5eedf66150ef6ea9ea383a70a3bfc454da292630d454714cb4f4dc668b772c7827f14836f2a59a9e638fc09f1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -187,9 +187,9 @@ Answers the first element which evaluates to true from a filtered collection.
|
|
187
187
|
[source,ruby]
|
188
188
|
----
|
189
189
|
handlers = [
|
190
|
-
->
|
190
|
+
-> object { object if object == :b },
|
191
191
|
proc { false },
|
192
|
-
->
|
192
|
+
-> object { object if object == :a }
|
193
193
|
]
|
194
194
|
|
195
195
|
handlers.filter_find # Enumerator::Lazy
|
@@ -209,7 +209,7 @@ Adds given array or elements without mutating itself.
|
|
209
209
|
|
210
210
|
===== #intersperse
|
211
211
|
|
212
|
-
Inserts additional elements or an array between all members of given array.
|
212
|
+
Inserts additional elements, or an array, between all members of given array.
|
213
213
|
|
214
214
|
[source,ruby]
|
215
215
|
----
|
@@ -237,11 +237,13 @@ Answers the maximum extracted value from a collection of objects.
|
|
237
237
|
|
238
238
|
[source,ruby]
|
239
239
|
----
|
240
|
-
Point =
|
240
|
+
Point = Data.define :x, :y
|
241
241
|
points = [Point[x: 1, y: 2], Point[x: 0, y: 1], Point[x: 2, y: 3]]
|
242
242
|
|
243
|
-
points.maximum
|
244
|
-
points.maximum
|
243
|
+
points.maximum :x # 2
|
244
|
+
points.maximum :y # 3
|
245
|
+
points.maximum :z # undefined method `z' for #<data Point x=1, y=2> (NoMethodError)
|
246
|
+
[].maximum :x # nil
|
245
247
|
----
|
246
248
|
|
247
249
|
===== #mean
|
@@ -262,11 +264,13 @@ Answers the minimum extracted value from a collection of objects.
|
|
262
264
|
|
263
265
|
[source,ruby]
|
264
266
|
----
|
265
|
-
Point =
|
267
|
+
Point = Data.define :x, :y
|
266
268
|
points = [Point[x: 1, y: 2], Point[x: 0, y: 1], Point[x: 2, y: 3]]
|
267
269
|
|
268
|
-
points.minimum
|
269
|
-
points.minimum
|
270
|
+
points.minimum :x # 0
|
271
|
+
points.minimum :y # 1
|
272
|
+
points.minimum :z # undefined method `z' for #<data Point x=1, y=2> (NoMethodError)
|
273
|
+
[].minimum :x # nil
|
270
274
|
----
|
271
275
|
|
272
276
|
===== #pad
|
@@ -292,7 +296,7 @@ array = [{name: "a", label: "A"}, {name: "b", label: "B"}, {name: "c", label: "C
|
|
292
296
|
array.pick :name # "a"
|
293
297
|
array.pick :name, :label # ["a", "A"]
|
294
298
|
array.pick # nil
|
295
|
-
[].pick
|
299
|
+
[].pick :other # nil
|
296
300
|
----
|
297
301
|
|
298
302
|
===== #pluck
|
@@ -315,10 +319,10 @@ Answers mutated array where an element -- at a specific index -- is replaced by
|
|
315
319
|
|
316
320
|
[source,ruby]
|
317
321
|
----
|
318
|
-
%i[a b c].replace_at
|
319
|
-
%i[a b c].replace_at
|
320
|
-
%i[a b c].replace_at
|
321
|
-
%i[a b c].replace_at
|
322
|
+
%i[a b c].replace_at 0, :x # [:x, :b, :c]
|
323
|
+
%i[a b c].replace_at 1, :x # [:a, :x, :c]
|
324
|
+
%i[a b c].replace_at 1, :x, :y # [:a, :x, :y, :c]
|
325
|
+
%i[a b c].replace_at -1, :x # [:a, :b, :x]
|
322
326
|
----
|
323
327
|
|
324
328
|
===== #ring
|
@@ -796,12 +800,12 @@ Answers full stream by rewinding to beginning of stream and reading all content.
|
|
796
800
|
io = IO.new IO.sysopen(Pathname("demo.txt").to_s, "w+")
|
797
801
|
io.write "This is a demo."
|
798
802
|
|
799
|
-
io.reread
|
800
|
-
io.reread 4
|
803
|
+
io.reread # "This is a demo."
|
804
|
+
io.reread 4 # "This"
|
801
805
|
|
802
806
|
buffer = "".dup
|
803
|
-
io.reread(buffer:
|
804
|
-
buffer
|
807
|
+
io.reread(buffer:) # "This is a demo."
|
808
|
+
buffer # "This is a demo."
|
805
809
|
----
|
806
810
|
|
807
811
|
===== #squelch
|
@@ -829,17 +833,17 @@ Answers previously written content by rewinding to beginning of device.
|
|
829
833
|
# With File.
|
830
834
|
device = Logger::LogDevice.new "test.log"
|
831
835
|
device.write "Test."
|
832
|
-
device.reread
|
836
|
+
device.reread # "Test."
|
833
837
|
|
834
838
|
# With StringIO.
|
835
839
|
device = Logger::LogDevice.new StringIO.new
|
836
840
|
device.write "Test."
|
837
|
-
device.reread
|
841
|
+
device.reread # "Test."
|
838
842
|
|
839
843
|
# With STDOUT.
|
840
844
|
device = Logger::LogDevice.new $stdout
|
841
845
|
device.write "Test."
|
842
|
-
device.reread
|
846
|
+
device.reread # ""
|
843
847
|
----
|
844
848
|
|
845
849
|
==== Logger
|
@@ -853,17 +857,17 @@ Answers previously written content by rewinding to beginning of log.
|
|
853
857
|
# With File.
|
854
858
|
logger = Logger.new "test.log"
|
855
859
|
logger.write "Test."
|
856
|
-
logger.reread
|
860
|
+
logger.reread # "Test."
|
857
861
|
|
858
862
|
# With StringIO.
|
859
863
|
logger = Logger.new StringIO.new
|
860
864
|
logger.write "Test."
|
861
|
-
logger.reread
|
865
|
+
logger.reread # "Test."
|
862
866
|
|
863
867
|
# With STDOUT.
|
864
868
|
logger = Logger.new $stdout
|
865
869
|
logger.write "Test."
|
866
|
-
logger.reread
|
870
|
+
logger.reread # ""
|
867
871
|
----
|
868
872
|
|
869
873
|
===== #any
|
@@ -891,7 +895,7 @@ construct a valid path.
|
|
891
895
|
|
892
896
|
[source,ruby]
|
893
897
|
----
|
894
|
-
Pathname
|
898
|
+
Pathname nil # Pathname("")
|
895
899
|
----
|
896
900
|
|
897
901
|
===== .home
|
@@ -1017,9 +1021,9 @@ Deletes a path prefix and answers new pathname.
|
|
1017
1021
|
|
1018
1022
|
[source,ruby]
|
1019
1023
|
----
|
1020
|
-
Pathname("a/path/example-test.rb").delete_prefix
|
1021
|
-
Pathname("example-test.rb").delete_prefix
|
1022
|
-
Pathname("example-test.rb").delete_prefix
|
1024
|
+
Pathname("a/path/example-test.rb").delete_prefix "example-" # Pathname("a/path/test.rb")
|
1025
|
+
Pathname("example-test.rb").delete_prefix "example-" # Pathname("test.rb")
|
1026
|
+
Pathname("example-test.rb").delete_prefix "miss" # Pathname("example-test.rb")
|
1023
1027
|
----
|
1024
1028
|
|
1025
1029
|
===== #delete_suffix
|
@@ -1028,9 +1032,9 @@ Deletes a path suffix and answers new pathname.
|
|
1028
1032
|
|
1029
1033
|
[source,ruby]
|
1030
1034
|
----
|
1031
|
-
Pathname("a/path/test-example.rb").delete_suffix
|
1032
|
-
Pathname("test-example.rb").delete_suffix
|
1033
|
-
Pathname("test-example.rb").delete_suffix
|
1035
|
+
Pathname("a/path/test-example.rb").delete_suffix "-example" # Pathname("a/path/test.rb")
|
1036
|
+
Pathname("test-example.rb").delete_suffix "-example" # Pathname("test.rb")
|
1037
|
+
Pathname("test-example.rb").delete_suffix "miss" # Pathname("test-example.rb")
|
1034
1038
|
----
|
1035
1039
|
|
1036
1040
|
===== #directories
|
@@ -1084,10 +1088,10 @@ Same behavior as `String#gsub` but answers a path with patterns replaced with de
|
|
1084
1088
|
|
1085
1089
|
[source,ruby]
|
1086
1090
|
----
|
1087
|
-
Pathname("/a/path/some/path").gsub
|
1091
|
+
Pathname("/a/path/some/path").gsub "path", "test"
|
1088
1092
|
# Pathname("/a/test/some/test")
|
1089
1093
|
|
1090
|
-
Pathname("/%placeholder%/some/%placeholder%").gsub
|
1094
|
+
Pathname("/%placeholder%/some/%placeholder%").gsub "%placeholder%", "test"
|
1091
1095
|
# Pathname("/test/some/test")
|
1092
1096
|
----
|
1093
1097
|
|
@@ -1135,11 +1139,11 @@ Pathname("example.txt").name # Pathname("example")
|
|
1135
1139
|
|
1136
1140
|
===== #relative_parent
|
1137
1141
|
|
1138
|
-
Answers relative path from parent directory. This
|
1142
|
+
Answers relative path from parent directory. This complements: `#relative_path_from`.
|
1139
1143
|
|
1140
1144
|
[source,ruby]
|
1141
1145
|
----
|
1142
|
-
Pathname("/one/two/three").relative_parent
|
1146
|
+
Pathname("/one/two/three").relative_parent "/one" # Pathname "two"
|
1143
1147
|
----
|
1144
1148
|
|
1145
1149
|
===== #remove_dir
|
@@ -1378,8 +1382,8 @@ io.reread # "This is a test."
|
|
1378
1382
|
io.reread 4 # "This"
|
1379
1383
|
|
1380
1384
|
buffer = "".dup
|
1381
|
-
io.reread(buffer:
|
1382
|
-
buffer
|
1385
|
+
io.reread(buffer:) # "This is a test."
|
1386
|
+
buffer # "This is a test."
|
1383
1387
|
----
|
1384
1388
|
|
1385
1389
|
==== Struct
|
@@ -1458,8 +1462,7 @@ example # #<struct Struct::Example a=10, b=20, c=30>
|
|
1458
1462
|
|
1459
1463
|
Transforms values without mutating itself. An optional hash can be supplied to target specific
|
1460
1464
|
attributes. In the event that a block isn't supplied, the struct will answer itself since there is
|
1461
|
-
nothing to operate on.
|
1462
|
-
positional or keyword arguments. Works regardless of whether the struct is constructed with
|
1465
|
+
nothing to operate on. Works regardless of whether the struct is constructed with
|
1463
1466
|
positional or keyword arguments.
|
1464
1467
|
|
1465
1468
|
[source,ruby]
|
@@ -1477,8 +1480,7 @@ example # #<struct Str
|
|
1477
1480
|
|
1478
1481
|
Transforms values while mutating itself. An optional hash can be supplied to target specific
|
1479
1482
|
attributes. In the event that a block isn't supplied, the struct will answer itself since there is
|
1480
|
-
nothing to operate on.
|
1481
|
-
positional or keyword arguments. Works regardless of whether the struct is constructed with
|
1483
|
+
nothing to operate on. Works regardless of whether the struct is constructed with
|
1482
1484
|
positional or keyword arguments.
|
1483
1485
|
|
1484
1486
|
[source,ruby]
|
data/lib/refinements/hashes.rb
CHANGED
@@ -51,7 +51,7 @@ module Refinements
|
|
51
51
|
each.with_object({}) { |(key, value), diff| diff[key] = [value, nil] }
|
52
52
|
end
|
53
53
|
|
54
|
-
def fetch_value(key, *
|
54
|
+
def fetch_value(key, *default, &) = fetch(key, *default, &) || default.first
|
55
55
|
|
56
56
|
def flatten_keys prefix: nil, delimiter: "_"
|
57
57
|
reduce({}) do |accumulator, (key, value)|
|
data/refinements.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "refinements"
|
5
|
-
spec.version = "11.1.
|
5
|
+
spec.version = "11.1.2"
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
8
8
|
spec.homepage = "https://alchemists.io/projects/refinements"
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.signing_key = Gem.default_key_path
|
23
23
|
spec.cert_chain = [Gem.default_cert_path]
|
24
24
|
|
25
|
-
spec.required_ruby_version = "
|
25
|
+
spec.required_ruby_version = [">= 3.2", "<= 3.3"]
|
26
26
|
|
27
27
|
spec.files = Dir["*.gemspec", "lib/**/*"]
|
28
28
|
spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
|
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: 11.1.
|
4
|
+
version: 11.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
36
|
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2023-
|
38
|
+
date: 2023-11-16 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description:
|
41
41
|
email:
|
@@ -83,16 +83,19 @@ require_paths:
|
|
83
83
|
- lib
|
84
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- - "
|
86
|
+
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '3.2'
|
89
|
+
- - "<="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '3.3'
|
89
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
93
|
requirements:
|
91
94
|
- - ">="
|
92
95
|
- !ruby/object:Gem::Version
|
93
96
|
version: '0'
|
94
97
|
requirements: []
|
95
|
-
rubygems_version: 3.4.
|
98
|
+
rubygems_version: 3.4.22
|
96
99
|
signing_key:
|
97
100
|
specification_version: 4
|
98
101
|
summary: A collection of core Ruby object refinements.
|
metadata.gz.sig
CHANGED
Binary file
|