lite-ruby 1.1.8 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +8 -8
- data/docs/ARRAY.md +11 -1
- data/docs/ENUMERABLE.md +13 -0
- data/lib/lite/ruby/array.rb +6 -2
- data/lib/lite/ruby/enumerable.rb +2 -2
- data/lib/lite/ruby/hash.rb +2 -2
- data/lib/lite/ruby/object.rb +2 -2
- data/lib/lite/ruby/range.rb +2 -2
- data/lib/lite/ruby/safe/array.rb +3 -0
- data/lib/lite/ruby/safe/enumerable.rb +12 -1
- data/lib/lite/ruby/string.rb +2 -2
- data/lib/lite/ruby/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b32c7f149936f48b462434da3dd84d20667a9bbe0771fd284df29b8d515a8339
|
4
|
+
data.tar.gz: a220ce1b98faa3487d4a6fead4eaf9a7dccf00b6c480d2657e94f3e449bd5884
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e878a158ba8b9118ee0ad83aee4538b55ab70a379bc288c4985f3243901d4a4b3b481669fbff8dfde32b262f53294f0ecd35061a201acc50e64e73b5eabf8fa
|
7
|
+
data.tar.gz: e51ce8fa082348bca0020a6190d72b8845944f01e230ba5f6c67c6f405f6311c0ca002d02fee9c93037c11d4e762c1d1b6df164c3ab7b35a3bd573dd09926932
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.1.9] - 2021-05-26
|
10
|
+
### Added
|
11
|
+
- Added Array => `match`
|
12
|
+
- Added Array => `strip` to `compact_blank` alias
|
13
|
+
- Added Enumerable => `pick`
|
14
|
+
### Changed
|
15
|
+
- Move safe requires to bottom of file
|
16
|
+
|
9
17
|
## [1.1.8] - 2021-07-05
|
10
18
|
### Changed
|
11
19
|
- Linter fixes
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lite-ruby (1.1.
|
4
|
+
lite-ruby (1.1.9)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -46,7 +46,7 @@ GEM
|
|
46
46
|
method_source (1.0.0)
|
47
47
|
mini_portile2 (2.5.1)
|
48
48
|
minitest (5.14.4)
|
49
|
-
nokogiri (1.11.
|
49
|
+
nokogiri (1.11.6)
|
50
50
|
mini_portile2 (~> 2.5.0)
|
51
51
|
racc (~> 1.4)
|
52
52
|
parallel (1.20.1)
|
@@ -84,7 +84,7 @@ GEM
|
|
84
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
85
85
|
rspec-support (~> 3.10.0)
|
86
86
|
rspec-support (3.10.2)
|
87
|
-
rubocop (1.
|
87
|
+
rubocop (1.15.0)
|
88
88
|
parallel (~> 1.10)
|
89
89
|
parser (>= 3.0.0.0)
|
90
90
|
rainbow (>= 2.2.2, < 4.0)
|
@@ -93,7 +93,7 @@ GEM
|
|
93
93
|
rubocop-ast (>= 1.5.0, < 2.0)
|
94
94
|
ruby-progressbar (~> 1.7)
|
95
95
|
unicode-display_width (>= 1.4.0, < 3.0)
|
96
|
-
rubocop-ast (1.
|
96
|
+
rubocop-ast (1.6.0)
|
97
97
|
parser (>= 3.0.1.1)
|
98
98
|
rubocop-performance (1.11.3)
|
99
99
|
rubocop (>= 1.7.0, < 2.0)
|
@@ -104,9 +104,9 @@ GEM
|
|
104
104
|
rubocop (~> 1.0)
|
105
105
|
rubocop-ast (>= 1.1.0)
|
106
106
|
ruby-progressbar (1.11.0)
|
107
|
-
ruby_parser (3.
|
108
|
-
sexp_processor (~> 4.
|
109
|
-
sexp_processor (4.15.
|
107
|
+
ruby_parser (3.16.0)
|
108
|
+
sexp_processor (~> 4.15, >= 4.15.1)
|
109
|
+
sexp_processor (4.15.3)
|
110
110
|
thor (1.1.0)
|
111
111
|
tzinfo (2.0.4)
|
112
112
|
concurrent-ruby (~> 1.0)
|
@@ -129,4 +129,4 @@ DEPENDENCIES
|
|
129
129
|
rubocop-rspec
|
130
130
|
|
131
131
|
BUNDLED WITH
|
132
|
-
2.2.
|
132
|
+
2.2.18
|
data/docs/ARRAY.md
CHANGED
@@ -235,6 +235,15 @@ Returns all indexes of the matching value.
|
|
235
235
|
[:a,:b,:a,:c].indexes(:a) #=> [0, 2]
|
236
236
|
```
|
237
237
|
|
238
|
+
`match`
|
239
|
+
------
|
240
|
+
Select a given value from the array.
|
241
|
+
|
242
|
+
```ruby
|
243
|
+
[1, 2, 3, 4].match(1) #=> 1
|
244
|
+
[1, 2, 3, 4].match(9) #=> nil
|
245
|
+
```
|
246
|
+
|
238
247
|
`merge(!)`
|
239
248
|
------
|
240
249
|
Concats multiple arrays.
|
@@ -259,6 +268,7 @@ Selects given values from the array.
|
|
259
268
|
|
260
269
|
```ruby
|
261
270
|
[1, 2, 3, 4].only(1, 3) #=> [1, 3]
|
271
|
+
[1, 2, 3, 4].only!(8, 9) #=> []
|
262
272
|
```
|
263
273
|
|
264
274
|
`probability`
|
@@ -328,7 +338,7 @@ Divides the array into one or more subarrays based on a delimiting value or the
|
|
328
338
|
(1..10).to_a.split { |i| i % 3 == 0 } # => [[1, 2], [4, 5], [7, 8], [10]]
|
329
339
|
```
|
330
340
|
|
331
|
-
`strip(!)`
|
341
|
+
`strip(!)` aka `compact_blank(!)`
|
332
342
|
------
|
333
343
|
Removes blank elements from an array.
|
334
344
|
|
data/docs/ENUMERABLE.md
CHANGED
@@ -158,6 +158,18 @@ a1.occur(2..3) #=> [1,3,5]
|
|
158
158
|
a1.occur { |n| n > 1 } #=> [1,3,5]
|
159
159
|
```
|
160
160
|
|
161
|
+
`pick`
|
162
|
+
------
|
163
|
+
Returns a value from a set of given keys.
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
a1 = [{ id: 1, name: 'a' }, { id: 2, name: 'b' }]
|
167
|
+
|
168
|
+
a1.pick(:id) #=> 1
|
169
|
+
a1.pick(:id, :name) #=> [1,'a']
|
170
|
+
a1.pick(:fake) #=> nil
|
171
|
+
```
|
172
|
+
|
161
173
|
`pluck`
|
162
174
|
------
|
163
175
|
Returns an array of values from a set of given keys.
|
@@ -167,6 +179,7 @@ a1 = [{ id: 1, name: 'a' }, { id: 2, name: 'b' }]
|
|
167
179
|
|
168
180
|
a1.pluck(:id) #=> [1,2]
|
169
181
|
a1.pluck(:id, :name) #=> [[1,'a'], [2,'b']]
|
182
|
+
a1.pluck(:fake) #=> [nil,nil]
|
170
183
|
```
|
171
184
|
|
172
185
|
`produce`
|
data/lib/lite/ruby/array.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
if Lite::Ruby.configuration.monkey_patches.include?('array')
|
4
|
-
require 'lite/ruby/safe/array' unless defined?(ActiveSupport)
|
5
|
-
|
6
4
|
class Array
|
7
5
|
|
8
6
|
def assert_min_values!(*valid_values)
|
@@ -188,6 +186,10 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
|
|
188
186
|
array
|
189
187
|
end
|
190
188
|
|
189
|
+
def match(value)
|
190
|
+
find { |val| value == val }
|
191
|
+
end
|
192
|
+
|
191
193
|
def merge(*values)
|
192
194
|
dup.merge!(*values)
|
193
195
|
end
|
@@ -282,4 +284,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
|
|
282
284
|
alias select_values! only!
|
283
285
|
|
284
286
|
end
|
287
|
+
|
288
|
+
require 'lite/ruby/safe/array' unless defined?(ActiveSupport)
|
285
289
|
end
|
data/lib/lite/ruby/enumerable.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
4
|
-
require 'lite/ruby/safe/enumerable' unless defined?(ActiveSupport)
|
5
|
-
|
6
4
|
module Enumerable
|
7
5
|
|
8
6
|
def cluster
|
@@ -209,4 +207,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
209
207
|
alias occurrences frequency
|
210
208
|
|
211
209
|
end
|
210
|
+
|
211
|
+
require 'lite/ruby/safe/enumerable' unless defined?(ActiveSupport)
|
212
212
|
end
|
data/lib/lite/ruby/hash.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
if Lite::Ruby.configuration.monkey_patches.include?('hash')
|
4
|
-
require 'lite/ruby/safe/hash' unless defined?(ActiveSupport)
|
5
|
-
|
6
4
|
class Hash
|
7
5
|
|
8
6
|
class << self
|
@@ -405,4 +403,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('hash')
|
|
405
403
|
alias to_o to_object
|
406
404
|
|
407
405
|
end
|
406
|
+
|
407
|
+
require 'lite/ruby/safe/hash' unless defined?(ActiveSupport)
|
408
408
|
end
|
data/lib/lite/ruby/object.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
if Lite::Ruby.configuration.monkey_patches.include?('object')
|
4
|
-
require 'lite/ruby/safe/object' unless defined?(ActiveSupport)
|
5
|
-
|
6
4
|
class Object
|
7
5
|
|
8
6
|
FALSE_VALUES = %w[
|
@@ -168,4 +166,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('object')
|
|
168
166
|
alias to_b to_bool
|
169
167
|
|
170
168
|
end
|
169
|
+
|
170
|
+
require 'lite/ruby/safe/object' unless defined?(ActiveSupport)
|
171
171
|
end
|
data/lib/lite/ruby/range.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
if Lite::Ruby.configuration.monkey_patches.include?('range')
|
4
|
-
require 'lite/ruby/safe/range' unless defined?(ActiveSupport)
|
5
|
-
|
6
4
|
class Range
|
7
5
|
|
8
6
|
def combine(other)
|
@@ -29,4 +27,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('range')
|
|
29
27
|
end
|
30
28
|
|
31
29
|
end
|
30
|
+
|
31
|
+
require 'lite/ruby/safe/range' unless defined?(ActiveSupport)
|
32
32
|
end
|
data/lib/lite/ruby/safe/array.rb
CHANGED
@@ -28,11 +28,22 @@ module Enumerable
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def pick(*keys)
|
32
|
+
return if none?
|
33
|
+
|
34
|
+
if keys.many?
|
35
|
+
keys.map { |key| first[key] }
|
36
|
+
else
|
37
|
+
first[keys.first]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
31
41
|
def pluck(*keys)
|
32
42
|
if keys.many?
|
33
43
|
map { |element| keys.map { |key| element[key] } }
|
34
44
|
else
|
35
|
-
|
45
|
+
key = keys.first
|
46
|
+
map { |element| element[key] }
|
36
47
|
end
|
37
48
|
end
|
38
49
|
|
data/lib/lite/ruby/string.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
3
|
if Lite::Ruby.configuration.monkey_patches.include?('string')
|
4
|
-
require 'lite/ruby/safe/string' unless defined?(ActiveSupport)
|
5
|
-
|
6
4
|
class String
|
7
5
|
|
8
6
|
TRANSLITERATIONS = {
|
@@ -482,4 +480,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('string')
|
|
482
480
|
alias titlecase! titleize!
|
483
481
|
|
484
482
|
end
|
483
|
+
|
484
|
+
require 'lite/ruby/safe/string' unless defined?(ActiveSupport)
|
485
485
|
end
|
data/lib/lite/ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lite-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
- !ruby/object:Gem::Version
|
223
223
|
version: '0'
|
224
224
|
requirements: []
|
225
|
-
rubygems_version: 3.2.
|
225
|
+
rubygems_version: 3.2.18
|
226
226
|
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: Collection of useful Ruby methods for its primitive classes
|