refinements 7.2.0 → 7.3.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: ad5be980b8f793ae3267c3903932b56af4d7e0f4e85868086015f7f44209e6e6
4
- data.tar.gz: 21fd8437f771085190de49af6f46e08ba3cc1cdd6844649d8e63cde20549b9f4
3
+ metadata.gz: 07f6d846bc9cd533e7c5b7fae5eb8c5e9fbe9d496f5abe6c32443e49d1e4c74b
4
+ data.tar.gz: f5c01757545c4fb8f11f5485695ec4ecdaa5061966945161e8bdb7c53cfe5d19
5
5
  SHA512:
6
- metadata.gz: 0a37bebc4c4ef4f6e0b503601f2728eee8f04c9bcde3b714e9332dac343b62f4281dc4924b178c24a011c2e6ddfcb963e479aab6b0f070fc4bd898a99f98824a
7
- data.tar.gz: c33d3b26f9b7c19ec977a36c1904faa888f00884921abad97ac4ca76e14772fda5b87cc2455d46e8c114f4392604f216ff90e06a3648be7c00fa268b77697c44
6
+ metadata.gz: 2787e284a26eb3e5db5cd3c33024163440220c1fba90a81c887b166eadf6b54ab73b5f369b3b1a03042a65abcbd886a093ff304a240315a14ec58e3ab1cd83a3
7
+ data.tar.gz: 6838f0cc48d65154bcb0761c4446bea18447a7571ec6a0836b58cff7c259f97365162bd636310a82fe6d1a9b8625edbb7cdba99521115ccee0c0059ba23c21cb
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1,3 @@
1
- �5(�� r��MC��ZdeM�ibhE�uRz������:~h(�>�gl��u+6��%гoA�;�@ ��3�|y�m�n�#��R�p���A��ދ�� >���������o���CH�s�c<�k�.z�[;j�9���:`ٱw��)*��,���5�+鐓�l�2��&*#bᣕ��Kl%��*b�q�ً̘5����x<�U �+&XLϝ�U�a��9��-fz˼���-�@1gݴ��h]����AἍ�Z1)��
1
+ r�͚
2
+ ��~3C��mr���T������S�V�5���~�8K^�C ��.��2XYQ�N�Q�{%��+�fa*�
3
+ ����6�5k�IB�e�N ?������mE�Q�o���ˉ��[�5���bf�&�I�ٛ�p9I �'T�6����)��Œws��,��,p�R^��^�̿��QEO����8
@@ -19,17 +19,13 @@ 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
30
  ** `#except` - Answers new hash with given keys removed without modifying calling hash.
35
31
  ** `#except!` - Answers new hash with given keys removed while modifying calling hash.
@@ -39,9 +35,17 @@ not existing.
39
35
  ** `#deep_merge!` - Merges deeply nested hashes together while modifying itself.
40
36
  ** `#reverse_merge` - Merges calling hash into passed in hash without modifying calling hash.
41
37
  ** `#reverse_merge!` - Merges calling hash into passed in hash while modifying calling hash.
38
+ ** `#use` - Passes each hash value as a block argument for further processing.
42
39
  * *Pathnames*:
40
+ ** `#name` - Answers file name without extension.
41
+ ** `#copy` - Copies file from current location to new location.
42
+ ** `#extensions` - Answers file extensions as an array.
43
+ ** `#relative_parent_from` - Answers relative path from parent directory. This is a complement to
44
+ `#relative_path_from`.
45
+ ** `#make_ancestors` - Ensures all ancestor directories are created for a path.
43
46
  ** `#rewrite` - When given a block, it provides the contents of the recently read file for
44
47
  manipulation and immediate writing back to the same file.
48
+ ** `#touch` - Updates access and modification times to current time for path.
45
49
  * *Strings*:
46
50
  ** `#first` - Answers first character of a string or first set of characters if given a number.
47
51
  ** `#last` - Answers last character of a string or last set of characters if given a number.
@@ -49,11 +53,9 @@ manipulation and immediate writing back to the same file.
49
53
  (i.e. `<space>`, `\n`, `\t`, `\r`).
50
54
  ** `#up` - Answers string with only first letter upcased.
51
55
  ** `#down` - Answers string with only first letter downcased.
52
- ** `#camelcase` - Answers a camelcased string. Example: "`ThisIsCamelcase`".
53
- ** `#snakecase` - Answers a snakecased string. Example: "`this_is_snakecase`".
54
- ** `#titleize` - Answers titleized string. Example: "`This Is Titleized`".
55
- ** `#use` - Provides hash value computation, via a block, by using only the keys as arguments to
56
- the block.
56
+ ** `#camelcase` - Answers a camelcased string.
57
+ ** `#snakecase` - Answers a snakecased string.
58
+ ** `#titleize` - Answers titleized string.
57
59
 
58
60
  == Requirements
59
61
 
@@ -113,8 +115,8 @@ gem "refinements", require: false
113
115
  [source,ruby]
114
116
  ----
115
117
  require "refinements/arrays"
116
- require "refinements/date_times"
117
118
  require "refinements/big_decimals"
119
+ require "refinements/date_times"
118
120
  require "refinements/files"
119
121
  require "refinements/hashes"
120
122
  require "refinements/pathnames"
@@ -129,8 +131,8 @@ Much like including/extending a module, you’ll need modify your object(s) to u
129
131
  ----
130
132
  class Example
131
133
  using Refinements::Arrays
132
- using Refinements::DateTimes
133
134
  using Refinements::BigDecimals
135
+ using Refinements::DateTimes
134
136
  using Refinements::Files
135
137
  using Refinements::Hashes
136
138
  using Refinements::Pathnames
@@ -162,18 +164,18 @@ example.ring { |(before, current, after)| puts "#{before} #{current} #{after}" }
162
164
  # [2 3 1]
163
165
  ----
164
166
 
165
- ==== DateTime
167
+ ==== Big Decimal
166
168
 
167
169
  [source,ruby]
168
170
  ----
169
- DateTime.utc # => #<DateTime: 2019-12-31T18:17:00+00:00 ((2458849j,65820s,181867000n),+0s,2299161j)>
171
+ BigDecimal.new("5.0E-10").inspect # => "#<BigDecimal:3fd3d458fe84 0.0000000005>"
170
172
  ----
171
173
 
172
- ==== Big Decimal
174
+ ==== DateTime
173
175
 
174
176
  [source,ruby]
175
177
  ----
176
- BigDecimal.new("5.0E-10").inspect # => "#<BigDecimal:3fd3d458fe84 0.0000000005>"
178
+ DateTime.utc # => #<DateTime: 2019-12-31T18:17:00+00:00 ((2458849j,65820s,181867000n),+0s,2299161j)>
177
179
  ----
178
180
 
179
181
  ==== File
@@ -235,14 +237,22 @@ example.use { |unit, street| "#{unit} #{street}" } # => "221B Baker Street"
235
237
 
236
238
  [source,ruby]
237
239
  ----
238
- Pathname("test.txt").name # => Pathname("test")
240
+ Pathname("example.txt").name # => Pathname("example")
239
241
 
240
242
  Pathname("input.txt").copy Pathname("output.txt")
241
243
 
244
+ Pathname("example.txt.erb").extensions # => [".txt", ".erb"]
245
+
246
+ Pathname("/one/two/three").relative_parent_from("/one") # => Pathname "two"
247
+
248
+ Pathname("/one/two").make_ancestors
249
+ Pathname("/one").exist? # => true
250
+ Pathname("/one/two").exist? # => false
251
+
242
252
  Pathname("/test.txt").rewrite { |content| content.sub "[placeholder]", "example" }
243
253
 
244
- Pathname("test.txt").touch
245
- Pathname("test.txt").touch accessed_at: Time.now - 1, modified_at: Time.now - 1
254
+ Pathname("example.txt").touch
255
+ Pathname("example.txt").touch accessed_at: Time.now - 1, modified_at: Time.now - 1
246
256
  ----
247
257
 
248
258
  ==== String
@@ -299,4 +309,4 @@ Read link:CHANGES.adoc[CHANGES] for details.
299
309
 
300
310
  == Credits
301
311
 
302
- Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann.html[Brooke Kuhlmann].
312
+ Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
@@ -2,8 +2,8 @@
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"
@@ -5,7 +5,7 @@ module Refinements
5
5
  module Identity
6
6
  NAME = "refinements"
7
7
  LABEL = "Refinements"
8
- VERSION = "7.2.0"
8
+ VERSION = "7.3.0"
9
9
  VERSION_LABEL = "#{LABEL} #{VERSION}"
10
10
  end
11
11
  end
@@ -15,6 +15,19 @@ module Refinements
15
15
  self
16
16
  end
17
17
 
18
+ def extensions
19
+ basename.to_s.split(/(?=\.)+/).tap(&:shift)
20
+ end
21
+
22
+ def relative_parent_from root
23
+ relative_path_from(root).parent
24
+ end
25
+
26
+ def make_ancestors
27
+ dirname.mkpath
28
+ self
29
+ end
30
+
18
31
  def rewrite
19
32
  read.then { |content| write yield(content) if block_given? }
20
33
  self
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.2.0
4
+ version: 7.3.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-04-01 00:00:00.000000000 Z
31
+ date: 2020-05-13 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler-audit
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '0.12'
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.12'
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.7'
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.7'
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.79'
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.79'
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.37'
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.37'
214
+ version: '1.39'
215
215
  - !ruby/object:Gem::Dependency
216
216
  name: simplecov
217
217
  requirement: !ruby/object:Gem::Requirement
@@ -269,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
269
  - !ruby/object:Gem::Version
270
270
  version: '0'
271
271
  requirements: []
272
- rubygems_version: 3.1.2
272
+ rubygems_version: 3.1.3
273
273
  signing_key:
274
274
  specification_version: 4
275
275
  summary: A collection of refinements to core Ruby objects.
metadata.gz.sig CHANGED
Binary file