lite-ruby 1.0.30 → 1.0.31
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
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +29 -28
- data/docs/HASH.md +2 -2
- data/lib/lite/ruby.rb +4 -1
- data/lib/lite/ruby/array.rb +9 -9
- data/lib/lite/ruby/enumerable.rb +12 -10
- data/lib/lite/ruby/hash.rb +23 -23
- data/lib/lite/ruby/numeric.rb +3 -3
- data/lib/lite/ruby/object.rb +1 -1
- data/lib/lite/ruby/string.rb +1 -1
- data/lib/lite/ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 15a0127d8b5abef7b86a8b357d76bd81721b3e17633e25935d074c914f2ce6c9
|
|
4
|
+
data.tar.gz: 0e0cbbb3cb414574370770851e3423b1f09094d1aebd0a133897c24ad9b40588
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 28cb3f81b2df9ff0483153c8c7077c04220efa0012958d6533cd8903a6d7b22e1099ab77c5c3db6b024cf04d211c37eb8bae9581e6457c02ddf1d891a5bf7142
|
|
7
|
+
data.tar.gz: 5adfc54f1824eab97ab7f23f20ea4b33f3405fddbd97ba32d48fa93f883eb35e0f6f9d70ac24f39ff046ae5a0775a080e0fcffaea1cfd4ce3e353e50afcd1bf8
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.0.31] - 2020-09-21
|
|
10
|
+
### Changed
|
|
11
|
+
- Changed `block_given?` => `defined?(yield)` for more performance
|
|
12
|
+
|
|
9
13
|
## [1.0.30] - 2020-07-03
|
|
10
14
|
### Added
|
|
11
15
|
- Added more Ruby 2.7 support
|
data/Gemfile.lock
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
lite-ruby (1.0.
|
|
4
|
+
lite-ruby (1.0.31)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
actionpack (6.0.3.
|
|
10
|
-
actionview (= 6.0.3.
|
|
11
|
-
activesupport (= 6.0.3.
|
|
9
|
+
actionpack (6.0.3.3)
|
|
10
|
+
actionview (= 6.0.3.3)
|
|
11
|
+
activesupport (= 6.0.3.3)
|
|
12
12
|
rack (~> 2.0, >= 2.0.8)
|
|
13
13
|
rack-test (>= 0.6.3)
|
|
14
14
|
rails-dom-testing (~> 2.0)
|
|
15
15
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
16
|
-
actionview (6.0.3.
|
|
17
|
-
activesupport (= 6.0.3.
|
|
16
|
+
actionview (6.0.3.3)
|
|
17
|
+
activesupport (= 6.0.3.3)
|
|
18
18
|
builder (~> 3.1)
|
|
19
19
|
erubi (~> 1.4)
|
|
20
20
|
rails-dom-testing (~> 2.0)
|
|
21
21
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
22
|
-
activesupport (6.0.3.
|
|
22
|
+
activesupport (6.0.3.3)
|
|
23
23
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
24
24
|
i18n (>= 0.7, < 2)
|
|
25
25
|
minitest (~> 5.1)
|
|
@@ -28,7 +28,7 @@ GEM
|
|
|
28
28
|
ast (2.4.1)
|
|
29
29
|
builder (3.2.4)
|
|
30
30
|
colorize (0.8.1)
|
|
31
|
-
concurrent-ruby (1.1.
|
|
31
|
+
concurrent-ruby (1.1.7)
|
|
32
32
|
crass (1.0.6)
|
|
33
33
|
diff-lcs (1.4.4)
|
|
34
34
|
erubi (1.9.0)
|
|
@@ -38,15 +38,15 @@ GEM
|
|
|
38
38
|
generator_spec (0.9.4)
|
|
39
39
|
activesupport (>= 3.0.0)
|
|
40
40
|
railties (>= 3.0.0)
|
|
41
|
-
i18n (1.8.
|
|
41
|
+
i18n (1.8.5)
|
|
42
42
|
concurrent-ruby (~> 1.0)
|
|
43
|
-
loofah (2.
|
|
43
|
+
loofah (2.7.0)
|
|
44
44
|
crass (~> 1.0.2)
|
|
45
45
|
nokogiri (>= 1.5.9)
|
|
46
46
|
method_source (1.0.0)
|
|
47
47
|
mini_portile2 (2.4.0)
|
|
48
|
-
minitest (5.14.
|
|
49
|
-
nokogiri (1.10.
|
|
48
|
+
minitest (5.14.2)
|
|
49
|
+
nokogiri (1.10.10)
|
|
50
50
|
mini_portile2 (~> 2.4.0)
|
|
51
51
|
parallel (1.19.2)
|
|
52
52
|
parser (2.7.1.4)
|
|
@@ -59,15 +59,15 @@ GEM
|
|
|
59
59
|
nokogiri (>= 1.6)
|
|
60
60
|
rails-html-sanitizer (1.3.0)
|
|
61
61
|
loofah (~> 2.3)
|
|
62
|
-
railties (6.0.3.
|
|
63
|
-
actionpack (= 6.0.3.
|
|
64
|
-
activesupport (= 6.0.3.
|
|
62
|
+
railties (6.0.3.3)
|
|
63
|
+
actionpack (= 6.0.3.3)
|
|
64
|
+
activesupport (= 6.0.3.3)
|
|
65
65
|
method_source
|
|
66
66
|
rake (>= 0.8.7)
|
|
67
67
|
thor (>= 0.20.3, < 2.0)
|
|
68
68
|
rainbow (3.0.0)
|
|
69
69
|
rake (13.0.1)
|
|
70
|
-
regexp_parser (1.
|
|
70
|
+
regexp_parser (1.8.0)
|
|
71
71
|
rexml (3.2.4)
|
|
72
72
|
rspec (3.9.0)
|
|
73
73
|
rspec-core (~> 3.9.0)
|
|
@@ -82,31 +82,32 @@ GEM
|
|
|
82
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
83
83
|
rspec-support (~> 3.9.0)
|
|
84
84
|
rspec-support (3.9.3)
|
|
85
|
-
rubocop (0.
|
|
85
|
+
rubocop (0.91.0)
|
|
86
86
|
parallel (~> 1.10)
|
|
87
|
-
parser (>= 2.7.
|
|
87
|
+
parser (>= 2.7.1.1)
|
|
88
88
|
rainbow (>= 2.2.2, < 4.0)
|
|
89
89
|
regexp_parser (>= 1.7)
|
|
90
90
|
rexml
|
|
91
|
-
rubocop-ast (>= 0.0
|
|
91
|
+
rubocop-ast (>= 0.4.0, < 1.0)
|
|
92
92
|
ruby-progressbar (~> 1.7)
|
|
93
93
|
unicode-display_width (>= 1.4.0, < 2.0)
|
|
94
|
-
rubocop-ast (0.
|
|
95
|
-
parser (>= 2.7.
|
|
96
|
-
rubocop-performance (1.
|
|
97
|
-
rubocop (>= 0.
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
rubocop-ast (0.4.2)
|
|
95
|
+
parser (>= 2.7.1.4)
|
|
96
|
+
rubocop-performance (1.8.1)
|
|
97
|
+
rubocop (>= 0.87.0)
|
|
98
|
+
rubocop-ast (>= 0.4.0)
|
|
99
|
+
rubocop-rspec (1.43.2)
|
|
100
|
+
rubocop (~> 0.87)
|
|
100
101
|
ruby-progressbar (1.10.1)
|
|
101
|
-
ruby_parser (3.
|
|
102
|
+
ruby_parser (3.15.0)
|
|
102
103
|
sexp_processor (~> 4.9)
|
|
103
|
-
sexp_processor (4.15.
|
|
104
|
+
sexp_processor (4.15.1)
|
|
104
105
|
thor (1.0.1)
|
|
105
106
|
thread_safe (0.3.6)
|
|
106
107
|
tzinfo (1.2.7)
|
|
107
108
|
thread_safe (~> 0.1)
|
|
108
109
|
unicode-display_width (1.7.0)
|
|
109
|
-
zeitwerk (2.
|
|
110
|
+
zeitwerk (2.4.0)
|
|
110
111
|
|
|
111
112
|
PLATFORMS
|
|
112
113
|
ruby
|
data/docs/HASH.md
CHANGED
|
@@ -323,8 +323,8 @@ Moves a key value pair to the head of the hash.
|
|
|
323
323
|
Rename the keys of a hash.
|
|
324
324
|
|
|
325
325
|
```ruby
|
|
326
|
-
{ foo: 'foo', baz: 'baz' }.rename_keys(foo: :bar)
|
|
327
|
-
{ foo: 'foo', 'baz' => 'baz' }.rename_keys(foo: :bar, 'baz' => 'tick') #=> { bar: 'foo', tick: 'baz' }
|
|
326
|
+
{ foo: 'foo', baz: 'baz' }.rename_keys(foo: :bar) #=> { bar: 'foo', baz: 'baz' }
|
|
327
|
+
{ foo: 'foo', 'baz' => 'baz' }.rename_keys!(foo: :bar, 'baz' => 'tick') #=> { bar: 'foo', tick: 'baz' }
|
|
328
328
|
```
|
|
329
329
|
|
|
330
330
|
`reverse_merge(!)`
|
data/lib/lite/ruby.rb
CHANGED
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
require "lite/ruby/#{filename}"
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
+
%w[date time].each do |filename|
|
|
8
|
+
require "lite/ruby/helpers/#{filename}_helper"
|
|
9
|
+
end
|
|
10
|
+
|
|
7
11
|
%w[
|
|
8
12
|
array boolean date enumerable hash integer kernel numeric object open_struct range string
|
|
9
13
|
struct time
|
|
10
14
|
].each do |filename|
|
|
11
|
-
require "lite/ruby/helpers/#{filename}_helper" if %w[date time].include?(filename)
|
|
12
15
|
require "lite/ruby/#{filename}"
|
|
13
16
|
end
|
|
14
17
|
|
data/lib/lite/ruby/array.rb
CHANGED
|
@@ -184,7 +184,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
|
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
187
|
-
def in_groups(number, fill_with = nil)
|
|
187
|
+
def in_groups(number, fill_with = nil, &block)
|
|
188
188
|
collection_size = size
|
|
189
189
|
division = collection_size.div(number)
|
|
190
190
|
modulo = collection_size % number
|
|
@@ -199,14 +199,14 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
|
|
|
199
199
|
start += grouping
|
|
200
200
|
end
|
|
201
201
|
|
|
202
|
-
return collection unless
|
|
202
|
+
return collection unless defined?(yield)
|
|
203
203
|
|
|
204
|
-
collection.each
|
|
204
|
+
collection.each(&block)
|
|
205
205
|
end
|
|
206
206
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
207
207
|
|
|
208
|
-
# rubocop:disable Metrics/
|
|
209
|
-
def in_groups_of(number, fill_with = nil)
|
|
208
|
+
# rubocop:disable Metrics/MethodLength, Style/GuardClause
|
|
209
|
+
def in_groups_of(number, fill_with = nil, &block)
|
|
210
210
|
if number.to_i <= 0
|
|
211
211
|
raise ArgumentError, "Group size must be a positive integer, was #{number.inspect}"
|
|
212
212
|
elsif fill_with == false
|
|
@@ -217,11 +217,11 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
|
|
|
217
217
|
end
|
|
218
218
|
|
|
219
219
|
sliced_collection = collection.each_slice(number)
|
|
220
|
-
return sliced_collection.to_a unless
|
|
220
|
+
return sliced_collection.to_a unless defined?(yield)
|
|
221
221
|
|
|
222
|
-
sliced_collection
|
|
222
|
+
sliced_collection(&block)
|
|
223
223
|
end
|
|
224
|
-
# rubocop:enable Metrics/
|
|
224
|
+
# rubocop:enable Metrics/MethodLength, Style/GuardClause
|
|
225
225
|
|
|
226
226
|
def indexes(value)
|
|
227
227
|
array = []
|
|
@@ -311,7 +311,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
|
|
|
311
311
|
def split(number = nil)
|
|
312
312
|
array = [[]]
|
|
313
313
|
|
|
314
|
-
if
|
|
314
|
+
if defined?(yield)
|
|
315
315
|
each { |val| yield(val) ? (array << []) : (array.last << val) }
|
|
316
316
|
else
|
|
317
317
|
dup_arr = dup
|
data/lib/lite/ruby/enumerable.rb
CHANGED
|
@@ -20,7 +20,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def deduce(identity = 0, &block)
|
|
23
|
-
if
|
|
23
|
+
if defined?(yield)
|
|
24
24
|
map(&block).deduce(identity)
|
|
25
25
|
else
|
|
26
26
|
inject { |acc, val| acc - val } || identity
|
|
@@ -46,7 +46,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
|
46
46
|
def exactly?(num)
|
|
47
47
|
found_count = 0
|
|
48
48
|
|
|
49
|
-
if
|
|
49
|
+
if defined?(yield)
|
|
50
50
|
each { |*opt| found_count += 1 if yield(*opt) }
|
|
51
51
|
else
|
|
52
52
|
each { |opt| found_count += 1 if opt }
|
|
@@ -77,7 +77,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def exponential(identity = 0, &block)
|
|
80
|
-
if
|
|
80
|
+
if defined?(yield)
|
|
81
81
|
map(&block).exponential(identity)
|
|
82
82
|
else
|
|
83
83
|
inject { |acc, val| acc**val } || identity
|
|
@@ -131,7 +131,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
|
131
131
|
def many?
|
|
132
132
|
found_count = 0
|
|
133
133
|
|
|
134
|
-
if
|
|
134
|
+
if defined?(yield)
|
|
135
135
|
any? do |val|
|
|
136
136
|
found_count += 1 if yield(val)
|
|
137
137
|
found_count > 1
|
|
@@ -153,7 +153,8 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
|
153
153
|
end
|
|
154
154
|
end
|
|
155
155
|
|
|
156
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
156
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
157
|
+
# rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
157
158
|
def occur(amount = nil)
|
|
158
159
|
result = Hash.new { |hash, key| hash[key] = [] }
|
|
159
160
|
|
|
@@ -162,7 +163,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
|
162
163
|
result[key] << item
|
|
163
164
|
end
|
|
164
165
|
|
|
165
|
-
if
|
|
166
|
+
if defined?(yield)
|
|
166
167
|
result.select! { |_key, values| yield(values.size) }
|
|
167
168
|
else
|
|
168
169
|
raise ArgumentError, 'Invalid occur amount' unless amount
|
|
@@ -176,7 +177,8 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
|
176
177
|
|
|
177
178
|
result.values.flatten.uniq
|
|
178
179
|
end
|
|
179
|
-
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
180
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
181
|
+
# rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
180
182
|
|
|
181
183
|
def pluck(*keys)
|
|
182
184
|
if keys.many?
|
|
@@ -187,7 +189,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
|
187
189
|
end
|
|
188
190
|
|
|
189
191
|
def produce(identity = 0, &block)
|
|
190
|
-
if
|
|
192
|
+
if defined?(yield)
|
|
191
193
|
map(&block).produce(identity)
|
|
192
194
|
else
|
|
193
195
|
inject { |acc, val| acc * val } || identity
|
|
@@ -195,7 +197,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
|
195
197
|
end
|
|
196
198
|
|
|
197
199
|
def quotient(identity = 0, &block)
|
|
198
|
-
if
|
|
200
|
+
if defined?(yield)
|
|
199
201
|
map(&block).quotient(identity)
|
|
200
202
|
else
|
|
201
203
|
inject { |acc, val| acc / val } || identity
|
|
@@ -205,7 +207,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
|
205
207
|
def several?
|
|
206
208
|
found_count = 0
|
|
207
209
|
|
|
208
|
-
if
|
|
210
|
+
if defined?(yield)
|
|
209
211
|
each { |*opt| found_count += 1 if yield(*opt) }
|
|
210
212
|
else
|
|
211
213
|
each { |opt| found_count += 1 if opt }
|
data/lib/lite/ruby/hash.rb
CHANGED
|
@@ -102,7 +102,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('hash')
|
|
|
102
102
|
end
|
|
103
103
|
# rubocop:enable Style/GuardClause
|
|
104
104
|
|
|
105
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
105
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
106
106
|
def collate(*others)
|
|
107
107
|
hash = {}
|
|
108
108
|
|
|
@@ -121,18 +121,18 @@ if Lite::Ruby.configuration.monkey_patches.include?('hash')
|
|
|
121
121
|
hash.each_value(&:flatten!)
|
|
122
122
|
hash
|
|
123
123
|
end
|
|
124
|
-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
124
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
125
125
|
|
|
126
126
|
def collate!(other_hash)
|
|
127
127
|
replace(collate(other_hash))
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
-
def collect_keys
|
|
131
|
-
|
|
130
|
+
def collect_keys(&block)
|
|
131
|
+
keys.map(&block)
|
|
132
132
|
end
|
|
133
133
|
|
|
134
|
-
def collect_values
|
|
135
|
-
|
|
134
|
+
def collect_values(&block)
|
|
135
|
+
values.map(&block)
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
def dearray_values(idx = 0)
|
|
@@ -186,7 +186,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('hash')
|
|
|
186
186
|
merge!(other_hash) do |key, this_val, other_val|
|
|
187
187
|
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
|
|
188
188
|
this_val.deep_merge(other_val, &block)
|
|
189
|
-
elsif
|
|
189
|
+
elsif defined?(yield)
|
|
190
190
|
yield(key, this_val, other_val)
|
|
191
191
|
else
|
|
192
192
|
other_val
|
|
@@ -403,10 +403,10 @@ if Lite::Ruby.configuration.monkey_patches.include?('hash')
|
|
|
403
403
|
def symbolize_keys
|
|
404
404
|
each_with_object({}) do |(key, val), hash|
|
|
405
405
|
new_key = begin
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
406
|
+
key.to_s.to_sym
|
|
407
|
+
rescue StandardError
|
|
408
|
+
key
|
|
409
|
+
end
|
|
410
410
|
|
|
411
411
|
hash[new_key] = val
|
|
412
412
|
end
|
|
@@ -420,16 +420,16 @@ if Lite::Ruby.configuration.monkey_patches.include?('hash')
|
|
|
420
420
|
def symbolize_and_underscore_keys
|
|
421
421
|
each_with_object({}) do |(key, val), hash|
|
|
422
422
|
new_key = begin
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
423
|
+
key.to_s
|
|
424
|
+
.gsub(/::/, '/')
|
|
425
|
+
.gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
|
|
426
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
|
427
|
+
.tr(' -', '_')
|
|
428
|
+
.downcase
|
|
429
|
+
.to_sym
|
|
430
|
+
rescue StandardError
|
|
431
|
+
key
|
|
432
|
+
end
|
|
433
433
|
|
|
434
434
|
hash[new_key] = val
|
|
435
435
|
end
|
|
@@ -462,13 +462,13 @@ if Lite::Ruby.configuration.monkey_patches.include?('hash')
|
|
|
462
462
|
end
|
|
463
463
|
|
|
464
464
|
def update_keys
|
|
465
|
-
return to_enum(:update_keys) unless
|
|
465
|
+
return to_enum(:update_keys) unless defined?(yield)
|
|
466
466
|
|
|
467
467
|
replace(each_with_object({}) { |(key, val), hash| hash[yield(key)] = val })
|
|
468
468
|
end
|
|
469
469
|
|
|
470
470
|
def update_values
|
|
471
|
-
return to_enum(:update_values) unless
|
|
471
|
+
return to_enum(:update_values) unless defined?(yield)
|
|
472
472
|
|
|
473
473
|
replace(each_with_object({}) { |(key, val), hash| hash[key] = yield(val) })
|
|
474
474
|
end
|
data/lib/lite/ruby/numeric.rb
CHANGED
|
@@ -86,7 +86,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('numeric')
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
def fraction?
|
|
89
|
-
fraction != 0.0
|
|
89
|
+
fraction.to_d != 0.0.to_d
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def greater_than?(num)
|
|
@@ -173,7 +173,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('numeric')
|
|
|
173
173
|
to_s.rjust(precision, pad_number.to_s)
|
|
174
174
|
end
|
|
175
175
|
|
|
176
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
176
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
177
177
|
def pad_precision(options = {})
|
|
178
178
|
pad_number = options[:pad_number] || 0
|
|
179
179
|
precision = options[:precision] || 2
|
|
@@ -190,7 +190,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('numeric')
|
|
|
190
190
|
string[0..(ljust_count - 1)]
|
|
191
191
|
end
|
|
192
192
|
end
|
|
193
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
193
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
194
194
|
|
|
195
195
|
def percentage_of(number)
|
|
196
196
|
return 0 if zero? || number.zero?
|
data/lib/lite/ruby/object.rb
CHANGED
|
@@ -177,7 +177,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('object')
|
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
def try!(*obj, &block)
|
|
180
|
-
if obj.empty? &&
|
|
180
|
+
if obj.empty? && defined?(yield)
|
|
181
181
|
block.arity.zero? ? instance_eval(&block) : yield(self)
|
|
182
182
|
else
|
|
183
183
|
public_send(*obj, &block)
|
data/lib/lite/ruby/string.rb
CHANGED
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.0.
|
|
4
|
+
version: 1.0.31
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juan Gomez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-09-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|