refinements 11.1.0 → 11.1.1
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 +43 -41
- data/lib/refinements/hashes.rb +1 -1
- data/refinements.gemspec +1 -1
- 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: 91fae4e74017d86d0ca24e153dc7210fd9503276ccdf79da032e0f8f8ee2d181
|
4
|
+
data.tar.gz: eeea2c49941fe6508e9e4aab89aa42f38c2e23efd48b4f5381d4487a08061e3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08e77b3c0837d2158593f431a6cdd427cdc7cf9a1605178c0762444549b08807e3f3890cd7c578a8bc429d453b8961d38649a412b4616ea92889f745a721bc1f'
|
7
|
+
data.tar.gz: 20525ddb58f09cb45d4fc39fe652d0790b156f387bea40fe0f6574be0d396d8607cc6e9f692a6e6feee78f8608b102aaab5d9219ef6f4d43dcdd5e73e8ad4957
|
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
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.1
|
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-04 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description:
|
41
41
|
email:
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
rubygems_version: 3.4.
|
95
|
+
rubygems_version: 3.4.21
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: A collection of core Ruby object refinements.
|
metadata.gz.sig
CHANGED
Binary file
|