refinements 10.0.1 → 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: 689d81be17018cdf3ef2e6b0ac907a15c336428a1ce38cfefada918cf40ea099
4
- data.tar.gz: 430b2746c975b947c263d1eafcda9ebb6687286e233e79dc12208d33b5a36c57
3
+ metadata.gz: 82142460f83d84a2b94bf4a1e6c07b4c6839e91f2da64192e0c64a36382fe3e5
4
+ data.tar.gz: d657c64e946049d4c946513329446b781880c34c76301408318a8487e0728f17
5
5
  SHA512:
6
- metadata.gz: 69e153809a336d6bebd1bf5f86d2bbc4790710808d60880fa5320f4d11a3a2f0963e585e7ef3b379a85e349b9aa66796d4bed07cd9920089f4c3fb5e6c13dc2c
7
- data.tar.gz: 5c82f814adbc33c2d6a814599b7fa40e3d3959bd2969db1a5d6302f879c3d0933d27b8ca4f20d9071032ce3c58c4dad7faed19f7064bf5632f2d149f29cb2e90
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://www.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://www.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
  ----
@@ -760,6 +751,20 @@ logger.write "Test."
760
751
  logger.reread # ""
761
752
  ----
762
753
 
754
+ ===== #any
755
+
756
+ 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.
757
+
758
+ ``` ruby
759
+ logger = Logger.new STDOUT
760
+
761
+ logger.any "Test."
762
+ # A, [2000-01-10T09:00:00.847428 #44925] ANY -- : Test.
763
+
764
+ logger.any { "Test." }
765
+ A, [2000-01-10T09:00:00.330719 #44925] ANY -- : Test.
766
+ ```
767
+
763
768
  ==== Pathname
764
769
 
765
770
  ===== Pathname
@@ -817,7 +822,7 @@ before being required to ensure consistent behavior. Example:
817
822
  Dir[File.join(__dir__, "support/shared_contexts/**/*.rb")].sort.each { |path| require path }
818
823
 
819
824
  # After
820
- Pathname.require_tree __dir__, "support/shared_contexts/**/*.rb"
825
+ Pathname.require_tree "#{__dir__}/support/shared_contexts"
821
826
  ----
822
827
 
823
828
  The following are further examples of potential usage:
@@ -831,7 +836,7 @@ Pathname.require_tree __dir__
831
836
  Pathname.require_tree "/test"
832
837
 
833
838
  # Requires all files in RSpec shared examples directory structure.
834
- Pathname.require_tree SPEC_ROOT, "support/shared_examples/**/*.rb"
839
+ Pathname.require_tree SPEC_ROOT.join("support/shared_examples")
835
840
  ----
836
841
 
837
842
  ===== .root
@@ -1133,7 +1138,7 @@ Answers first character of a string or first set of characters if given a number
1133
1138
 
1134
1139
  ===== #indent
1135
1140
 
1136
- 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.
1137
1142
 
1138
1143
  [source,ruby]
1139
1144
  ----
@@ -1439,19 +1444,19 @@ To test, run:
1439
1444
  bin/rake
1440
1445
  ----
1441
1446
 
1442
- == link:https://www.alchemists.io/policies/license[License]
1447
+ == link:https://alchemists.io/policies/license[License]
1443
1448
 
1444
- == link:https://www.alchemists.io/policies/security[Security]
1449
+ == link:https://alchemists.io/policies/security[Security]
1445
1450
 
1446
- == link:https://www.alchemists.io/policies/code_of_conduct[Code of Conduct]
1451
+ == link:https://alchemists.io/policies/code_of_conduct[Code of Conduct]
1447
1452
 
1448
- == link:https://www.alchemists.io/policies/contributions[Contributions]
1453
+ == link:https://alchemists.io/policies/contributions[Contributions]
1449
1454
 
1450
- == link:https://www.alchemists.io/projects/refinements/versions[Versions]
1455
+ == link:https://alchemists.io/projects/refinements/versions[Versions]
1451
1456
 
1452
- == link:https://www.alchemists.io/community[Community]
1457
+ == link:https://alchemists.io/community[Community]
1453
1458
 
1454
1459
  == Credits
1455
1460
 
1456
- * Built with link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
1457
- * Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
1461
+ * Built with link:https://alchemists.io/projects/gemsmith[Gemsmith].
1462
+ * Engineered by link:https://alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
@@ -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
@@ -9,6 +9,8 @@ module Refinements
9
9
 
10
10
  refine Logger do
11
11
  def reread = @logdev.reread
12
+
13
+ alias_method :any, :unknown
12
14
  end
13
15
  end
14
16
  end
data/refinements.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "refinements"
5
- spec.version = "10.0.1"
5
+ spec.version = "10.1.1"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
- spec.homepage = "https://www.alchemists.io/projects/refinements"
8
+ spec.homepage = "https://alchemists.io/projects/refinements"
9
9
  spec.summary = "A collection of refinements to core Ruby objects."
10
10
  spec.license = "Hippocratic-2.1"
11
11
 
12
12
  spec.metadata = {
13
13
  "bug_tracker_uri" => "https://github.com/bkuhlmann/refinements/issues",
14
- "changelog_uri" => "https://www.alchemists.io/projects/refinements/versions",
15
- "documentation_uri" => "https://www.alchemists.io/projects/refinements",
14
+ "changelog_uri" => "https://alchemists.io/projects/refinements/versions",
15
+ "documentation_uri" => "https://alchemists.io/projects/refinements",
16
16
  "funding_uri" => "https://github.com/sponsors/bkuhlmann",
17
17
  "label" => "Refinements",
18
18
  "rubygems_mfa_required" => "true",
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.0.1
4
+ version: 10.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -10,25 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIC/jCCAeagAwIBAgIBBTANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
14
- a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMjAzMTkxNzI0MzJaFw0yMzAzMTkx
15
- NzI0MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
16
- IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
17
- xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
18
- brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
19
- 9z0A8KcGhz67SdcoQiD7qiCjL/2NTeWHOzkpPrdGlt088+VerEEGf5I13QCvaftP
20
- D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
21
- 3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
22
- AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
23
- 2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAJbbNyWzFjqUNVPPCUCo
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RhDl5HqS1SJp2Ko3lcnpXeFResp0HNlt8NSu13vhC08j
24
+ GUHU9MyIXbFOsnp3K3ADrAVjPWop8EZkmUR3MV/CUm00w2cZHCSGiXl1KMpiVKvk
25
+ Ywr1gd2ZME4QLSo+EXUtLxDUa/W3xnBS8dBOuMMz02FPWYr3PN8CAwEAAaN7MHkw
26
+ CQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFAFgmv0tYMZnItuPycSM
27
+ F5wykJEVMB8GA1UdEQQYMBaBFGJyb29rZUBhbGNoZW1pc3RzLmlvMB8GA1UdEgQY
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=
30
37
  -----END CERTIFICATE-----
31
- date: 2023-01-22 00:00:00.000000000 Z
38
+ date: 2023-04-08 00:00:00.000000000 Z
32
39
  dependencies: []
33
40
  description:
34
41
  email:
@@ -57,13 +64,13 @@ files:
57
64
  - lib/refinements/structs.rb
58
65
  - lib/refinements/symbols.rb
59
66
  - refinements.gemspec
60
- homepage: https://www.alchemists.io/projects/refinements
67
+ homepage: https://alchemists.io/projects/refinements
61
68
  licenses:
62
69
  - Hippocratic-2.1
63
70
  metadata:
64
71
  bug_tracker_uri: https://github.com/bkuhlmann/refinements/issues
65
- changelog_uri: https://www.alchemists.io/projects/refinements/versions
66
- documentation_uri: https://www.alchemists.io/projects/refinements
72
+ changelog_uri: https://alchemists.io/projects/refinements/versions
73
+ documentation_uri: https://alchemists.io/projects/refinements
67
74
  funding_uri: https://github.com/sponsors/bkuhlmann
68
75
  label: Refinements
69
76
  rubygems_mfa_required: 'true'
@@ -83,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
90
  - !ruby/object:Gem::Version
84
91
  version: '0'
85
92
  requirements: []
86
- rubygems_version: 3.4.4
93
+ rubygems_version: 3.4.10
87
94
  signing_key:
88
95
  specification_version: 4
89
96
  summary: A collection of refinements to core Ruby objects.
metadata.gz.sig CHANGED
Binary file