refinements 13.2.0 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +31 -0
- data/lib/refinements/string.rb +11 -1
- data/refinements.gemspec +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: 3b9653414033e7e566848bb9457c1642c047eed1f21d1dd2518f24cf4d3f366d
|
4
|
+
data.tar.gz: 858ad0585193b6e65db26c71e8e7bd203838441820e44127f0787e4a75406c72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5a07a0139c13fbd31c08a72d1905703db130f0bb0fb30c27ee938266146d0273c29b5cec6543520a11c5f244ad525a8dc9448c65ecac8ec1d650426430f7c4f
|
7
|
+
data.tar.gz: 2c97c94497dd0827239452ad1c936290ee2fb77587426b5d23c47557d7c1ae1dc69e7a36d3c63548d99669f920d35d3b0a4233ef4b9cc5754cd66dd56b76eecd
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -1292,6 +1292,22 @@ Answers string with only first letter down cased.
|
|
1292
1292
|
"EXAMPLE".down # "eXAMPLE"
|
1293
1293
|
----
|
1294
1294
|
|
1295
|
+
===== #falsey?
|
1296
|
+
|
1297
|
+
Answers if string is falsey.
|
1298
|
+
|
1299
|
+
[source,ruby]
|
1300
|
+
----
|
1301
|
+
"false".falsey? # true
|
1302
|
+
"0".falsey? # true
|
1303
|
+
"no".falsey? # true
|
1304
|
+
"".falsey? # true
|
1305
|
+
"example".falsey? # true
|
1306
|
+
"true".falsey? # false
|
1307
|
+
"yes".falsey? # false
|
1308
|
+
"1".falsey? # false
|
1309
|
+
----
|
1310
|
+
|
1295
1311
|
===== #first
|
1296
1312
|
|
1297
1313
|
Answers first character of a string or first set of characters if given a number.
|
@@ -1394,6 +1410,19 @@ Answers a title string with proper capitalization of each word.
|
|
1394
1410
|
"ThisIsAnExample".titleize # "This Is An Example"
|
1395
1411
|
----
|
1396
1412
|
|
1413
|
+
===== #truthy?
|
1414
|
+
|
1415
|
+
Answers if string is truthy.
|
1416
|
+
|
1417
|
+
[source,ruby]
|
1418
|
+
----
|
1419
|
+
"true".truthy? # true
|
1420
|
+
"yes".truthy? # true
|
1421
|
+
"1".truthy? # true
|
1422
|
+
"".truthy? # false
|
1423
|
+
"example".truthy? # false
|
1424
|
+
----
|
1425
|
+
|
1397
1426
|
===== #truncate
|
1398
1427
|
|
1399
1428
|
Answers a truncated, non-mutated, string for given length with optional delimiter and/or overflow.
|
@@ -1420,6 +1449,8 @@ demo.truncate 16, trailer: "... (more)" # "It was... (more)"
|
|
1420
1449
|
|
1421
1450
|
===== #to_bool
|
1422
1451
|
|
1452
|
+
⚠️ This method is deprecated and will be removed in Version 14.0.0. Please use `#truthy?` or `#falsey?` instead.
|
1453
|
+
|
1423
1454
|
Answers string as a boolean.
|
1424
1455
|
|
1425
1456
|
[source,ruby]
|
data/lib/refinements/string.rb
CHANGED
@@ -18,6 +18,8 @@ module Refinements
|
|
18
18
|
|
19
19
|
def down = empty? ? self : first.downcase + self[1, size]
|
20
20
|
|
21
|
+
def falsey? = !truthy?
|
22
|
+
|
21
23
|
def first maximum = 0
|
22
24
|
return self if empty?
|
23
25
|
return self[0] if maximum.zero?
|
@@ -60,6 +62,8 @@ module Refinements
|
|
60
62
|
.then { |parts| combine parts, :up, "/" }
|
61
63
|
end
|
62
64
|
|
65
|
+
def truthy? = %w[true yes on t y 1].include? downcase.strip
|
66
|
+
|
63
67
|
def truncate to, delimiter = nil, trailer: "..."
|
64
68
|
return dup if length <= to
|
65
69
|
|
@@ -68,7 +72,13 @@ module Refinements
|
|
68
72
|
"#{self[...maximum]}#{trailer}"
|
69
73
|
end
|
70
74
|
|
71
|
-
|
75
|
+
# rubocop:disable Naming/PredicateMethod
|
76
|
+
def to_bool
|
77
|
+
warn "`#{self.class}##{__method__}` is deprecated, use `#truthy?` or `#falsey?` instead.",
|
78
|
+
category: :deprecated
|
79
|
+
truthy?
|
80
|
+
end
|
81
|
+
# rubocop:enable Naming/PredicateMethod
|
72
82
|
|
73
83
|
def up = empty? ? self : first.upcase + self[1, size]
|
74
84
|
|
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: 13.
|
4
|
+
version: 13.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
|
-
rubygems_version: 3.6.
|
91
|
+
rubygems_version: 3.6.9
|
92
92
|
specification_version: 4
|
93
93
|
summary: A collection of core object refinements.
|
94
94
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|