refinements 10.1.0 → 10.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 +12 -21
- data/lib/refinements/big_decimals.rb +1 -1
- data/lib/refinements/hashes.rb +1 -1
- data/refinements.gemspec +1 -1
- data.tar.gz.sig +0 -0
- metadata +27 -27
- 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: 82142460f83d84a2b94bf4a1e6c07b4c6839e91f2da64192e0c64a36382fe3e5
|
4
|
+
data.tar.gz: d657c64e946049d4c946513329446b781880c34c76301408318a8487e0728f17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81df10e22a7fb65d5737e7a8c23114fdecd47bcdecf532bc231612d29cd9036a90444fd8d59b5d140ab7c72347a1bbbbc9dee9b1e8c3464962b146ad5dc82085
|
7
|
+
data.tar.gz: 4446cffdb57fe7383f891193a95edc8c0a023da2f6670fb13a00730be21113123a55f8f13ad9cf9fad39954af418142e5e17e8b6b00cac0fb815b5ed6592252d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -4,11 +4,7 @@
|
|
4
4
|
|
5
5
|
= Refinements
|
6
6
|
|
7
|
-
|
8
|
-
to debug link:https://alchemists.io/articles/ruby_antipatterns/#_monkey_patches[monkey patches].
|
9
|
-
These refinements give you additional syntactic sugar to develop clean and concise implementations
|
10
|
-
while using less code. By refining our code we can acquire the functionality we wish the core
|
11
|
-
primitives had!
|
7
|
+
These refinements augment and enhance Ruby primitives so you can avoid link:https://alchemists.io/articles/ruby_antipatterns/#_monkey_patches[monkey patches]. They also allow you to develop clean and concise implementations while using less code. By refining your code, you can acquire the functionality you wish the core primitives had!
|
12
8
|
|
13
9
|
toc::[]
|
14
10
|
|
@@ -31,8 +27,7 @@ Enhances the following objects:
|
|
31
27
|
== Requirements
|
32
28
|
|
33
29
|
. https://www.ruby-lang.org[Ruby].
|
34
|
-
. A solid understanding of link:https://alchemists.io/articles/ruby_refinements[
|
35
|
-
and lexical scope].
|
30
|
+
. A solid understanding of link:https://alchemists.io/articles/ruby_refinements[refinements].
|
36
31
|
|
37
32
|
== Setup
|
38
33
|
|
@@ -54,7 +49,7 @@ gem "refinements"
|
|
54
49
|
|
55
50
|
=== Requires
|
56
51
|
|
57
|
-
If
|
52
|
+
If no refinements are desired, then add the following to your `Gemfile` instead:
|
58
53
|
|
59
54
|
[source,ruby]
|
60
55
|
----
|
@@ -195,7 +190,7 @@ Adds given array or elements without mutating itself.
|
|
195
190
|
|
196
191
|
===== #intersperse
|
197
192
|
|
198
|
-
Inserts additional elements or array between all members of given array.
|
193
|
+
Inserts additional elements or an array between all members of given array.
|
199
194
|
|
200
195
|
[source,ruby]
|
201
196
|
----
|
@@ -371,7 +366,7 @@ example[:b] # []
|
|
371
366
|
|
372
367
|
===== #compress
|
373
368
|
|
374
|
-
Removes `nil` and empty objects without mutating itself. Answers itself if
|
369
|
+
Removes `nil` and empty objects without mutating itself. Answers itself if nothing to remove.
|
375
370
|
|
376
371
|
[source,ruby]
|
377
372
|
----
|
@@ -386,7 +381,7 @@ example # {a: 1, b: "blueberry", c: nil, d: "", e: [], f: {}, g:
|
|
386
381
|
|
387
382
|
===== #compress!
|
388
383
|
|
389
|
-
Removes `nil` and empty objects while mutating itself. Answers `nil` if
|
384
|
+
Removes `nil` and empty objects while mutating itself. Answers `nil` if nothing to remove.
|
390
385
|
|
391
386
|
[source,ruby]
|
392
387
|
----
|
@@ -584,9 +579,7 @@ example # {a: 1, b: 2}
|
|
584
579
|
|
585
580
|
===== #transform_with
|
586
581
|
|
587
|
-
Transforms
|
588
|
-
|
589
|
-
You can transform multiple values at once:
|
582
|
+
Transforms values of keys using specific operations (i.e. any object that responds to `#call`). Does not mutate itself and you can transform multiple values at once:
|
590
583
|
|
591
584
|
[source,ruby]
|
592
585
|
----
|
@@ -605,7 +598,7 @@ example.transform_with bogus: -> value { value.tr "<>", "" }
|
|
605
598
|
# {email: "<jd@example.com>"}
|
606
599
|
----
|
607
600
|
|
608
|
-
The original object
|
601
|
+
The original object _will not_ be mutated:
|
609
602
|
|
610
603
|
[source,ruby]
|
611
604
|
----
|
@@ -614,9 +607,7 @@ example # {name: "Jayne Doe", email: "<jd@example.com>"}
|
|
614
607
|
|
615
608
|
===== #transform_with!
|
616
609
|
|
617
|
-
Transforms
|
618
|
-
|
619
|
-
You can transform multiple values at once:
|
610
|
+
Transforms values of keys using specific operations (i.e. any object that responds to `#call`). Mutates itself and you can transform multiple values at once:
|
620
611
|
|
621
612
|
[source,ruby]
|
622
613
|
----
|
@@ -635,7 +626,7 @@ example.transform_with! bogus: -> value { value.tr "<>", "" }
|
|
635
626
|
# {email: "<jd@example.com>"}
|
636
627
|
----
|
637
628
|
|
638
|
-
The original object
|
629
|
+
The original object _will be_ mutated:
|
639
630
|
|
640
631
|
[source,ruby]
|
641
632
|
----
|
@@ -644,7 +635,7 @@ example # {name: "Jayne", email: "jd@example.com"}
|
|
644
635
|
|
645
636
|
===== #use
|
646
637
|
|
647
|
-
|
638
|
+
Uses the hash's keys as block arguments where the value of the block argument is equal to the value of the key found within the hash. Works best with hashes that use symbols for keys but falls back to string keys when symbol keys can't be found.
|
648
639
|
|
649
640
|
[source,ruby]
|
650
641
|
----
|
@@ -1147,7 +1138,7 @@ Answers first character of a string or first set of characters if given a number
|
|
1147
1138
|
|
1148
1139
|
===== #indent
|
1149
1140
|
|
1150
|
-
Answers string
|
1141
|
+
Answers indentation (string) which is the result of the multiplier times padding. By default, the multiplier is `1` and the padding is `" "` which equates to two spaces.
|
1151
1142
|
|
1152
1143
|
[source,ruby]
|
1153
1144
|
----
|
@@ -6,7 +6,7 @@ module Refinements
|
|
6
6
|
# Provides additional enhancements to the BigDecimal primitive.
|
7
7
|
module BigDecimals
|
8
8
|
refine BigDecimal do
|
9
|
-
def inspect = format("#<BigDecimal
|
9
|
+
def inspect = format("#<BigDecimal:%<id>s %<string>s>", id: object_id, string: to_s("F"))
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/lib/refinements/hashes.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: 10.1.
|
4
|
+
version: 10.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -10,32 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
13
|
+
MIIEeDCCAuCgAwIBAgIBATANBgkqhkiG9w0BAQsFADBBMQ8wDQYDVQQDDAZicm9v
|
14
|
+
a2UxGjAYBgoJkiaJk/IsZAEZFgphbGNoZW1pc3RzMRIwEAYKCZImiZPyLGQBGRYC
|
15
|
+
aW8wHhcNMjMwMzIyMTYxNDQxWhcNMjUwMzIxMTYxNDQxWjBBMQ8wDQYDVQQDDAZi
|
16
|
+
cm9va2UxGjAYBgoJkiaJk/IsZAEZFgphbGNoZW1pc3RzMRIwEAYKCZImiZPyLGQB
|
17
|
+
GRYCaW8wggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCro8tj5/E1Hg88
|
18
|
+
f4qfiwPVd2zJQHvdYt4GHVvuHRR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
+
rDKJRcusZ12lNBeDfgqACz/BBJF8FLodgk6rGMRZz7+ZmjjHEmpG5bQpR6Q2BuWL
|
34
|
+
XMtYk/QzaWuhiR7pWjiF8jbdd7RO6or0ohq7iFkokz/5xrtQ/vPzU2RQ3Qc6YaKw
|
35
|
+
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
|
+
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2023-
|
38
|
+
date: 2023-04-08 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description:
|
41
41
|
email:
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
rubygems_version: 3.4.
|
93
|
+
rubygems_version: 3.4.10
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: A collection of refinements to core Ruby objects.
|
metadata.gz.sig
CHANGED
Binary file
|