refinements 9.0.1 → 9.0.2
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 +19 -18
- data/lib/refinements/identity.rb +1 -1
- data/lib/refinements/pathnames.rb +5 -1
- data/lib/refinements/structs.rb +6 -3
- 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: ad550aa0de5b7885133c4a146ff83f8df49184e10fdafc36c57a32511d4ca4e3
|
4
|
+
data.tar.gz: 52279fbf8e921a3500b5b341bd421b7827ad37f5f5cd0c0976042b33a2332885
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '095faf7714a553a86654fbb302ebaebe964ba8c291f5e6bf4dc010a2f96ae74ddf2b4bc2fd3a537eb4f76ae38d8bfdc1f06d9a70ac62b039d8437cdbe6fddd0d'
|
7
|
+
data.tar.gz: d642f75675fa88cf809ea086e4965b43d091c90ff75f11b0d5878ba2f4e900ef427c849b18345b6f1804729a91e20d805ce67223c334fe4af44f1c104b34026e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -11,12 +11,11 @@ image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchem
|
|
11
11
|
[link=https://circleci.com/gh/bkuhlmann/refinements]
|
12
12
|
image::https://circleci.com/gh/bkuhlmann/refinements.svg?style=svg[Circle CI Status]
|
13
13
|
|
14
|
-
Refinements are a collection
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
had!
|
14
|
+
Refinements are a collection primitive Ruby objects enhancements without needing to resort to hard
|
15
|
+
to debug link:https://www.alchemists.io/articles/ruby_antipatterns/#_monkey_patches[monkey patches].
|
16
|
+
These refinements give you additional syntactic sugar to develop clean and concise implementations
|
17
|
+
while using less code. By refining our code we can acquire the functionality we wish the core
|
18
|
+
primitives had!
|
20
19
|
|
21
20
|
toc::[]
|
22
21
|
|
@@ -148,7 +147,7 @@ Removes given array or elements without mutating itself.
|
|
148
147
|
|
149
148
|
===== #filter_find
|
150
149
|
|
151
|
-
Answers the first
|
150
|
+
Answers the first element which evaluates to true from a filtered collection.
|
152
151
|
|
153
152
|
[source,ruby]
|
154
153
|
----
|
@@ -349,7 +348,7 @@ example # {a: "A", b: {one: 1, two: "Two"}}
|
|
349
348
|
|
350
349
|
===== #deep_stringify_keys
|
351
350
|
|
352
|
-
|
351
|
+
Answers string keys of a nested hash without mutating itself. Does not handle nested arrays, though.
|
353
352
|
|
354
353
|
[source,ruby]
|
355
354
|
----
|
@@ -360,7 +359,7 @@ example # {a: {b: 2}}
|
|
360
359
|
|
361
360
|
===== #deep_stringify_keys!
|
362
361
|
|
363
|
-
|
362
|
+
Answers string keys of nested hash while mutating itself. Does not handle nested arrays, though.
|
364
363
|
|
365
364
|
[source,ruby]
|
366
365
|
----
|
@@ -827,14 +826,14 @@ parent_path = Pathname "/one"
|
|
827
826
|
child_path = parent_path.join "two"
|
828
827
|
|
829
828
|
child_path.make_path
|
830
|
-
|
829
|
+
parent_path.remove_tree # Pathname "/one"
|
831
830
|
child_path.exist? # false
|
832
|
-
|
831
|
+
parent_path.exist? # false
|
833
832
|
|
834
833
|
child_path.make_path
|
835
|
-
|
834
|
+
child_path.remove_tree # Pathname "/one/two"
|
836
835
|
child_path.exist? # false
|
837
|
-
parent_path.exist? #
|
836
|
+
parent_path.exist? # true
|
838
837
|
----
|
839
838
|
|
840
839
|
===== #rewrite
|
@@ -886,7 +885,7 @@ Answers `true`/`false` based on whether string is blank, `<space>`, `\n`, `\t`,
|
|
886
885
|
|
887
886
|
===== #camelcase
|
888
887
|
|
889
|
-
Answers a
|
888
|
+
Answers a camel cased string.
|
890
889
|
|
891
890
|
[source,ruby]
|
892
891
|
----
|
@@ -895,7 +894,7 @@ Answers a camelcased string.
|
|
895
894
|
|
896
895
|
===== #down
|
897
896
|
|
898
|
-
Answers string with only first letter
|
897
|
+
Answers string with only first letter down cased.
|
899
898
|
|
900
899
|
[source,ruby]
|
901
900
|
----
|
@@ -977,7 +976,7 @@ well in other languages.
|
|
977
976
|
|
978
977
|
===== #snakecase
|
979
978
|
|
980
|
-
Answers a
|
979
|
+
Answers a snake cased string.
|
981
980
|
|
982
981
|
[source,ruby]
|
983
982
|
----
|
@@ -986,7 +985,7 @@ Answers a snakecased string.
|
|
986
985
|
|
987
986
|
===== #titleize
|
988
987
|
|
989
|
-
Answers
|
988
|
+
Answers a title string with proper capitalization of each word.
|
990
989
|
|
991
990
|
[source,ruby]
|
992
991
|
----
|
@@ -1008,7 +1007,7 @@ Answers string as a boolean.
|
|
1008
1007
|
|
1009
1008
|
===== #up
|
1010
1009
|
|
1011
|
-
Answers string with only first letter
|
1010
|
+
Answers string with only first letter capitalized.
|
1012
1011
|
|
1013
1012
|
[source,ruby]
|
1014
1013
|
----
|
@@ -1038,6 +1037,8 @@ buffer # "This is a test."
|
|
1038
1037
|
|
1039
1038
|
===== .keyworded?
|
1040
1039
|
|
1040
|
+
⚠️ Will be removed in the next major version. Use `.keyword_init?` instead.
|
1041
|
+
|
1041
1042
|
Answers whether a struct was constructed with keyword or positional arguments.
|
1042
1043
|
|
1043
1044
|
[source,ruby]
|
data/lib/refinements/identity.rb
CHANGED
@@ -17,7 +17,11 @@ module Refinements
|
|
17
17
|
def home = new(ENV["HOME"])
|
18
18
|
|
19
19
|
def make_temp_dir prefix: "temp-", suffix: nil, root: nil
|
20
|
-
|
20
|
+
if block_given?
|
21
|
+
Dir.mktmpdir([prefix, suffix], root) { |path| yield new(path) }
|
22
|
+
else
|
23
|
+
new Dir.mktmpdir([prefix, suffix], root)
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
def require_tree root, pattern = "**/*.rb"
|
data/lib/refinements/structs.rb
CHANGED
@@ -4,11 +4,14 @@ module Refinements
|
|
4
4
|
# Provides additional enhancements to the Struct primitive.
|
5
5
|
module Structs
|
6
6
|
refine Struct.singleton_class do
|
7
|
-
def keyworded?
|
7
|
+
def keyworded?
|
8
|
+
warn "[DEPRECATION]: .keyworded? is deprecated, use .keyword_init? instead."
|
9
|
+
inspect.include?("keyword_init: true")
|
10
|
+
end
|
8
11
|
|
9
|
-
def with_keywords(**arguments) =
|
12
|
+
def with_keywords(**arguments) = keyword_init? ? new(**arguments) : new.merge!(**arguments)
|
10
13
|
|
11
|
-
def with_positions(*values) =
|
14
|
+
def with_positions(*values) = keyword_init? ? new(**members.zip(values).to_h) : new(*values)
|
12
15
|
end
|
13
16
|
|
14
17
|
refine Struct do
|
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.0.
|
4
|
+
version: 9.0.2
|
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: 2022-01-
|
31
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
32
32
|
dependencies: []
|
33
33
|
description:
|
34
34
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|