refinements 7.18.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5dd9bd6cbc9800c0c66d8c1ae4ed93124143f196a4173723438bb7d9fc12957e
4
- data.tar.gz: 9d6651c258900528aa68db2a8b26e1bd77aef9be70fe3fbeadf63e4c0580ab45
3
+ metadata.gz: 478c1dda3c9bffc07f29b8f69da33ed2c77f4d35ffbfffc006091087df483258
4
+ data.tar.gz: dc8e46e411df838fb1096093ea508283c0125f2ce98c4b5b66f30578ab3d0d03
5
5
  SHA512:
6
- metadata.gz: bad8de30ca4c07607013a08d8346d1390b3f6223b943588ac94ce1c7e44fb5f59ebb634c9adb4d0f1773929ede430ffc7025fa9e6fcdca6f055d3bfa4c5cbeb8
7
- data.tar.gz: d81030c3b1a8db17fff6cafea12496041d2cb95e87452cf932c7cf03c60dea4971f1bbce59c30fde5b5a8d80f713b5a00fca1cbcbba6bbb1962f77e21984f9b0
6
+ metadata.gz: 5a52d78821f3f0dd4a166b379c5e88fec11d043c31fc9b06f227735363b1d550c8acce79afaf1b6187c5a38305379ef035c11b388ae726d5d7a3f136e6c54903
7
+ data.tar.gz: efddacd66b51acf732c104f78ea90440b166b7208e87d11fb3d569c010ab222aac075fe0fa5516250d51c15e3066f6a36cc3c4796cdf88b1be4ec7a5ac3c4f55
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -22,7 +22,6 @@ Enhances the following objects:
22
22
  * Array
23
23
  * BigDecimal
24
24
  * DateTime
25
- * File
26
25
  * Hash
27
26
  * IO
28
27
  * Pathname
@@ -70,7 +69,6 @@ gem "refinements", require: false
70
69
  require "refinements/arrays"
71
70
  require "refinements/big_decimals"
72
71
  require "refinements/date_times"
73
- require "refinements/files"
74
72
  require "refinements/hashes"
75
73
  require "refinements/ios"
76
74
  require "refinements/pathnames"
@@ -90,7 +88,6 @@ class Example
90
88
  using Refinements::Arrays
91
89
  using Refinements::BigDecimals
92
90
  using Refinements::DateTimes
93
- using Refinements::Files
94
91
  using Refinements::Hashes
95
92
  using Refinements::IOs
96
93
  using Refinements::Pathnames
@@ -220,18 +217,6 @@ Answers new DateTime object for current UTC date/time.
220
217
  DateTime.utc # => #<DateTime: 2019-12-31T18:17:00+00:00 ((2458849j,65820s,181867000n),+0s,2299161j)>
221
218
  ----
222
219
 
223
- ==== File
224
-
225
- ===== .rewrite
226
-
227
- When given a file path and a block, it provides the contents of the recently read file for
228
- manipulation and immediate writing back to the same file.
229
-
230
- [source,ruby]
231
- ----
232
- File.rewrite("/test.txt") { |content| content.gsub "[placeholder]", "example" }
233
- ----
234
-
235
220
  ==== Hash
236
221
 
237
222
  ===== .infinite
@@ -324,28 +309,6 @@ example.deep_symbolize_keys! # => {a: {b: 1}}
324
309
  example # => {a: {b: 1}}
325
310
  ----
326
311
 
327
- ===== #except
328
-
329
- Answers new hash with given keys removed without mutating itself.
330
-
331
- [source,ruby]
332
- ----
333
- example = {a: 1, b: 2, c: 3}
334
- example.except :a, :b # => {c: 3}
335
- example # => {a: 1, b: 2, c: 3}
336
- ----
337
-
338
- ===== #except!
339
-
340
- Answers new hash with given keys removed while mutating itself.
341
-
342
- [source,ruby]
343
- ----
344
- example = {a: 1, b: 2, c: 3}
345
- example.except! :a, :b # => {c: 3}
346
- example # => {c: 3}
347
- ----
348
-
349
312
  ===== #flatten_keys
350
313
 
351
314
  Flattens nested keys as top-level keys without mutating itself. Does not handle nested arrays,
@@ -388,50 +351,6 @@ example.recurse(&:symbolize_keys) # => {a: {b: 1}}
388
351
  example.recurse(&:invert) # => {{"b" => 1} => "a"}
389
352
  ----
390
353
 
391
- ===== #rekey
392
-
393
- Transforms keys per mapping (size of mapping can vary) without mutating itself.
394
-
395
- [source,ruby]
396
- ----
397
- example = {a: 1, b: 2, c: 3}
398
- example.rekey a: :amber, b: :blue # => {amber: 1, blue: 2, c: 3}
399
- example # => {a: 1, b: 2, c: 3}
400
- ----
401
-
402
- ===== #rekey!
403
-
404
- Transforms keys per mapping (size of mapping can vary) while mutating itself.
405
-
406
- [source,ruby]
407
- ----
408
- example = {a: 1, b: 2, c: 3}
409
- example.rekey! a: :amber, b: :blue # => {amber: 1, blue: 2, c: 3}
410
- example # => {amber: 1, blue: 2, c: 3}
411
- ----
412
-
413
- ===== #reverse_merge
414
-
415
- Merges calling hash into passed in hash without mutating itself.
416
-
417
- [source,ruby]
418
- ----
419
- example = {a: 1, b: 2}
420
- example.reverse_merge a: 0, c: 3 # => {a: 1, b: 2, c: 3}
421
- example # => {a: 1, b: 2}
422
- ----
423
-
424
- ===== #reverse_merge!
425
-
426
- Merges calling hash into passed in hash while mutating itself.
427
-
428
- [source,ruby]
429
- ----
430
- example = {a: 1, b: 2}
431
- example.reverse_merge! a: 0, c: 3 # => {a: 1, b: 2, c: 3}
432
- example # => {a: 1, b: 2, c: 3}
433
- ----
434
-
435
354
  ===== #stringify_keys
436
355
 
437
356
  Converts keys to strings without mutating itself.
@@ -797,8 +716,8 @@ Updates access and modification times for path. Defaults to current time.
797
716
 
798
717
  [source,ruby]
799
718
  ----
800
- Pathname("example.txt").touch # => Pathname("example.txt")
801
- Pathname("example.txt").touch at: Time.now - 1 # => Pathname("example.txt")
719
+ Pathname("example.txt").touch # => Pathname("example.txt")
720
+ Pathname("example.txt").touch Time.now - 1 # => Pathname("example.txt")
802
721
  ----
803
722
 
804
723
  ===== #write
@@ -4,7 +4,6 @@ require "refinements/identity"
4
4
  require "refinements/arrays"
5
5
  require "refinements/big_decimals"
6
6
  require "refinements/date_times"
7
- require "refinements/files"
8
7
  require "refinements/hashes"
9
8
  require "refinements/ios"
10
9
  require "refinements/pathnames"
@@ -11,20 +11,10 @@ module Refinements
11
11
  replace compress
12
12
  end
13
13
 
14
- def exclude *elements
15
- warn "[DEPRECATION]: #exclude is deprecated, use #excluding instead."
16
- excluding(*elements)
17
- end
18
-
19
14
  def excluding *elements
20
15
  self - elements.flatten
21
16
  end
22
17
 
23
- def include *elements
24
- warn "[DEPRECATION]: #include is deprecated, use #including instead."
25
- including(*elements)
26
- end
27
-
28
18
  def including *elements
29
19
  self + elements.flatten
30
20
  end
@@ -45,14 +45,6 @@ module Refinements
45
45
  replace deep_symbolize_keys
46
46
  end
47
47
 
48
- def except *keys
49
- reject { |key, _value| keys.include? key }
50
- end
51
-
52
- def except! *keys
53
- replace except(*keys)
54
- end
55
-
56
48
  # :reek:TooManyStatements
57
49
  def flatten_keys prefix: nil, delimiter: "_", cast: :to_sym
58
50
  fail StandardError, "Unknown cast: #{cast}." unless %i[to_sym to_s].include? cast
@@ -82,26 +74,6 @@ module Refinements
82
74
  end
83
75
  end
84
76
 
85
- def rekey mapping = {}
86
- return self if mapping.empty?
87
-
88
- transform_keys { |key| mapping[key] || key }
89
- end
90
-
91
- def rekey! mapping = {}
92
- replace rekey(mapping)
93
- end
94
-
95
- def reverse_merge other
96
- warn "[DEPRECATION]: #reverse_merge is deprecated, use #merge instead."
97
- merge(other) { |_key, old_value, _new_value| old_value }
98
- end
99
-
100
- def reverse_merge! other
101
- warn "[DEPRECATION]: #reverse_merge! is deprecated, use #merge! instead."
102
- replace reverse_merge(other)
103
- end
104
-
105
77
  def stringify_keys
106
78
  reduce({}) { |hash, (key, value)| hash.merge key.to_s => value }
107
79
  end
@@ -5,7 +5,7 @@ module Refinements
5
5
  module Identity
6
6
  NAME = "refinements"
7
7
  LABEL = "Refinements"
8
- VERSION = "7.18.0"
8
+ VERSION = "8.0.0"
9
9
  VERSION_LABEL = "#{LABEL} #{VERSION}"
10
10
  end
11
11
  end
@@ -71,10 +71,6 @@ module Refinements
71
71
  self
72
72
  end
73
73
 
74
- def mkdir
75
- exist? ? self : super and self
76
- end
77
-
78
74
  def name
79
75
  basename extname
80
76
  end
@@ -102,7 +98,7 @@ module Refinements
102
98
  read.then { |content| write yield(content) if block_given? }
103
99
  end
104
100
 
105
- def touch at: Time.now
101
+ def touch at = Time.now
106
102
  exist? ? utime(at, at) : write("")
107
103
  self
108
104
  end
@@ -2,14 +2,7 @@
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
-
7
- refine String.singleton_class do
8
- def delimiters
9
- warn "[DEPRECATION]: .delimiters is deprecated, use DELIMITERS instead."
10
- DELIMITERS
11
- end
12
- end
5
+ DELIMITERS = %r([a-z][A-Z]|\s*-\s*|\s*/\s*|\s*:+\s*|\s*_\s*|\s+)
13
6
 
14
7
  refine String do
15
8
  def blank?
@@ -7,8 +7,8 @@ module Refinements
7
7
  inspect.include? "keyword_init: true"
8
8
  end
9
9
 
10
- def with_keywords arguments
11
- keyworded? ? new(arguments) : new.merge!(arguments)
10
+ def with_keywords **arguments
11
+ keyworded? ? new(**arguments) : new.merge!(**arguments)
12
12
  end
13
13
 
14
14
  def with_positions *values
@@ -18,11 +18,11 @@ module Refinements
18
18
 
19
19
  refine Struct do
20
20
  def merge **attributes
21
- dup.merge! attributes
21
+ dup.merge!(**attributes)
22
22
  end
23
23
 
24
24
  def merge! **attributes
25
- to_h.merge(attributes).each { |key, value| self[key] = value }
25
+ to_h.merge(**attributes).each { |key, value| self[key] = value }
26
26
  self
27
27
  end
28
28
 
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: 7.18.0
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
29
29
  QWc=
30
30
  -----END CERTIFICATE-----
31
- date: 2020-12-21 00:00:00.000000000 Z
31
+ date: 2020-12-29 00:00:00.000000000 Z
32
32
  dependencies: []
33
33
  description:
34
34
  email:
@@ -45,7 +45,6 @@ files:
45
45
  - lib/refinements/arrays.rb
46
46
  - lib/refinements/big_decimals.rb
47
47
  - lib/refinements/date_times.rb
48
- - lib/refinements/files.rb
49
48
  - lib/refinements/hashes.rb
50
49
  - lib/refinements/identity.rb
51
50
  - lib/refinements/ios.rb
@@ -69,14 +68,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
68
  requirements:
70
69
  - - "~>"
71
70
  - !ruby/object:Gem::Version
72
- version: '2.7'
71
+ version: '3.0'
73
72
  required_rubygems_version: !ruby/object:Gem::Requirement
74
73
  requirements:
75
74
  - - ">="
76
75
  - !ruby/object:Gem::Version
77
76
  version: '0'
78
77
  requirements: []
79
- rubygems_version: 3.2.2
78
+ rubygems_version: 3.2.3
80
79
  signing_key:
81
80
  specification_version: 4
82
81
  summary: A collection of refinements to core Ruby objects.
metadata.gz.sig CHANGED
Binary file
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Refinements
4
- module Files
5
- refine File.singleton_class do
6
- def rewrite path
7
- warn "[DEPRECATION]: File.rewrite is deprecated, use Pathname#rewrite instead."
8
- read(path).then { |content| write path, yield(content) }
9
- end
10
- end
11
- end
12
- end