refinements 12.9.0 → 12.11.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 +36 -2
- data/lib/refinements/array.rb +6 -1
- data/lib/refinements/module.rb +12 -0
- data/lib/refinements/struct.rb +6 -1
- data/lib/refinements.rb +1 -0
- data/refinements.gemspec +1 -1
- data.tar.gz.sig +0 -0
- metadata +4 -3
- metadata.gz.sig +1 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d69e0e63ab3517d24dcd3bdce7e3e431e01b8d650c8cf2dab0d61eaa3cb062e1
|
4
|
+
data.tar.gz: 55f9613cf283a4423fb22008fa8e686d7a2d2c4d9a8d387c64fd1040e850feea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d98d59c37417c339097cfceda519c0099a7e4b63ef28966c769865cd64d2a174c60fc5d7f92f602e09c7dd001fd6e1cba6bc24f08bc5c8ace90b1d3e3d395ce
|
7
|
+
data.tar.gz: 0a8c378c45fa6a4a20f05a1bfa1786a5840761648b1e9c1f8114e9a837a3398aeac35b47820743366ccf618e3288a863e3b4a290a637e2db3c72454294e6ffeb
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -20,6 +20,7 @@ Enhances the following objects:
|
|
20
20
|
* IO
|
21
21
|
* LogDevice
|
22
22
|
* Logger
|
23
|
+
* Module
|
23
24
|
* Object
|
24
25
|
* Pathname
|
25
26
|
* String
|
@@ -87,6 +88,7 @@ require "refinements/hash"
|
|
87
88
|
require "refinements/io"
|
88
89
|
require "refinements/log_device"
|
89
90
|
require "refinements/logger"
|
91
|
+
require "refinements/module"
|
90
92
|
require "refinements/object"
|
91
93
|
require "refinements/pathname"
|
92
94
|
require "refinements/string"
|
@@ -111,6 +113,7 @@ class Example
|
|
111
113
|
using Refinements::IO
|
112
114
|
using Refinements::LogDevice
|
113
115
|
using Refinements::Logger
|
116
|
+
using Refinements::Module
|
114
117
|
using Refinements::Object
|
115
118
|
using Refinements::Pathname
|
116
119
|
using Refinements::String
|
@@ -186,6 +189,8 @@ Removes given array or elements without mutating itself.
|
|
186
189
|
|
187
190
|
===== #filter_find
|
188
191
|
|
192
|
+
⚠️ _This is deprecated and will be removed in Version 13.0.0._
|
193
|
+
|
189
194
|
Answers the first element which evaluates to true from a filtered collection.
|
190
195
|
|
191
196
|
[source,ruby]
|
@@ -969,7 +974,8 @@ logger.reread # ""
|
|
969
974
|
|
970
975
|
Allows you to log _any_ message which is identical in behavior and functionality to the `Logger#unknown` method only this requires less typing and better matches the terminology used by the `#unknown` method.
|
971
976
|
|
972
|
-
|
977
|
+
[source,ruby]
|
978
|
+
----
|
973
979
|
logger = Logger.new STDOUT
|
974
980
|
|
975
981
|
logger.any "Test."
|
@@ -977,7 +983,33 @@ logger.any "Test."
|
|
977
983
|
|
978
984
|
logger.any { "Test." }
|
979
985
|
A, [2000-01-10T09:00:00.330719 #44925] ANY -- : Test.
|
980
|
-
|
986
|
+
----
|
987
|
+
|
988
|
+
==== Module
|
989
|
+
|
990
|
+
===== #pseudonym
|
991
|
+
|
992
|
+
Allows you to set a temporary name for your anonymous `Module` (or `Class` since `Class` inherits from `Module`) with a better default than what `+#set_temporary_name+` provides.
|
993
|
+
|
994
|
+
[source,ruby]
|
995
|
+
----
|
996
|
+
Module.new.pseudonym "demo" # demo-44600
|
997
|
+
Module.new.pseudonym "demo", delimiter: "_" # demo_60900
|
998
|
+
Module.new.pseudonym "demo", nil # demo-
|
999
|
+
Module.new.pseudonym "demo", nil, delimiter: nil # demo
|
1000
|
+
----
|
1001
|
+
|
1002
|
+
The same applies for anonymous classes since classes inherit from modules:
|
1003
|
+
|
1004
|
+
[source,ruby]
|
1005
|
+
----
|
1006
|
+
Class.new.pseudonym "demo" # demo-44600 < Object
|
1007
|
+
Class.new.pseudonym "demo", delimiter: "_" # demo_60900 < Object
|
1008
|
+
Class.new.pseudonym "demo", nil # demo- < Object
|
1009
|
+
Class.new.pseudonym "demo", nil, delimiter: nil # demo < Object
|
1010
|
+
----
|
1011
|
+
|
1012
|
+
💡 While convenient, if you find yourself nullifying the suffix and/or delimiter, you're better off using `+#set_temporary_name+`.
|
981
1013
|
|
982
1014
|
==== Object
|
983
1015
|
|
@@ -1598,6 +1630,8 @@ io.to_str # "One, Two."
|
|
1598
1630
|
|
1599
1631
|
===== .with_positions
|
1600
1632
|
|
1633
|
+
⚠️ _This is deprecated and will be removed in Version 13.0.0._
|
1634
|
+
|
1601
1635
|
Answers a struct instance with given positional arguments regardless of
|
1602
1636
|
whether the struct was constructed with positional or keyword arguments.
|
1603
1637
|
|
data/lib/refinements/array.rb
CHANGED
@@ -19,7 +19,12 @@ module Refinements
|
|
19
19
|
|
20
20
|
def excluding(*elements) = self - elements.flatten
|
21
21
|
|
22
|
-
def filter_find(&)
|
22
|
+
def filter_find(&)
|
23
|
+
warn "`#{self.class}##{__method__}` is deprecated and will be removed in Version 13.0.0.",
|
24
|
+
category: :deprecated
|
25
|
+
|
26
|
+
block_given? ? lazy.map(&).find(&:itself) : lazy
|
27
|
+
end
|
23
28
|
|
24
29
|
def including(*elements) = self + elements.flatten
|
25
30
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Refinements
|
4
|
+
# Provides additional enhancements to the Symbol primitive.
|
5
|
+
module Module
|
6
|
+
refine ::Module do
|
7
|
+
def pseudonym prefix, suffix = object_id, delimiter: "-"
|
8
|
+
set_temporary_name "#{prefix}#{delimiter}#{suffix}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/refinements/struct.rb
CHANGED
@@ -6,7 +6,12 @@ module Refinements
|
|
6
6
|
# Provides additional enhancements to the Struct primitive.
|
7
7
|
module Struct
|
8
8
|
refine ::Struct.singleton_class do
|
9
|
-
def with_positions(*values)
|
9
|
+
def with_positions(*values)
|
10
|
+
warn "`#{self.class}##{__method__}` is deprecated and will be removed in Version 13.0.0.",
|
11
|
+
category: :deprecated
|
12
|
+
|
13
|
+
keyword_init? ? new(**members.zip(values).to_h) : new(*values)
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
17
|
refine ::Struct do
|
data/lib/refinements.rb
CHANGED
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: 12.
|
4
|
+
version: 12.11.0
|
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: 2024-
|
38
|
+
date: 2024-11-09 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description:
|
41
41
|
email:
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/refinements/io.rb
|
58
58
|
- lib/refinements/log_device.rb
|
59
59
|
- lib/refinements/logger.rb
|
60
|
+
- lib/refinements/module.rb
|
60
61
|
- lib/refinements/object.rb
|
61
62
|
- lib/refinements/pathname.rb
|
62
63
|
- lib/refinements/shared/diff.rb
|
@@ -96,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
97
|
- !ruby/object:Gem::Version
|
97
98
|
version: '0'
|
98
99
|
requirements: []
|
99
|
-
rubygems_version: 3.5.
|
100
|
+
rubygems_version: 3.5.23
|
100
101
|
signing_key:
|
101
102
|
specification_version: 4
|
102
103
|
summary: A collection of core object refinements.
|
metadata.gz.sig
CHANGED
@@ -1,4 +1 @@
|
|
1
|
-
|
2
|
-
b��^�-�9��Pea�(�t��K�< ^�fI�'�F�D^�o� ���ϐNh�Di����]���πߢ� ��5Rr�H����DM��큸���jB��ӴҸU�ЅY���u+��_p@���
|
3
|
-
����+(�M8V��'d��� ɋ����>�ow�}xTHc'9��ׇg%��[��Yd2`�>h�i
|
4
|
-
-yE*���s1z�
|
1
|
+
AڦtPefp�j,��>�ӿhR��{ƅb�y׀,˯�;���4�hʥ$Nb�q�r��ܳ8y���%�%�0�鯴NNm�o>\[[>��A�?�G.A������< ?��O�&�y�%a3�F��)��uX�_��QȆ�E��ئgѡ$�*�R�K�v��_W��yy��������� R�7\sٗTrK<:����M�:���A�8T�5F�w�3g��4>��`J��URX)��6��WJ����[-�.q�h���Դr$�Sq+��{%�������".�:&a,X���{N�I���¸AV����R�lC��� ��5������&Y�M����e��T�a�C����ad�9������
|