refinements 8.3.0 → 8.4.1
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 +24 -9
- data/lib/refinements/arrays.rb +5 -2
- data/lib/refinements/hashes.rb +2 -0
- data/lib/refinements/identity.rb +1 -1
- data/lib/refinements/pathnames.rb +3 -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: 0b633f00ddb573cba22fcf647e293a7f4544fecc82ad3869d9c3528d0bd8e1aa
|
4
|
+
data.tar.gz: 00ef7df42687d801237b8b27563aaa028e19b75a4764c32a3c2220f58186dbe0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edb16cbce2ab22b6b95303751e87f09037dd570b38ffb7e6620d91a3e8e7bc9293fdcf4a4378e091847b12ccb80bd5d57c5bab22b0d930507327e54c29c9c855
|
7
|
+
data.tar.gz: 5767133f63df1a255b0ac9d6f9ff1ab6c8dfc73d237968a3cea225e3d2be4964fd8aa2298c7047cb81a8594ba6a9f4a676738d485519b696efeee20ddfe4b51d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -107,13 +107,14 @@ The following sections demonstrate how each refinement enriches your objects wit
|
|
107
107
|
|
108
108
|
===== #compress
|
109
109
|
|
110
|
-
Removes `nil` and empty
|
110
|
+
Removes `nil` and empty objects without mutating itself.
|
111
111
|
|
112
112
|
[source,ruby]
|
113
113
|
----
|
114
|
-
|
115
|
-
example
|
116
|
-
example
|
114
|
+
object = Object.new
|
115
|
+
example = [1, "blueberry", nil, "", [], {}, object]
|
116
|
+
example.compress # => [1, "blueberry", object]
|
117
|
+
example # => [1, "blueberry", nil, "", [], {}, object]
|
117
118
|
----
|
118
119
|
|
119
120
|
===== #compress!
|
@@ -122,9 +123,10 @@ Removes `nil` and empty values while mutating itself.
|
|
122
123
|
|
123
124
|
[source,ruby]
|
124
125
|
----
|
125
|
-
|
126
|
-
example
|
127
|
-
example
|
126
|
+
object = Object.new
|
127
|
+
example = [1, "blueberry", nil, "", [], {}, object]
|
128
|
+
example.compress # => [1, "blueberry", object]
|
129
|
+
example # => [1, "blueberry", object]
|
128
130
|
----
|
129
131
|
|
130
132
|
===== #excluding
|
@@ -290,7 +292,7 @@ example[:b] # => []
|
|
290
292
|
|
291
293
|
===== #compress
|
292
294
|
|
293
|
-
Removes empty objects without mutating itself.
|
295
|
+
Removes `nil` and empty objects without mutating itself.
|
294
296
|
|
295
297
|
[source,ruby]
|
296
298
|
----
|
@@ -302,7 +304,7 @@ example # => {a: 1, b: "blueberry", c: nil, d: "", e: [], f: {}, g: ob
|
|
302
304
|
|
303
305
|
===== #compress!
|
304
306
|
|
305
|
-
Removes empty objects while mutating itself.
|
307
|
+
Removes `nil` and empty objects while mutating itself.
|
306
308
|
|
307
309
|
[source,ruby]
|
308
310
|
----
|
@@ -640,6 +642,19 @@ Copies file from current location to new location while answering itself so it c
|
|
640
642
|
Pathname("input.txt").copy Pathname("output.txt") # => Pathname("input.txt")
|
641
643
|
----
|
642
644
|
|
645
|
+
===== #delete
|
646
|
+
|
647
|
+
Deletes file or directory and answers itself so it can be chained.
|
648
|
+
|
649
|
+
[source,ruby]
|
650
|
+
----
|
651
|
+
# When path exists.
|
652
|
+
Pathname("/example.txt").touch.delete # => Pathname("/example")
|
653
|
+
|
654
|
+
# When path doesn't exist.
|
655
|
+
Pathname("/example.txt").delete # => Errno::ENOENT
|
656
|
+
----
|
657
|
+
|
643
658
|
===== #directories
|
644
659
|
|
645
660
|
Answers all directories or filtered directories for current path.
|
data/lib/refinements/arrays.rb
CHANGED
@@ -4,9 +4,12 @@ module Refinements
|
|
4
4
|
# Provides additional enhancements to the Array primitive.
|
5
5
|
module Arrays
|
6
6
|
refine Array do
|
7
|
-
def compress =
|
7
|
+
def compress = dup.compress!
|
8
8
|
|
9
|
-
def compress!
|
9
|
+
def compress!
|
10
|
+
compact!
|
11
|
+
delete_if { |element| element.respond_to?(:empty?) && element.empty? }
|
12
|
+
end
|
10
13
|
|
11
14
|
def excluding(*elements) = self - elements.flatten
|
12
15
|
|
data/lib/refinements/hashes.rb
CHANGED
data/lib/refinements/identity.rb
CHANGED
@@ -24,7 +24,7 @@ module Refinements
|
|
24
24
|
new(root).files(pattern).each { |path| require path.to_s }
|
25
25
|
end
|
26
26
|
|
27
|
-
def root = new(
|
27
|
+
def root = new(File::SEPARATOR)
|
28
28
|
end
|
29
29
|
|
30
30
|
refine Pathname do
|
@@ -38,6 +38,8 @@ module Refinements
|
|
38
38
|
self
|
39
39
|
end
|
40
40
|
|
41
|
+
def delete = super && self
|
42
|
+
|
41
43
|
def directories pattern = "*", flag: File::FNM_SYSCASE
|
42
44
|
glob(pattern, flag).select(&:directory?).sort
|
43
45
|
end
|
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: 8.
|
4
|
+
version: 8.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
28
28
|
lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
|
29
29
|
W2A=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2021-
|
31
|
+
date: 2021-10-03 00:00:00.000000000 Z
|
32
32
|
dependencies: []
|
33
33
|
description:
|
34
34
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|