refinements 7.0.0 → 7.1.0
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.tar.gz.sig +2 -3
- data/README.md +13 -2
- data/lib/refinements/identity.rb +1 -1
- data/lib/refinements/pathnames.rb +17 -1
- metadata +36 -8
- 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: 33305a79040d956270249e8e69d221e18144754a754c768a4c5dbd46f52672aa
|
4
|
+
data.tar.gz: c8d64fe7e0be077ae13e3dda3bf65baa0b4f0bd5690d30ff4fc5cf75df08772b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc20aa5a6d29ddf5d184d54054e76ba44f1b0b092fecb67b98c8ba4bbe53ee3004f9e7418feeadce99243367070791a2c6064b4667b306cfbf8f4c40421e5e27
|
7
|
+
data.tar.gz: ed26803b0ed30ea0fc82cf89781c15604946db6ad0826b3a452b51b97f9b868dabc1d9b547a32385b5dcf7bc03a3269e999654ba30dd9d350696b188bdbb09c5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
�
|
2
|
-
|
3
|
-
���$�m���C��AZ²��<��I�l�W�}��D�������2���٘ƿ̶g:i�{0uU�)�����!+�$�7��.-6��[�L�W�>����h u�*X�����(�)"���99E3)�-=�w=.��t@}��Td���_�Ut���4;W����Qp�L'
|
1
|
+
L��S,-������7�Ͻ��I�����AE�Jr�`�(j:û�"Q�PU�#���[��h~����M}���q�f�]�7H�$��vqZӳ���.�����B��as���>�����
|
2
|
+
/K��ɿ�^j���$h����k&�������Q@���d�t6N�.�X�c��K�G�Eq�Zs5���8�����$Z��Vl�B�|S��"��o� E��Q�̷�n|��%]�U����I�=3)�ajJ��>�x�
|
data/README.md
CHANGED
@@ -49,8 +49,12 @@ A collection of refinements (enhancements) to core Ruby objects.
|
|
49
49
|
- Provides BigDecimal refinements:
|
50
50
|
- `#inspect` - Allows one to inspect a big decimal with numeric representation.
|
51
51
|
- Provides File refinements:
|
52
|
-
-
|
52
|
+
- `#name` - Answers the *name* of file without extension.
|
53
|
+
- `#copy` - Copies an existing file to new file. Both directory structures must exist.
|
54
|
+
- `#rewrite` - When given a file path and a block, it provides the contents of the recently read
|
53
55
|
file for manipulation and immediate writing back to the same file.
|
56
|
+
- `#touch` - Updates the access and modified times of an existing file or creates the file when
|
57
|
+
not existing.
|
54
58
|
- Provides Hash refinements:
|
55
59
|
- `#except` - Answers new hash with given keys removed without modifying calling hash.
|
56
60
|
- `#except!` - Answers new hash with given keys removed while modifying calling hash.
|
@@ -78,7 +82,7 @@ A collection of refinements (enhancements) to core Ruby objects.
|
|
78
82
|
|
79
83
|
## Requirements
|
80
84
|
|
81
|
-
1. [Ruby 2.
|
85
|
+
1. [Ruby 2.7.x](https://www.ruby-lang.org).
|
82
86
|
1. A solid understanding of [Ruby refinements and lexical scope](https://www.youtube.com/watch?v=qXC9Gk4dCEw).
|
83
87
|
|
84
88
|
## Setup
|
@@ -196,8 +200,15 @@ The following sections demonstrate how each refinement enriches your objects wit
|
|
196
200
|
|
197
201
|
#### Pathname
|
198
202
|
|
203
|
+
Pathname("test.txt").name # => Pathname("test")
|
204
|
+
|
205
|
+
Pathname("input.txt").copy Pathname("output.txt")
|
206
|
+
|
199
207
|
Pathname("/test.txt").rewrite { |content| content.sub "[placeholder]", "example" }
|
200
208
|
|
209
|
+
Pathname("test.txt").touch
|
210
|
+
Pathname("test.txt").touch accessed_at: Time.now - 1, modified_at: Time.now - 1
|
211
|
+
|
201
212
|
#### String
|
202
213
|
|
203
214
|
"example".first # => "e"
|
data/lib/refinements/identity.rb
CHANGED
@@ -5,8 +5,24 @@ require "pathname"
|
|
5
5
|
module Refinements
|
6
6
|
module Pathnames
|
7
7
|
refine Pathname do
|
8
|
+
def name
|
9
|
+
basename extname
|
10
|
+
end
|
11
|
+
|
12
|
+
def copy to
|
13
|
+
destination = to.directory? ? to.join(basename) : to
|
14
|
+
read.then { |content| destination.write content }
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
8
18
|
def rewrite
|
9
|
-
read.then { |content| write yield(content) }
|
19
|
+
read.then { |content| write yield(content) if block_given? }
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def touch at: Time.now
|
24
|
+
exist? ? utime(at, at) : write("")
|
25
|
+
self
|
10
26
|
end
|
11
27
|
end
|
12
28
|
end
|
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.
|
4
|
+
version: 7.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
28
28
|
dKvURM+1PwDCzC5tvRwjhUJIizau6+MtkFCvJHmaAj1aZL3odcPejHj5Hxt/0CUW
|
29
29
|
y84=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2020-01-
|
31
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler-audit
|
@@ -44,6 +44,34 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0.6'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: gemsmith
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '14.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '14.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: git-cop
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '4.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '4.0'
|
47
75
|
- !ruby/object:Gem::Dependency
|
48
76
|
name: guard-rspec
|
49
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,14 +134,14 @@ dependencies:
|
|
106
134
|
requirements:
|
107
135
|
- - "~>"
|
108
136
|
- !ruby/object:Gem::Version
|
109
|
-
version: '5.
|
137
|
+
version: '5.6'
|
110
138
|
type: :development
|
111
139
|
prerelease: false
|
112
140
|
version_requirements: !ruby/object:Gem::Requirement
|
113
141
|
requirements:
|
114
142
|
- - "~>"
|
115
143
|
- !ruby/object:Gem::Version
|
116
|
-
version: '5.
|
144
|
+
version: '5.6'
|
117
145
|
- !ruby/object:Gem::Dependency
|
118
146
|
name: rspec
|
119
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,14 +162,14 @@ dependencies:
|
|
134
162
|
requirements:
|
135
163
|
- - "~>"
|
136
164
|
- !ruby/object:Gem::Version
|
137
|
-
version: '0.
|
165
|
+
version: '0.79'
|
138
166
|
type: :development
|
139
167
|
prerelease: false
|
140
168
|
version_requirements: !ruby/object:Gem::Requirement
|
141
169
|
requirements:
|
142
170
|
- - "~>"
|
143
171
|
- !ruby/object:Gem::Version
|
144
|
-
version: '0.
|
172
|
+
version: '0.79'
|
145
173
|
- !ruby/object:Gem::Dependency
|
146
174
|
name: rubocop-performance
|
147
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,14 +218,14 @@ dependencies:
|
|
190
218
|
requirements:
|
191
219
|
- - "~>"
|
192
220
|
- !ruby/object:Gem::Version
|
193
|
-
version: '0.
|
221
|
+
version: '0.18'
|
194
222
|
type: :development
|
195
223
|
prerelease: false
|
196
224
|
version_requirements: !ruby/object:Gem::Requirement
|
197
225
|
requirements:
|
198
226
|
- - "~>"
|
199
227
|
- !ruby/object:Gem::Version
|
200
|
-
version: '0.
|
228
|
+
version: '0.18'
|
201
229
|
description:
|
202
230
|
email:
|
203
231
|
- brooke@alchemists.io
|
metadata.gz.sig
CHANGED
Binary file
|