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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acd50ef5bb4db84f4db8c509c2deab9203e0e7c036e880d43ed047d540c961cf
4
- data.tar.gz: df6ebf181b200aeb38f14f3f691f844735e1e352741bc6e7cd667970c5b81b6a
3
+ metadata.gz: 82142460f83d84a2b94bf4a1e6c07b4c6839e91f2da64192e0c64a36382fe3e5
4
+ data.tar.gz: d657c64e946049d4c946513329446b781880c34c76301408318a8487e0728f17
5
5
  SHA512:
6
- metadata.gz: 53703faa9a8b2941e562561a1f9edf22920fdd3934e7d6b55ec3e4290ad18d3e6282e96733c658accf58d475e6f0f78a6687c4777cb7fe2bc49edfdb9707b17b
7
- data.tar.gz: 0ddb2f12bb1fcd7aefc06f6c9f2ce891c9929828a79162610824a8a5cf3ffa991d476118f9c5a106fb681c9603a6b8c1ba0dbeaf80004317c990b4673152f8ff
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
- Refinements are a collection primitive Ruby objects enhancements without needing to resort to hard
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[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 all refinements are not desired, add the following to your `+Gemfile+` instead:
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 there is nothing to remove.
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 there is nothing to remove.
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 key/value pairs based on specific operations where each operation (i.e. function that responds to the `call` message). Does not mutate itself.
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 will not be mutated:
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 key/value pairs based on specific operations where each operation (i.e. function that responds to the `call` message). Mutates itself.
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 will be mutated:
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
- Passes each hash value as a block argument for further processing.
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 indented by two spaces by default.
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:%{id} %{string}>", id: object_id, string: to_s("F"))
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
@@ -85,7 +85,7 @@ module Refinements
85
85
  return [] unless block
86
86
 
87
87
  block.parameters
88
- .map { |(_type, key)| self[key] }
88
+ .map { |(_type, key)| self[key] || self[key.to_s] }
89
89
  .then { |values| yield values }
90
90
  end
91
91
  end
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 = "10.1.0"
5
+ spec.version = "10.1.1"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/refinements"
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.0
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
- MIIEZDCCAsygAwIBAgIBATANBgkqhkiG9w0BAQsFADA8MQwwCgYDVQQDDAN5b3Ux
14
- FzAVBgoJkiaJk/IsZAEZFgdleGFtcGxlMRMwEQYKCZImiZPyLGQBGRYDY29tMB4X
15
- DTIzMDMyMjE1NTAzNloXDTI1MDMyMTE1NTAzNlowPDEMMAoGA1UEAwwDeW91MRcw
16
- FQYKCZImiZPyLGQBGRYHZXhhbXBsZTETMBEGCgmSJomT8ixkARkWA2NvbTCCAaIw
17
- DQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAMD1xmCyBRDIgMr9h+bXYgckAJwj
18
- EE8d49cWc4IgxXLEz7E/r3+DVWfbviErgQEjqZztso/5jormLpS2LC3VNjRXWdSN
19
- 3QoD51J3/OnAsW340sXTVvj5M9KD5ZkDo+QIoQO1Dp8QZKI5Ney8gTUxCj5857sX
20
- XqWm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MBaBFGJyb29rZUBhbGNoZW1pc3RzLmlvMB8GA1UdEgQY
28
+ MBaBFGJyb29rZUBhbGNoZW1pc3RzLmlvMA0GCSqGSIb3DQEBCwUAA4IBgQAX+EGY
29
+ 9RLYGxF1VLZz+G1ACQc4uyrCB6kXwI06kzUa5dF9tPXqTX9ffnz3/W8ck2IQhKzu
30
+ MKO2FVijzbDWTsZeZGglS4E+4Jxpau1lU9HhOIcKolv6LeC6UdALTFudY+GLb8Xw
31
+ REXgaJkjzzhkUSILmEnRwEbY08dVSl7ZAaxVI679vfI2yapLlIwpbBgmQTiTvPr3
32
+ qyyLUno9flYEOv9fmGHunSrM+gE0/0niGTXa5GgXBXYGS2he4LQGgSBfGp/cTwMU
33
+ 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-03-22 00:00:00.000000000 Z
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.9
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