refinements 6.2.2 → 6.3.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/README.md +21 -4
- data/lib/refinements/files.rb +11 -0
- data/lib/refinements/identity.rb +1 -1
- data/lib/refinements/pathnames.rb +13 -0
- data/lib/refinements.rb +3 -1
- data.tar.gz.sig +0 -0
- metadata +7 -5
- 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: b1ea3f558caa4371babea8a3cf9653d95a785575456cc6be4b043f5811984c49
|
4
|
+
data.tar.gz: cf99c530f40b36cc5f14143e75cb781d75bd7d3c8e79387e5ea76c89c95bb48d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3074e9fbfeb98ca10cbed67f38bb7daf103898e570884f49eee277337799b165058dfff0210bcb87d5472193f4b02cd39d0dc10211ab492c94b5d7ac3d73d966
|
7
|
+
data.tar.gz: 70aec9d111a40cd8d0d965de5f6b43f7482210b1101b678785b14635145ebc587ed4789dad04053092a9bd134ea2834873b4da8f5ec9cc52db46687549f5a691
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -24,7 +24,9 @@ Provides additional enhancements (refinements) to core Ruby objects.
|
|
24
24
|
- [Examples](#examples)
|
25
25
|
- [Array](#array)
|
26
26
|
- [Big Decimal](#big-decimal)
|
27
|
+
- [File](#file)
|
27
28
|
- [Hash](#hash)
|
29
|
+
- [Pathname](#pathname)
|
28
30
|
- [String](#string)
|
29
31
|
- [Tests](#tests)
|
30
32
|
- [Versioning](#versioning)
|
@@ -43,6 +45,9 @@ Provides additional enhancements (refinements) to core Ruby objects.
|
|
43
45
|
- `#compress!` - Removes `nil` and empty values while modifying itself.
|
44
46
|
- Provides BigDecimal refinements:
|
45
47
|
- `#inspect` - Allows one to inspect a big decimal with numeric representation.
|
48
|
+
- Provides File refinements:
|
49
|
+
- `.rewrite` - When given a file path and a block, it provides the contents of the recently read
|
50
|
+
file for manipulation and immediate writing back to the same file.
|
46
51
|
- Provides Hash refinements:
|
47
52
|
- `#except` - Answers new hash with given keys removed without modifying calling hash.
|
48
53
|
- `#except!` - Answers new hash with given keys removed while modifying calling hash.
|
@@ -52,6 +57,9 @@ Provides additional enhancements (refinements) to core Ruby objects.
|
|
52
57
|
- `#deep_merge!` - Merges deeply nested hashes together while modifying itself.
|
53
58
|
- `#reverse_merge` - Merges calling hash into passed in hash without modifying calling hash.
|
54
59
|
- `#reverse_merge!` - Merges calling hash into passed in hash while modifying calling hash.
|
60
|
+
- Provides Pathname refinements:
|
61
|
+
- `#rewrite` - When given a block, it provides the contents of the recently read file for
|
62
|
+
manipulation and immediate writing back to the same file.
|
55
63
|
- Provides String refinements:
|
56
64
|
- `#first` - Answers first character of a string or first set of characters if given a number.
|
57
65
|
- `#last` - Answers last character of a string or last set of characters if given a number.
|
@@ -92,8 +100,9 @@ If all refinements are not desired, add the following to your `Gemfile` instead:
|
|
92
100
|
|
93
101
|
require "refinements/arrays"
|
94
102
|
require "refinements/big_decimals"
|
103
|
+
require "refinements/files"
|
95
104
|
require "refinements/hashes"
|
96
|
-
require "refinements/
|
105
|
+
require "refinements/pathnames"
|
97
106
|
require "refinements/strings"
|
98
107
|
|
99
108
|
### Using
|
@@ -103,8 +112,9 @@ Much like including/extending a module, you'll need modify your object(s) to use
|
|
103
112
|
class Example
|
104
113
|
using Refinements::Arrays
|
105
114
|
using Refinements::BigDecimals
|
115
|
+
using Refinements::Files
|
106
116
|
using Refinements::Hashes
|
107
|
-
using Refinements::
|
117
|
+
using Refinements::Pathnames
|
108
118
|
using Refinements::Strings
|
109
119
|
end
|
110
120
|
|
@@ -124,8 +134,11 @@ The following sections demonstrate how each refinement enriches your objects wit
|
|
124
134
|
|
125
135
|
#### Big Decimal
|
126
136
|
|
127
|
-
|
128
|
-
|
137
|
+
BigDecimal.new("5.0E-10").inspect # => "#<BigDecimal:3fd3d458fe84 0.0000000005>"
|
138
|
+
|
139
|
+
#### File
|
140
|
+
|
141
|
+
File.rewrite("/test.txt") { |content| content.gsub "[placeholder]", "example" }
|
129
142
|
|
130
143
|
#### Hash
|
131
144
|
|
@@ -172,6 +185,10 @@ The following sections demonstrate how each refinement enriches your objects wit
|
|
172
185
|
example = {unit: "221B", street: "Baker Street", city: "London", country: "UK"}
|
173
186
|
example.use { |unit, street| "#{unit} #{street}" } # => "221B Baker Street"
|
174
187
|
|
188
|
+
#### Pathname
|
189
|
+
|
190
|
+
Pathname("/test.txt").rewrite { |content| content.sub "[placeholder]", "example" }
|
191
|
+
|
175
192
|
#### String
|
176
193
|
|
177
194
|
"example".first # => "e"
|
data/lib/refinements/identity.rb
CHANGED
data/lib/refinements.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "refinements/identity"
|
3
4
|
require "refinements/arrays"
|
4
5
|
require "refinements/big_decimals"
|
6
|
+
require "refinements/files"
|
5
7
|
require "refinements/hashes"
|
6
|
-
require "refinements/
|
8
|
+
require "refinements/pathnames"
|
7
9
|
require "refinements/strings"
|
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: 6.
|
4
|
+
version: 6.3.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: 2019-
|
31
|
+
date: 2019-07-07 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: awesome_print
|
@@ -218,14 +218,14 @@ dependencies:
|
|
218
218
|
requirements:
|
219
219
|
- - "~>"
|
220
220
|
- !ruby/object:Gem::Version
|
221
|
-
version: '1.
|
221
|
+
version: '1.4'
|
222
222
|
type: :development
|
223
223
|
prerelease: false
|
224
224
|
version_requirements: !ruby/object:Gem::Requirement
|
225
225
|
requirements:
|
226
226
|
- - "~>"
|
227
227
|
- !ruby/object:Gem::Version
|
228
|
-
version: '1.
|
228
|
+
version: '1.4'
|
229
229
|
- !ruby/object:Gem::Dependency
|
230
230
|
name: rubocop-rspec
|
231
231
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,8 +282,10 @@ files:
|
|
282
282
|
- lib/refinements.rb
|
283
283
|
- lib/refinements/arrays.rb
|
284
284
|
- lib/refinements/big_decimals.rb
|
285
|
+
- lib/refinements/files.rb
|
285
286
|
- lib/refinements/hashes.rb
|
286
287
|
- lib/refinements/identity.rb
|
288
|
+
- lib/refinements/pathnames.rb
|
287
289
|
- lib/refinements/strings.rb
|
288
290
|
homepage: https://github.com/bkuhlmann/refinements
|
289
291
|
licenses:
|
@@ -307,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
307
309
|
- !ruby/object:Gem::Version
|
308
310
|
version: '0'
|
309
311
|
requirements: []
|
310
|
-
rubygems_version: 3.0.
|
312
|
+
rubygems_version: 3.0.4
|
311
313
|
signing_key:
|
312
314
|
specification_version: 4
|
313
315
|
summary: Provides additional enhancements (refinements) to core Ruby objects.
|
metadata.gz.sig
CHANGED
Binary file
|