refinements 7.2.0 → 7.7.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.tar.gz.sig +0 -0
- data/README.adoc +123 -28
- data/lib/refinements.rb +2 -1
- data/lib/refinements/files.rb +1 -0
- data/lib/refinements/hashes.rb +43 -2
- data/lib/refinements/identity.rb +1 -1
- data/lib/refinements/pathnames.rb +33 -0
- data/lib/refinements/string_ios.rb +13 -0
- data/lib/refinements/strings.rb +26 -27
- metadata +21 -20
- 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: 3b7d7affd4176bb25ee87d3718b592a0bd2b07be2bad86d584f06f0d16dcd866
|
4
|
+
data.tar.gz: 256ab9f274581c668a06949a41501c50885f9681dd6150c9b58046d59cf87de7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 356b4ea5575bbec34d4b2c31495c59b49ce9efe00bedcce194d458c8bdbbcf47ca87e3be00b60f910af14e2768cf8b42de909fcdec652a895d8de706652e0777
|
7
|
+
data.tar.gz: 0a7d8c6bd99585868ec7b2d119f7014e1c2ebf571324d23c8be209bd364417c4106f465a4f0dd6ab012fb6f82e1024ae803ef0d27949051e6c65b4aa2d6f63dd
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -19,29 +19,47 @@ toc::[]
|
|
19
19
|
** `#compress` - Removes `nil` and empty values without modifying itself.
|
20
20
|
** `#compress!` - Removes `nil` and empty values while modifying itself.
|
21
21
|
** `#ring` - Answers a circular array which can enumerate before, current, after elements.
|
22
|
-
* *DateTimes*:
|
23
|
-
** `.utc` - Answers new DateTime object for current UTC date/time.
|
24
22
|
* *BigDecimals*:
|
25
23
|
** `#inspect` - Allows one to inspect a big decimal with numeric representation.
|
24
|
+
* *DateTimes*:
|
25
|
+
** `.utc` - Answers new DateTime object for current UTC date/time.
|
26
26
|
* *Files*:
|
27
|
-
** `#name` - Answers the _name_ of file without extension.
|
28
|
-
** `#copy` - Copies an existing file to new file. Both directory structures must exist.
|
29
27
|
** `#rewrite` - When given a file path and a block, it provides the contents of the recently read
|
30
28
|
file for manipulation and immediate writing back to the same file.
|
31
|
-
** `#touch` - Updates the access and modified times of an existing file or creates the file when
|
32
|
-
not existing.
|
33
29
|
* *Hashes*:
|
34
|
-
**
|
35
|
-
**
|
30
|
+
** `.infinite` - Answers new hash where missing keys, even deeply nested, answer an empty hash.
|
31
|
+
** `.with_default` - Answers new hash where every top-level missing key has the same default value.
|
32
|
+
** `#except` - Answers new hash with given keys removed without modifying itself.
|
33
|
+
** `#except!` - Answers new hash with given keys removed while modifying itself.
|
36
34
|
** `#symbolize_keys` - Converts keys to symbols without modifying itself.
|
37
35
|
** `#symbolize_keys!` - Converts keys to symbols while modifying itself.
|
38
36
|
** `#deep_merge` - Merges deeply nested hashes together without modifying itself.
|
39
37
|
** `#deep_merge!` - Merges deeply nested hashes together while modifying itself.
|
40
|
-
** `#
|
41
|
-
|
38
|
+
** `#deep_symbolize_keys` - Symbolizes keys of nested hash without modifying itself. Does not handle
|
39
|
+
nested arrays, though.
|
40
|
+
** `#deep_symbolize_keys!` - Symbolizes keys of nested hash while modifying itself. Does not handle
|
41
|
+
nested arrays, though.
|
42
|
+
** `#recurse` - Applies block to nested hash. Does not handle nested arrays, though.
|
43
|
+
** `#rekey` - Transforms keys per mapping (size of mapping can vary) without modifying itself.
|
44
|
+
** `#rekey!` - Transforms keys per mapping (size of mapping can vary) while modifying itself.
|
45
|
+
** `#reverse_merge` - Merges calling hash into passed in hash without modifying itself.
|
46
|
+
** `#reverse_merge!` - Merges calling hash into passed in hash while modifying itself.
|
47
|
+
** `#use` - Passes each hash value as a block argument for further processing.
|
42
48
|
* *Pathnames*:
|
49
|
+
** `Pathname` - Conversion function (refined from `Kernel`) which can cast `nil` into a pathname.
|
50
|
+
** `#name` - Answers file name without extension.
|
51
|
+
** `#copy` - Copies file from current location to new location.
|
52
|
+
** `#directories` - Answers all or filtered directories for current path.
|
53
|
+
** `#extensions` - Answers file extensions as an array.
|
54
|
+
** `#files` - Answers all or filtered files for current path.
|
55
|
+
** `#gsub` - Same behavior as `String#gsub` but answers a path with patterns replaced with desired
|
56
|
+
substitutes.
|
57
|
+
** `#relative_parent_from` - Answers relative path from parent directory. This is a complement to
|
58
|
+
`#relative_path_from`.
|
59
|
+
** `#make_ancestors` - Ensures all ancestor directories are created for a path.
|
43
60
|
** `#rewrite` - When given a block, it provides the contents of the recently read file for
|
44
61
|
manipulation and immediate writing back to the same file.
|
62
|
+
** `#touch` - Updates access and modification times for path. Defaults to current time.
|
45
63
|
* *Strings*:
|
46
64
|
** `#first` - Answers first character of a string or first set of characters if given a number.
|
47
65
|
** `#last` - Answers last character of a string or last set of characters if given a number.
|
@@ -49,17 +67,18 @@ manipulation and immediate writing back to the same file.
|
|
49
67
|
(i.e. `<space>`, `\n`, `\t`, `\r`).
|
50
68
|
** `#up` - Answers string with only first letter upcased.
|
51
69
|
** `#down` - Answers string with only first letter downcased.
|
52
|
-
** `#camelcase` - Answers a camelcased string.
|
53
|
-
** `#snakecase` - Answers a snakecased string.
|
54
|
-
** `#titleize` - Answers titleized string.
|
55
|
-
** `#
|
56
|
-
|
70
|
+
** `#camelcase` - Answers a camelcased string.
|
71
|
+
** `#snakecase` - Answers a snakecased string.
|
72
|
+
** `#titleize` - Answers titleized string.
|
73
|
+
** `#to_bool` - Answers string as a boolean.
|
74
|
+
* *String IOs*:
|
75
|
+
** `#reread` - Answers full string by rewinding to beginning of string and reading all content.
|
57
76
|
|
58
77
|
== Requirements
|
59
78
|
|
60
|
-
. https://www.ruby-lang.org[Ruby
|
61
|
-
. A solid understanding of https://www.
|
62
|
-
scope].
|
79
|
+
. https://www.ruby-lang.org[Ruby].
|
80
|
+
. A solid understanding of link:https://www.alchemists.io/articles/ruby_refinements[Ruby refinements
|
81
|
+
and lexical scope].
|
63
82
|
|
64
83
|
== Setup
|
65
84
|
|
@@ -113,8 +132,8 @@ gem "refinements", require: false
|
|
113
132
|
[source,ruby]
|
114
133
|
----
|
115
134
|
require "refinements/arrays"
|
116
|
-
require "refinements/date_times"
|
117
135
|
require "refinements/big_decimals"
|
136
|
+
require "refinements/date_times"
|
118
137
|
require "refinements/files"
|
119
138
|
require "refinements/hashes"
|
120
139
|
require "refinements/pathnames"
|
@@ -129,8 +148,8 @@ Much like including/extending a module, you’ll need modify your object(s) to u
|
|
129
148
|
----
|
130
149
|
class Example
|
131
150
|
using Refinements::Arrays
|
132
|
-
using Refinements::DateTimes
|
133
151
|
using Refinements::BigDecimals
|
152
|
+
using Refinements::DateTimes
|
134
153
|
using Refinements::Files
|
135
154
|
using Refinements::Hashes
|
136
155
|
using Refinements::Pathnames
|
@@ -162,18 +181,18 @@ example.ring { |(before, current, after)| puts "#{before} #{current} #{after}" }
|
|
162
181
|
# [2 3 1]
|
163
182
|
----
|
164
183
|
|
165
|
-
====
|
184
|
+
==== Big Decimal
|
166
185
|
|
167
186
|
[source,ruby]
|
168
187
|
----
|
169
|
-
|
188
|
+
BigDecimal.new("5.0E-10").inspect # => "#<BigDecimal:3fd3d458fe84 0.0000000005>"
|
170
189
|
----
|
171
190
|
|
172
|
-
====
|
191
|
+
==== DateTime
|
173
192
|
|
174
193
|
[source,ruby]
|
175
194
|
----
|
176
|
-
|
195
|
+
DateTime.utc # => #<DateTime: 2019-12-31T18:17:00+00:00 ((2458849j,65820s,181867000n),+0s,2299161j)>
|
177
196
|
----
|
178
197
|
|
179
198
|
==== File
|
@@ -187,6 +206,15 @@ File.rewrite("/test.txt") { |content| content.gsub "[placeholder]", "example" }
|
|
187
206
|
|
188
207
|
[source,ruby]
|
189
208
|
----
|
209
|
+
example = Hash.infinite
|
210
|
+
example[:a] # => {}
|
211
|
+
example[:a][:b][:c] # => {}
|
212
|
+
|
213
|
+
example = Hash.with_default ""
|
214
|
+
example[:a] # => ""
|
215
|
+
example = Hash.with_default []
|
216
|
+
example[:b] # => []
|
217
|
+
|
190
218
|
example = {a: 1, b: 2, c: 3}
|
191
219
|
example.except :a, :b # => {c: 3}
|
192
220
|
example # => {a: 1, b: 2, c: 3}
|
@@ -219,6 +247,26 @@ example = {a: "A", b: {one: "One", two: "Two"}}
|
|
219
247
|
example.deep_merge! b: {one: 1} # => {a: "A", b: {one: 1, two: "Two"}}
|
220
248
|
example # => {a: "A", b: {one: 1, two: "Two"}}
|
221
249
|
|
250
|
+
example = {"a" => {"b" => 2}}
|
251
|
+
example.deep_symbolize_keys # => {a: {b: 1}}
|
252
|
+
example # => {"a" => {"b" => 2}}
|
253
|
+
|
254
|
+
example = {"a" => {"b" => 2}}
|
255
|
+
example.deep_symbolize_keys! # => {a: {b: 1}}
|
256
|
+
example # => {a: {b: 1}}
|
257
|
+
|
258
|
+
example = {"a" => {"b" => 1}}
|
259
|
+
example.recurse(&:symbolize_keys) # => {a: {b: 1}}
|
260
|
+
example.recurse(&:invert) # => {{"b" => 1} => "a"}
|
261
|
+
|
262
|
+
example = {a: 1, b: 2, c: 3}
|
263
|
+
example.rekey a: :amber, b: :blue # => {amber: 1, blue: 2, c: 3}
|
264
|
+
example # => {a: 1, b: 2, c: 3}
|
265
|
+
|
266
|
+
example = {a: 1, b: 2, c: 3}
|
267
|
+
example.rekey! a: :amber, b: :blue # => {amber: 1, blue: 2, c: 3}
|
268
|
+
example # => {amber: 1, blue: 2, c: 3}
|
269
|
+
|
222
270
|
example = {a: 1, b: 2}
|
223
271
|
example.reverse_merge a: 0, c: 3 # => {a: 1, b: 2, c: 3}
|
224
272
|
example # => {a: 1, b: 2}
|
@@ -235,14 +283,35 @@ example.use { |unit, street| "#{unit} #{street}" } # => "221B Baker Street"
|
|
235
283
|
|
236
284
|
[source,ruby]
|
237
285
|
----
|
238
|
-
Pathname(
|
286
|
+
Pathname(nil) # => Pathname("")
|
287
|
+
|
288
|
+
Pathname("example.txt").name # => Pathname("example")
|
239
289
|
|
240
290
|
Pathname("input.txt").copy Pathname("output.txt")
|
241
291
|
|
292
|
+
Pathname("/example").directories # => [Pathname("a"), Pathname("b")]
|
293
|
+
Pathname("/example").directories "a*" # => [Pathname("a")]
|
294
|
+
Pathname("/example").directories flag: File::FNM_DOTMATCH # => [Pathname(".."), Pathname(".")]
|
295
|
+
|
296
|
+
Pathname("example.txt.erb").extensions # => [".txt", ".erb"]
|
297
|
+
|
298
|
+
Pathname("/example").files # => [Pathname("a.txt"), Pathname("a.png")]
|
299
|
+
Pathname("/example").files "*.png" # => [Pathname("a.png")]
|
300
|
+
Pathname("/example").files flag: File::FNM_DOTMATCH # => [Pathname(".ruby-version")]
|
301
|
+
|
302
|
+
Pathname("/a/path/some/path").gsub("path", "test") # => Pathname("/a/test/some/test")
|
303
|
+
Pathname("/%placeholder%/some/%placeholder%").gsub("%placeholder%", "test") # => Pathname("/test/some/test")
|
304
|
+
|
305
|
+
Pathname("/one/two/three").relative_parent_from("/one") # => Pathname "two"
|
306
|
+
|
307
|
+
Pathname("/one/two").make_ancestors
|
308
|
+
Pathname("/one").exist? # => true
|
309
|
+
Pathname("/one/two").exist? # => false
|
310
|
+
|
242
311
|
Pathname("/test.txt").rewrite { |content| content.sub "[placeholder]", "example" }
|
243
312
|
|
244
|
-
Pathname("
|
245
|
-
Pathname("
|
313
|
+
Pathname("example.txt").touch
|
314
|
+
Pathname("example.txt").touch at: Time.now - 1
|
246
315
|
----
|
247
316
|
|
248
317
|
==== String
|
@@ -256,11 +325,37 @@ Pathname("test.txt").touch accessed_at: Time.now - 1, modified_at: Time.now - 1
|
|
256
325
|
"instant".last 3 # => "ant"
|
257
326
|
|
258
327
|
" \n\t\r".blank? # => true
|
328
|
+
|
259
329
|
"example".up # => "Example"
|
330
|
+
|
260
331
|
"EXAMPLE".down # => "eXAMPLE"
|
332
|
+
|
261
333
|
"this_is_an_example".camelcase # => "ThisIsAnExample"
|
334
|
+
|
262
335
|
"ThisIsAnExample".snakecase # => "this_is_an_example"
|
336
|
+
|
263
337
|
"ThisIsAnExample".titleize # => "This Is An Example"
|
338
|
+
|
339
|
+
"true".to_bool # => true
|
340
|
+
"yes".to_bool # => true
|
341
|
+
"1".to_bool # => true
|
342
|
+
"".to_bool # => false
|
343
|
+
"example".to_bool # => false
|
344
|
+
----
|
345
|
+
|
346
|
+
==== String IO
|
347
|
+
|
348
|
+
[source,ruby]
|
349
|
+
----
|
350
|
+
io = StringIO.new
|
351
|
+
io.write "This is a test."
|
352
|
+
io.reread # => "This is a test."
|
353
|
+
|
354
|
+
io.reread(4) => "This"
|
355
|
+
|
356
|
+
buffer = "".dup
|
357
|
+
io.reread(buffer: buffer)
|
358
|
+
buffer # => "This is a test."
|
264
359
|
----
|
265
360
|
|
266
361
|
== Tests
|
@@ -299,4 +394,4 @@ Read link:CHANGES.adoc[CHANGES] for details.
|
|
299
394
|
|
300
395
|
== Credits
|
301
396
|
|
302
|
-
Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann
|
397
|
+
Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
data/lib/refinements.rb
CHANGED
@@ -2,9 +2,10 @@
|
|
2
2
|
|
3
3
|
require "refinements/identity"
|
4
4
|
require "refinements/arrays"
|
5
|
-
require "refinements/date_times"
|
6
5
|
require "refinements/big_decimals"
|
6
|
+
require "refinements/date_times"
|
7
7
|
require "refinements/files"
|
8
8
|
require "refinements/hashes"
|
9
9
|
require "refinements/pathnames"
|
10
10
|
require "refinements/strings"
|
11
|
+
require "refinements/string_ios"
|
data/lib/refinements/files.rb
CHANGED
data/lib/refinements/hashes.rb
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
module Refinements
|
4
4
|
module Hashes
|
5
|
+
refine Hash.singleton_class do
|
6
|
+
def infinite
|
7
|
+
new { |new_hash, missing_key| new_hash[missing_key] = new(&new_hash.default_proc) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def with_default value
|
11
|
+
new { |new_hash, missing_key| new_hash[missing_key] = value }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
refine Hash do
|
6
16
|
def except *keys
|
7
17
|
reject { |key, _value| keys.include? key }
|
@@ -23,10 +33,11 @@ module Refinements
|
|
23
33
|
dup.deep_merge! other
|
24
34
|
end
|
25
35
|
|
26
|
-
# :reek:FeatureEnvy
|
27
36
|
def deep_merge! other
|
37
|
+
clazz = self.class
|
38
|
+
|
28
39
|
merge! other do |_key, this_value, other_value|
|
29
|
-
if this_value.is_a?(
|
40
|
+
if this_value.is_a?(clazz) && other_value.is_a?(clazz)
|
30
41
|
this_value.deep_merge other_value
|
31
42
|
else
|
32
43
|
other_value
|
@@ -34,11 +45,41 @@ module Refinements
|
|
34
45
|
end
|
35
46
|
end
|
36
47
|
|
48
|
+
def deep_symbolize_keys
|
49
|
+
recurse(&:symbolize_keys)
|
50
|
+
end
|
51
|
+
|
52
|
+
def deep_symbolize_keys!
|
53
|
+
recurse(&:symbolize_keys!)
|
54
|
+
end
|
55
|
+
|
56
|
+
def recurse &block
|
57
|
+
return self unless block_given?
|
58
|
+
|
59
|
+
transform = yield self
|
60
|
+
|
61
|
+
transform.each do |key, value|
|
62
|
+
transform[key] = value.recurse(&block) if value.is_a? self.class
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def rekey mapping = {}
|
67
|
+
return self if mapping.empty?
|
68
|
+
|
69
|
+
transform_keys { |key| mapping[key] || key }
|
70
|
+
end
|
71
|
+
|
72
|
+
def rekey! mapping = {}
|
73
|
+
replace rekey(mapping)
|
74
|
+
end
|
75
|
+
|
37
76
|
def reverse_merge other
|
77
|
+
warn "[DEPRECATION]: #reverse_merge is deprecated, use #merge instead."
|
38
78
|
other.merge self
|
39
79
|
end
|
40
80
|
|
41
81
|
def reverse_merge! other
|
82
|
+
warn "[DEPRECATION]: #reverse_merge! is deprecated, use #merge! instead."
|
42
83
|
merge!(other) { |_key, old_value, _new_value| old_value }
|
43
84
|
end
|
44
85
|
|
data/lib/refinements/identity.rb
CHANGED
@@ -4,6 +4,14 @@ require "pathname"
|
|
4
4
|
|
5
5
|
module Refinements
|
6
6
|
module Pathnames
|
7
|
+
refine Kernel do
|
8
|
+
def Pathname object
|
9
|
+
return super(String(object)) unless object
|
10
|
+
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
7
15
|
refine Pathname do
|
8
16
|
def name
|
9
17
|
basename extname
|
@@ -15,6 +23,31 @@ module Refinements
|
|
15
23
|
self
|
16
24
|
end
|
17
25
|
|
26
|
+
def directories pattern = "*", flag: File::FNM_SYSCASE
|
27
|
+
glob(pattern, flag).select(&:directory?).sort
|
28
|
+
end
|
29
|
+
|
30
|
+
def extensions
|
31
|
+
basename.to_s.split(/(?=\.)+/).tap(&:shift)
|
32
|
+
end
|
33
|
+
|
34
|
+
def files pattern = "*", flag: File::FNM_SYSCASE
|
35
|
+
glob(pattern, flag).select(&:file?).sort
|
36
|
+
end
|
37
|
+
|
38
|
+
def gsub pattern, replacement
|
39
|
+
self.class.new to_s.gsub(pattern, replacement)
|
40
|
+
end
|
41
|
+
|
42
|
+
def relative_parent_from root
|
43
|
+
relative_path_from(root).parent
|
44
|
+
end
|
45
|
+
|
46
|
+
def make_ancestors
|
47
|
+
dirname.mkpath
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
18
51
|
def rewrite
|
19
52
|
read.then { |content| write yield(content) if block_given? }
|
20
53
|
self
|
data/lib/refinements/strings.rb
CHANGED
@@ -2,9 +2,12 @@
|
|
2
2
|
|
3
3
|
module Refinements
|
4
4
|
module Strings
|
5
|
+
DELIMITERS = %r([a-z][A-Z]|\s*-\s*|\s*/\s*|\s*:+\s*|\s*_\s*|\s+).freeze
|
6
|
+
|
5
7
|
refine String.singleton_class do
|
6
8
|
def delimiters
|
7
|
-
|
9
|
+
warn "[DEPRECATION]: .delimiters is deprecated, use DELIMITERS instead."
|
10
|
+
DELIMITERS
|
8
11
|
end
|
9
12
|
end
|
10
13
|
|
@@ -17,20 +20,18 @@ module Refinements
|
|
17
20
|
return self[0] if max.zero?
|
18
21
|
return "" if max.negative?
|
19
22
|
|
20
|
-
self[
|
23
|
+
self[..(max - 1)]
|
21
24
|
end
|
22
25
|
|
23
|
-
# :reek:TooManyStatements
|
24
26
|
def last number = 0
|
25
27
|
return self if empty?
|
26
28
|
|
27
29
|
min = Integer number
|
28
|
-
max = size - 1
|
29
30
|
|
30
|
-
return self[
|
31
|
+
return self[size - 1] if min.zero?
|
31
32
|
return "" if min.negative?
|
32
33
|
|
33
|
-
self[(min + 1)..
|
34
|
+
self[(min + 1)..]
|
34
35
|
end
|
35
36
|
|
36
37
|
def blank?
|
@@ -50,33 +51,31 @@ module Refinements
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def camelcase
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
up
|
59
|
-
end
|
54
|
+
return up unless match? DELIMITERS
|
55
|
+
|
56
|
+
split(%r(\s*-\s*|\s*/\s*|\s*:+\s*)).then { |parts| combine parts, :up, "::" }
|
57
|
+
.then { |text| text.split(/\s*_\s*|\s+/) }
|
58
|
+
.then { |parts| combine parts, :up }
|
60
59
|
end
|
61
60
|
|
62
61
|
def snakecase
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
downcase
|
69
|
-
end
|
62
|
+
return downcase unless match? DELIMITERS
|
63
|
+
|
64
|
+
split(%r(\s*-\s*|\s*/\s*|\s*:+\s*)).then { |parts| combine parts, :down, "/" }
|
65
|
+
.then { |text| text.split(/(?=[A-Z])|\s*_\s*|\s+/) }
|
66
|
+
.then { |parts| combine parts, :down, "_" }
|
70
67
|
end
|
71
68
|
|
72
69
|
def titleize
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
70
|
+
return capitalize unless match? DELIMITERS
|
71
|
+
|
72
|
+
split(/(?=[A-Z])|\s*_\s*|\s*-\s*|\s+/).then { |parts| combine parts, :up, " " }
|
73
|
+
.then { |text| text.split %r(\s*/\s*|\s*:+\s*) }
|
74
|
+
.then { |parts| combine parts, :up, "/" }
|
75
|
+
end
|
76
|
+
|
77
|
+
def to_bool
|
78
|
+
%w[true yes on t y 1].include? downcase.strip
|
80
79
|
end
|
81
80
|
|
82
81
|
private
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
28
28
|
2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
|
29
29
|
QWc=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2020-
|
31
|
+
date: 2020-08-05 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler-audit
|
@@ -50,28 +50,28 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '14.
|
53
|
+
version: '14.2'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '14.
|
60
|
+
version: '14.2'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name: git-
|
62
|
+
name: git-lint
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '1.0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '1.0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: guard-rspec
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,28 +92,28 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '0.
|
95
|
+
version: '0.13'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '0.
|
102
|
+
version: '0.13'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: pry-byebug
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '3.
|
109
|
+
version: '3.9'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: '3.
|
116
|
+
version: '3.9'
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: rake
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,14 +162,14 @@ dependencies:
|
|
162
162
|
requirements:
|
163
163
|
- - "~>"
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
version: '0.
|
165
|
+
version: '0.83'
|
166
166
|
type: :development
|
167
167
|
prerelease: false
|
168
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version: '0.
|
172
|
+
version: '0.83'
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
174
|
name: rubocop-performance
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,14 +204,14 @@ dependencies:
|
|
204
204
|
requirements:
|
205
205
|
- - "~>"
|
206
206
|
- !ruby/object:Gem::Version
|
207
|
-
version: '1.
|
207
|
+
version: '1.39'
|
208
208
|
type: :development
|
209
209
|
prerelease: false
|
210
210
|
version_requirements: !ruby/object:Gem::Requirement
|
211
211
|
requirements:
|
212
212
|
- - "~>"
|
213
213
|
- !ruby/object:Gem::Version
|
214
|
-
version: '1.
|
214
|
+
version: '1.39'
|
215
215
|
- !ruby/object:Gem::Dependency
|
216
216
|
name: simplecov
|
217
217
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,7 +226,7 @@ dependencies:
|
|
226
226
|
- - "~>"
|
227
227
|
- !ruby/object:Gem::Version
|
228
228
|
version: '0.18'
|
229
|
-
description:
|
229
|
+
description:
|
230
230
|
email:
|
231
231
|
- brooke@alchemists.io
|
232
232
|
executables: []
|
@@ -245,6 +245,7 @@ files:
|
|
245
245
|
- lib/refinements/hashes.rb
|
246
246
|
- lib/refinements/identity.rb
|
247
247
|
- lib/refinements/pathnames.rb
|
248
|
+
- lib/refinements/string_ios.rb
|
248
249
|
- lib/refinements/strings.rb
|
249
250
|
homepage: https://www.alchemists.io/projects/refinements
|
250
251
|
licenses:
|
@@ -254,7 +255,7 @@ metadata:
|
|
254
255
|
changelog_uri: https://www.alchemists.io/projects/refinements/changes.html
|
255
256
|
documentation_uri: https://www.alchemists.io/projects/refinements
|
256
257
|
source_code_uri: https://github.com/bkuhlmann/refinements
|
257
|
-
post_install_message:
|
258
|
+
post_install_message:
|
258
259
|
rdoc_options: []
|
259
260
|
require_paths:
|
260
261
|
- lib
|
@@ -269,8 +270,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
269
270
|
- !ruby/object:Gem::Version
|
270
271
|
version: '0'
|
271
272
|
requirements: []
|
272
|
-
rubygems_version: 3.1.
|
273
|
-
signing_key:
|
273
|
+
rubygems_version: 3.1.4
|
274
|
+
signing_key:
|
274
275
|
specification_version: 4
|
275
276
|
summary: A collection of refinements to core Ruby objects.
|
276
277
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|