refinements 9.4.0 → 9.5.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 +15 -0
- data/lib/refinements/arrays.rb +8 -0
- data/lib/refinements/hashes.rb +2 -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: 06c161de8cf1a100c8df6267ef2116368743557dac4504e9617b19dd063520aa
|
4
|
+
data.tar.gz: 60389a48bc41a581d835ac67c80e71a8db438ddbccf070336e1128d4d430e87a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95c680f9fe5df9820d72462e40984eafe398b0cf81589b6525026978a477950723608d8d39b89b3fe0c61e888ce3a2a166d2e54ec26676a3c9621f6b712e3828
|
7
|
+
data.tar.gz: b3743029174a74733328346ce1264d9f7dab9876222deb4a3b3f96a38817cf8b7c0b35eabc62639b5f7e7f4f2e1572282d1f31952e6c55b90d6f65df2b190bef
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -254,6 +254,21 @@ example.ring { |(before, current, after)| puts "#{before} #{current} #{after}" }
|
|
254
254
|
# [2 3 1]
|
255
255
|
----
|
256
256
|
|
257
|
+
===== #to_sentence
|
258
|
+
|
259
|
+
Answers a sentence using `", "` as the default delimiter and `"and"` as the default conjunction.
|
260
|
+
Useful when building documentation, answering human readable error messages, etc.
|
261
|
+
|
262
|
+
[source,ruby]
|
263
|
+
----
|
264
|
+
[].to_sentence # ""
|
265
|
+
["test"].to_sentence # "test"
|
266
|
+
["a", :b].to_sentence # "a and b"
|
267
|
+
[1, "a", :b, 2.0, /\w+/].map(&:inspect).to_sentence # 1, "a", :b, 2.0, and /\w+/
|
268
|
+
%w[one two three].to_sentence # "one, two, and three"
|
269
|
+
%w[eins zwei drei].to_sentence delimiter: " ", conjunction: "und" # "eins zwei und drei"
|
270
|
+
----
|
271
|
+
|
257
272
|
==== Big Decimal
|
258
273
|
|
259
274
|
===== #inspect
|
data/lib/refinements/arrays.rb
CHANGED
@@ -32,6 +32,14 @@ module Refinements
|
|
32
32
|
def pad(value, max: size) = dup.fill(value, size..(max - 1))
|
33
33
|
|
34
34
|
def ring(&) = [last, *self, first].each_cons(3, &)
|
35
|
+
|
36
|
+
def to_sentence delimiter: ", ", conjunction: "and"
|
37
|
+
case length
|
38
|
+
when (3..) then "#{self[..-2].join delimiter}#{delimiter}#{conjunction} #{last}"
|
39
|
+
when 2 then join " #{conjunction} "
|
40
|
+
else join
|
41
|
+
end
|
42
|
+
end
|
35
43
|
end
|
36
44
|
end
|
37
45
|
end
|
data/lib/refinements/hashes.rb
CHANGED
@@ -21,7 +21,8 @@ module Refinements
|
|
21
21
|
def compress!
|
22
22
|
return self if empty?
|
23
23
|
|
24
|
-
compact
|
24
|
+
compact!
|
25
|
+
delete_if { |_key, value| value.respond_to?(:empty?) && value.empty? }
|
25
26
|
end
|
26
27
|
|
27
28
|
def deep_merge other
|
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: 9.
|
4
|
+
version: 9.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
28
28
|
CxDe2+VuChj4I1nvIHdu+E6XoEVlanUPKmSg6nddhkKn2gC45Kyzh6FZqnzH/CRp
|
29
29
|
RFE=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2022-
|
31
|
+
date: 2022-06-25 00:00:00.000000000 Z
|
32
32
|
dependencies: []
|
33
33
|
description:
|
34
34
|
email:
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
|
-
rubygems_version: 3.3.
|
83
|
+
rubygems_version: 3.3.16
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: A collection of refinements to core Ruby objects.
|
metadata.gz.sig
CHANGED
Binary file
|