lite-ruby 1.1.4 → 1.1.9
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 +1 -0
- data/CHANGELOG.md +28 -0
- data/Gemfile.lock +59 -55
- data/docs/ARRAY.md +19 -1
- data/docs/ENUMERABLE.md +13 -0
- data/docs/TIME.md +8 -0
- data/lib/lite/ruby/array.rb +10 -2
- data/lib/lite/ruby/enumerable.rb +4 -8
- data/lib/lite/ruby/hash.rb +3 -3
- data/lib/lite/ruby/helpers/date_helper.rb +2 -2
- data/lib/lite/ruby/helpers/time_helper.rb +1 -1
- data/lib/lite/ruby/integer.rb +7 -3
- data/lib/lite/ruby/object.rb +4 -4
- 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 +3 -3
- data/lib/lite/ruby/time.rb +6 -2
- data/lib/lite/ruby/version.rb +1 -1
- data/lite-ruby.gemspec +1 -0
- metadata +17 -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/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,34 @@ 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
|
+
|
17
|
+
## [1.1.8] - 2021-07-05
|
18
|
+
### Changed
|
19
|
+
- Linter fixes
|
20
|
+
|
21
|
+
## [1.1.7] - 2021-03-04
|
22
|
+
### Added
|
23
|
+
- Added Integer => `SQL_SMALLINT`
|
24
|
+
- Added Integer => `SQL_INTEGER`
|
25
|
+
- Added Integer => `SQL_BIGINT`
|
26
|
+
|
27
|
+
## [1.1.6] - 2021-02-17
|
28
|
+
### Added
|
29
|
+
- Added Time => `monotonic`
|
30
|
+
### Changed
|
31
|
+
- Time `elapse` to use monotonic time
|
32
|
+
|
33
|
+
## [1.1.5] - 2021-02-16
|
34
|
+
### Added
|
35
|
+
- Added Array => `divergence`
|
36
|
+
|
9
37
|
## [1.1.4] - 2020-11-19
|
10
38
|
### Changed
|
11
39
|
- Object `array?` coerce ARGV check from nil to string
|
data/Gemfile.lock
CHANGED
@@ -1,56 +1,58 @@
|
|
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/
|
8
8
|
specs:
|
9
|
-
actionpack (6.
|
10
|
-
actionview (= 6.
|
11
|
-
activesupport (= 6.
|
12
|
-
rack (~> 2.0, >= 2.0.
|
9
|
+
actionpack (6.1.3.2)
|
10
|
+
actionview (= 6.1.3.2)
|
11
|
+
activesupport (= 6.1.3.2)
|
12
|
+
rack (~> 2.0, >= 2.0.9)
|
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.
|
17
|
-
activesupport (= 6.
|
16
|
+
actionview (6.1.3.2)
|
17
|
+
activesupport (= 6.1.3.2)
|
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.
|
22
|
+
activesupport (6.1.3.2)
|
23
23
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
24
|
-
i18n (>=
|
25
|
-
minitest (
|
26
|
-
tzinfo (~>
|
27
|
-
zeitwerk (~> 2.
|
28
|
-
ast (2.4.
|
24
|
+
i18n (>= 1.6, < 2)
|
25
|
+
minitest (>= 5.1)
|
26
|
+
tzinfo (~> 2.0)
|
27
|
+
zeitwerk (~> 2.3)
|
28
|
+
ast (2.4.2)
|
29
29
|
builder (3.2.4)
|
30
30
|
colorize (0.8.1)
|
31
|
-
concurrent-ruby (1.1.
|
31
|
+
concurrent-ruby (1.1.8)
|
32
32
|
crass (1.0.6)
|
33
33
|
diff-lcs (1.4.4)
|
34
34
|
erubi (1.10.0)
|
35
|
-
fasterer (0.
|
35
|
+
fasterer (0.9.0)
|
36
36
|
colorize (~> 0.7)
|
37
37
|
ruby_parser (>= 3.14.1)
|
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.10)
|
42
42
|
concurrent-ruby (~> 1.0)
|
43
|
-
loofah (2.
|
43
|
+
loofah (2.9.1)
|
44
44
|
crass (~> 1.0.2)
|
45
45
|
nokogiri (>= 1.5.9)
|
46
46
|
method_source (1.0.0)
|
47
|
-
mini_portile2 (2.
|
48
|
-
minitest (5.14.
|
49
|
-
nokogiri (1.
|
50
|
-
mini_portile2 (~> 2.
|
51
|
-
|
52
|
-
|
47
|
+
mini_portile2 (2.5.1)
|
48
|
+
minitest (5.14.4)
|
49
|
+
nokogiri (1.11.6)
|
50
|
+
mini_portile2 (~> 2.5.0)
|
51
|
+
racc (~> 1.4)
|
52
|
+
parallel (1.20.1)
|
53
|
+
parser (3.0.1.1)
|
53
54
|
ast (~> 2.4.1)
|
55
|
+
racc (1.5.2)
|
54
56
|
rack (2.2.3)
|
55
57
|
rack-test (1.1.0)
|
56
58
|
rack (>= 1.0, < 3)
|
@@ -59,56 +61,57 @@ GEM
|
|
59
61
|
nokogiri (>= 1.6)
|
60
62
|
rails-html-sanitizer (1.3.0)
|
61
63
|
loofah (~> 2.3)
|
62
|
-
railties (6.
|
63
|
-
actionpack (= 6.
|
64
|
-
activesupport (= 6.
|
64
|
+
railties (6.1.3.2)
|
65
|
+
actionpack (= 6.1.3.2)
|
66
|
+
activesupport (= 6.1.3.2)
|
65
67
|
method_source
|
66
68
|
rake (>= 0.8.7)
|
67
|
-
thor (
|
69
|
+
thor (~> 1.0)
|
68
70
|
rainbow (3.0.0)
|
69
|
-
rake (13.0.
|
70
|
-
regexp_parser (1.
|
71
|
-
rexml (3.2.
|
71
|
+
rake (13.0.3)
|
72
|
+
regexp_parser (2.1.1)
|
73
|
+
rexml (3.2.5)
|
72
74
|
rspec (3.10.0)
|
73
75
|
rspec-core (~> 3.10.0)
|
74
76
|
rspec-expectations (~> 3.10.0)
|
75
77
|
rspec-mocks (~> 3.10.0)
|
76
|
-
rspec-core (3.10.
|
78
|
+
rspec-core (3.10.1)
|
77
79
|
rspec-support (~> 3.10.0)
|
78
|
-
rspec-expectations (3.10.
|
80
|
+
rspec-expectations (3.10.1)
|
79
81
|
diff-lcs (>= 1.2.0, < 2.0)
|
80
82
|
rspec-support (~> 3.10.0)
|
81
|
-
rspec-mocks (3.10.
|
83
|
+
rspec-mocks (3.10.2)
|
82
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
83
85
|
rspec-support (~> 3.10.0)
|
84
|
-
rspec-support (3.10.
|
85
|
-
rubocop (1.
|
86
|
+
rspec-support (3.10.2)
|
87
|
+
rubocop (1.15.0)
|
86
88
|
parallel (~> 1.10)
|
87
|
-
parser (>=
|
89
|
+
parser (>= 3.0.0.0)
|
88
90
|
rainbow (>= 2.2.2, < 4.0)
|
89
|
-
regexp_parser (>= 1.8)
|
91
|
+
regexp_parser (>= 1.8, < 3.0)
|
90
92
|
rexml
|
91
|
-
rubocop-ast (>= 1.
|
93
|
+
rubocop-ast (>= 1.5.0, < 2.0)
|
92
94
|
ruby-progressbar (~> 1.7)
|
93
|
-
unicode-display_width (>= 1.4.0, <
|
94
|
-
rubocop-ast (1.
|
95
|
-
parser (>=
|
96
|
-
rubocop-performance (1.
|
97
|
-
rubocop (>=
|
95
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
96
|
+
rubocop-ast (1.6.0)
|
97
|
+
parser (>= 3.0.1.1)
|
98
|
+
rubocop-performance (1.11.3)
|
99
|
+
rubocop (>= 1.7.0, < 2.0)
|
98
100
|
rubocop-ast (>= 0.4.0)
|
99
|
-
rubocop-
|
101
|
+
rubocop-rake (0.5.1)
|
102
|
+
rubocop
|
103
|
+
rubocop-rspec (2.3.0)
|
100
104
|
rubocop (~> 1.0)
|
101
105
|
rubocop-ast (>= 1.1.0)
|
102
|
-
ruby-progressbar (1.
|
103
|
-
ruby_parser (3.
|
104
|
-
sexp_processor (~> 4.
|
105
|
-
sexp_processor (4.15.
|
106
|
-
thor (1.0
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
zeitwerk (2.4.1)
|
106
|
+
ruby-progressbar (1.11.0)
|
107
|
+
ruby_parser (3.16.0)
|
108
|
+
sexp_processor (~> 4.15, >= 4.15.1)
|
109
|
+
sexp_processor (4.15.3)
|
110
|
+
thor (1.1.0)
|
111
|
+
tzinfo (2.0.4)
|
112
|
+
concurrent-ruby (~> 1.0)
|
113
|
+
unicode-display_width (2.0.0)
|
114
|
+
zeitwerk (2.4.2)
|
112
115
|
|
113
116
|
PLATFORMS
|
114
117
|
ruby
|
@@ -122,7 +125,8 @@ DEPENDENCIES
|
|
122
125
|
rspec
|
123
126
|
rubocop
|
124
127
|
rubocop-performance
|
128
|
+
rubocop-rake
|
125
129
|
rubocop-rspec
|
126
130
|
|
127
131
|
BUNDLED WITH
|
128
|
-
2.
|
132
|
+
2.2.18
|
data/docs/ARRAY.md
CHANGED
@@ -137,6 +137,14 @@ Moves a given value to the tail of array.
|
|
137
137
|
[1, 2, 2, 3].demote!(4) #=> [1, 2, 2, 3]
|
138
138
|
```
|
139
139
|
|
140
|
+
`divergence`
|
141
|
+
------
|
142
|
+
Returns a list of elements not found in either array.
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
[1, 2, 2].divergence([2, 3, 4]) #=> [1, 3, 4]
|
146
|
+
```
|
147
|
+
|
140
148
|
`denillify(!)`
|
141
149
|
------
|
142
150
|
Converts `nil` into a given value.
|
@@ -227,6 +235,15 @@ Returns all indexes of the matching value.
|
|
227
235
|
[:a,:b,:a,:c].indexes(:a) #=> [0, 2]
|
228
236
|
```
|
229
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
|
+
|
230
247
|
`merge(!)`
|
231
248
|
------
|
232
249
|
Concats multiple arrays.
|
@@ -251,6 +268,7 @@ Selects given values from the array.
|
|
251
268
|
|
252
269
|
```ruby
|
253
270
|
[1, 2, 3, 4].only(1, 3) #=> [1, 3]
|
271
|
+
[1, 2, 3, 4].only!(8, 9) #=> []
|
254
272
|
```
|
255
273
|
|
256
274
|
`probability`
|
@@ -320,7 +338,7 @@ Divides the array into one or more subarrays based on a delimiting value or the
|
|
320
338
|
(1..10).to_a.split { |i| i % 3 == 0 } # => [[1, 2], [4, 5], [7, 8], [10]]
|
321
339
|
```
|
322
340
|
|
323
|
-
`strip(!)`
|
341
|
+
`strip(!)` aka `compact_blank(!)`
|
324
342
|
------
|
325
343
|
Removes blank elements from an array.
|
326
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/docs/TIME.md
CHANGED
@@ -35,6 +35,14 @@ Converts a `time` object to `strftime` it using a human readable string.
|
|
35
35
|
Time.now.format('month_name day, year hour:minute ampm') #=> 'January 09, 2014 02:31 pm'
|
36
36
|
```
|
37
37
|
|
38
|
+
`monotonic`
|
39
|
+
------
|
40
|
+
Returns the monotonic time.
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
Time.monotonic #=> 5834550.444132
|
44
|
+
```
|
45
|
+
|
38
46
|
`stamp` aka `to_format`
|
39
47
|
------
|
40
48
|
Converts a `time` object to a predefined format.
|
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)
|
@@ -147,6 +145,10 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
|
|
147
145
|
replace(denillify(identity))
|
148
146
|
end
|
149
147
|
|
148
|
+
def divergence(other)
|
149
|
+
(self - other) | (other - self)
|
150
|
+
end
|
151
|
+
|
150
152
|
def duplicates(minimum = 2)
|
151
153
|
hash = Hash.new(0)
|
152
154
|
each { |val| hash[val] += 1 }
|
@@ -184,6 +186,10 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
|
|
184
186
|
array
|
185
187
|
end
|
186
188
|
|
189
|
+
def match(value)
|
190
|
+
find { |val| value == val }
|
191
|
+
end
|
192
|
+
|
187
193
|
def merge(*values)
|
188
194
|
dup.merge!(*values)
|
189
195
|
end
|
@@ -278,4 +284,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
|
|
278
284
|
alias select_values! only!
|
279
285
|
|
280
286
|
end
|
287
|
+
|
288
|
+
require 'lite/ruby/safe/array' unless defined?(ActiveSupport)
|
281
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
|
@@ -57,11 +55,9 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
57
55
|
found_count > num ? false : num == found_count
|
58
56
|
end
|
59
57
|
|
60
|
-
# rubocop:disable Style/CaseEquality
|
61
58
|
def excase?(object)
|
62
|
-
none?
|
59
|
+
none?(object)
|
63
60
|
end
|
64
|
-
# rubocop:enable Style/CaseEquality
|
65
61
|
|
66
62
|
def expand
|
67
63
|
map { |val| val.is_a?(Enumerable) ? val.expand : val }
|
@@ -79,11 +75,9 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
79
75
|
each_with_object(Hash.new(0)) { |val, hash| hash[val] += 1 }
|
80
76
|
end
|
81
77
|
|
82
|
-
# rubocop:disable Style/CaseEquality
|
83
78
|
def incase?(object)
|
84
|
-
any?
|
79
|
+
any?(object)
|
85
80
|
end
|
86
|
-
# rubocop:enable Style/CaseEquality
|
87
81
|
|
88
82
|
# rubocop:disable Metrics/MethodLength
|
89
83
|
def interpose(sep, &block)
|
@@ -213,4 +207,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
|
|
213
207
|
alias occurrences frequency
|
214
208
|
|
215
209
|
end
|
210
|
+
|
211
|
+
require 'lite/ruby/safe/enumerable' unless defined?(ActiveSupport)
|
216
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
|
@@ -312,7 +310,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('hash')
|
|
312
310
|
end
|
313
311
|
|
314
312
|
def shuffle
|
315
|
-
|
313
|
+
to_a.sample(size).to_h
|
316
314
|
end
|
317
315
|
|
318
316
|
def shuffle!
|
@@ -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
|
@@ -5,7 +5,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('date')
|
|
5
5
|
module Ruby
|
6
6
|
module DateHelper
|
7
7
|
|
8
|
-
DATE_STAMPS
|
8
|
+
DATE_STAMPS = {
|
9
9
|
weekday: '%d',
|
10
10
|
weekday_blank: '%_d',
|
11
11
|
weekday_padded: '%d',
|
@@ -41,7 +41,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('date')
|
|
41
41
|
date_abbr: '%b %-d, %Y',
|
42
42
|
date_iso: '%Y-%m-%d'
|
43
43
|
}.freeze
|
44
|
-
DATE_UNITS
|
44
|
+
DATE_UNITS = {
|
45
45
|
w: 'u',
|
46
46
|
weekday: 'u',
|
47
47
|
ww: 'w',
|
data/lib/lite/ruby/integer.rb
CHANGED
@@ -3,11 +3,15 @@
|
|
3
3
|
if Lite::Ruby.configuration.monkey_patches.include?('integer')
|
4
4
|
class Integer
|
5
5
|
|
6
|
-
ROMAN_NUMERALS
|
7
|
-
M: 1000, CM: 900, D: 500, CD: 400, C: 100, XC: 90, L: 50,
|
8
|
-
I: 1
|
6
|
+
ROMAN_NUMERALS = {
|
7
|
+
M: 1000, CM: 900, D: 500, CD: 400, C: 100, XC: 90, L: 50,
|
8
|
+
XL: 40, X: 10, IX: 9, V: 5, IV: 4, I: 1
|
9
9
|
}.freeze
|
10
10
|
|
11
|
+
SQL_SMALLINT = 32_767
|
12
|
+
SQL_INTEGER = 2_147_483_647
|
13
|
+
SQL_BIGINT = 9_223_372_036_854_775_807
|
14
|
+
|
11
15
|
def bit(bit)
|
12
16
|
if bit.negative?
|
13
17
|
mask = (1 << ~bit)
|
data/lib/lite/ruby/object.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
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
|
-
FALSE_VALUES
|
6
|
+
FALSE_VALUES = %w[
|
9
7
|
0 f false n no off
|
10
8
|
].freeze
|
11
|
-
TRUE_VALUES
|
9
|
+
TRUE_VALUES = %w[
|
12
10
|
1 t true y yes on
|
13
11
|
].freeze
|
14
12
|
|
@@ -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,11 +1,9 @@
|
|
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
|
-
TRANSLITERATIONS
|
6
|
+
TRANSLITERATIONS = {
|
9
7
|
'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'Ae',
|
10
8
|
'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I',
|
11
9
|
'Î' => 'I', 'Ï' => 'I', 'Ð' => 'D', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O',
|
@@ -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/time.rb
CHANGED
@@ -9,15 +9,19 @@ if Lite::Ruby.configuration.monkey_patches.include?('time')
|
|
9
9
|
class << self
|
10
10
|
|
11
11
|
def elapse(verbose: false)
|
12
|
-
started_at =
|
12
|
+
started_at = monotonic
|
13
13
|
yield
|
14
|
-
ended_at =
|
14
|
+
ended_at = monotonic
|
15
15
|
runtime = ended_at - started_at
|
16
16
|
return runtime unless verbose
|
17
17
|
|
18
18
|
{ started_at: started_at, ended_at: ended_at, runtime: runtime }
|
19
19
|
end
|
20
20
|
|
21
|
+
def monotonic
|
22
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
23
|
+
end
|
24
|
+
|
21
25
|
end
|
22
26
|
|
23
27
|
private
|
data/lib/lite/ruby/version.rb
CHANGED
data/lite-ruby.gemspec
CHANGED
@@ -44,5 +44,6 @@ Gem::Specification.new do |spec|
|
|
44
44
|
spec.add_development_dependency 'rspec'
|
45
45
|
spec.add_development_dependency 'rubocop'
|
46
46
|
spec.add_development_dependency 'rubocop-performance'
|
47
|
+
spec.add_development_dependency 'rubocop-rake'
|
47
48
|
spec.add_development_dependency 'rubocop-rspec'
|
48
49
|
end
|
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:
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rubocop-rspec
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
222
|
- !ruby/object:Gem::Version
|
209
223
|
version: '0'
|
210
224
|
requirements: []
|
211
|
-
rubygems_version: 3.
|
225
|
+
rubygems_version: 3.2.18
|
212
226
|
signing_key:
|
213
227
|
specification_version: 4
|
214
228
|
summary: Collection of useful Ruby methods for its primitive classes
|