lite-ruby 2.0.7 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +47 -47
- data/docs/DATE.md +6 -0
- data/docs/STRING.md +51 -3
- data/docs/TIME.md +18 -0
- data/lib/lite/ruby/formats/date_stamps.yml +6 -0
- data/lib/lite/ruby/formats/time_stamps.yml +18 -0
- data/lib/lite/ruby/integer.rb +0 -2
- data/lib/lite/ruby/numeric.rb +2 -4
- data/lib/lite/ruby/string.rb +45 -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: 929161abda8b513b17abcca23b3e979815173803159300b09b439c90d0cd350e
|
4
|
+
data.tar.gz: e5424b301619fc8c69715095ec50cf78d427c9d5036268ad7112aea491aef761
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84e02a4af6d6433ea904f4a3ffc6c79fd8e4864d226107fb1946ff02b2a058334bf5f8aabfea6f352fd9b37fe21b0ea3bdf5cec23cbe7ef0142cbf9475ac1702
|
7
|
+
data.tar.gz: 7d6468c886ad49b110023f9ae3f29fd4a3ecb2823f460ea781ae340bf3a98fb8b211faa392e02f4d21942582bf351ba8a3ac76c19320eb691c0bd09f778b0229
|
data/.rubocop.yml
CHANGED
@@ -7,6 +7,8 @@ AllCops:
|
|
7
7
|
NewCops: enable
|
8
8
|
DisplayCopNames: true
|
9
9
|
DisplayStyleGuide: true
|
10
|
+
Gemspec/RequireMFA:
|
11
|
+
Enabled: false
|
10
12
|
Gemspec/RequiredRubyVersion:
|
11
13
|
Enabled: false
|
12
14
|
Layout/EmptyLinesAroundBlockBody:
|
@@ -61,6 +63,8 @@ Style/HashTransformKeys:
|
|
61
63
|
Enabled: false
|
62
64
|
Style/HashTransformValues:
|
63
65
|
Enabled: false
|
66
|
+
Style/OpenStructUse:
|
67
|
+
Enabled: false
|
64
68
|
Style/PerlBackrefs:
|
65
69
|
Enabled: false
|
66
70
|
Style/RedundantRegexpCharacterClass:
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.1.0] - 2022-02-09
|
10
|
+
### Added
|
11
|
+
- Added String `domain` to include protocol (more inline with URI method names) [BREAKING]
|
12
|
+
- Added Date => `day_day` format
|
13
|
+
- Added Date => `day_day_abbr` format
|
14
|
+
- Added Date => `day_day_iso` format
|
15
|
+
- Added Date => `day_date` format
|
16
|
+
- Added Date => `day_date_abbr` format
|
17
|
+
- Added Date => `day_date_iso` format
|
18
|
+
### Changed
|
19
|
+
- Rename String `domain` to `host`
|
20
|
+
- String `host` to use URI instead of a regexp
|
21
|
+
|
9
22
|
## [2.0.7] - 2021-09-29
|
10
23
|
### Added
|
11
24
|
- Added Range => `bounds`
|
data/Gemfile.lock
CHANGED
@@ -1,36 +1,35 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lite-ruby (2.0
|
4
|
+
lite-ruby (2.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
actionpack (
|
10
|
-
actionview (=
|
11
|
-
activesupport (=
|
12
|
-
rack (~> 2.0, >= 2.0
|
9
|
+
actionpack (7.0.2)
|
10
|
+
actionview (= 7.0.2)
|
11
|
+
activesupport (= 7.0.2)
|
12
|
+
rack (~> 2.0, >= 2.2.0)
|
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 (
|
17
|
-
activesupport (=
|
16
|
+
actionview (7.0.2)
|
17
|
+
activesupport (= 7.0.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 (
|
22
|
+
activesupport (7.0.2)
|
23
23
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
24
24
|
i18n (>= 1.6, < 2)
|
25
25
|
minitest (>= 5.1)
|
26
26
|
tzinfo (~> 2.0)
|
27
|
-
zeitwerk (~> 2.3)
|
28
27
|
ast (2.4.2)
|
29
28
|
builder (3.2.4)
|
30
29
|
colorize (0.8.1)
|
31
30
|
concurrent-ruby (1.1.9)
|
32
31
|
crass (1.0.6)
|
33
|
-
diff-lcs (1.
|
32
|
+
diff-lcs (1.5.0)
|
34
33
|
erubi (1.10.0)
|
35
34
|
fasterer (0.9.0)
|
36
35
|
colorize (~> 0.7)
|
@@ -38,21 +37,21 @@ GEM
|
|
38
37
|
generator_spec (0.9.4)
|
39
38
|
activesupport (>= 3.0.0)
|
40
39
|
railties (>= 3.0.0)
|
41
|
-
i18n (1.
|
40
|
+
i18n (1.9.1)
|
42
41
|
concurrent-ruby (~> 1.0)
|
43
|
-
loofah (2.
|
42
|
+
loofah (2.13.0)
|
44
43
|
crass (~> 1.0.2)
|
45
44
|
nokogiri (>= 1.5.9)
|
46
45
|
method_source (1.0.0)
|
47
|
-
mini_portile2 (2.
|
48
|
-
minitest (5.
|
49
|
-
nokogiri (1.
|
50
|
-
mini_portile2 (~> 2.
|
46
|
+
mini_portile2 (2.7.1)
|
47
|
+
minitest (5.15.0)
|
48
|
+
nokogiri (1.13.1)
|
49
|
+
mini_portile2 (~> 2.7.0)
|
51
50
|
racc (~> 1.4)
|
52
51
|
parallel (1.21.0)
|
53
|
-
parser (3.0.
|
52
|
+
parser (3.1.0.0)
|
54
53
|
ast (~> 2.4.1)
|
55
|
-
racc (1.
|
54
|
+
racc (1.6.0)
|
56
55
|
rack (2.2.3)
|
57
56
|
rack-test (1.1.0)
|
58
57
|
rack (>= 1.0, < 3)
|
@@ -61,56 +60,57 @@ GEM
|
|
61
60
|
nokogiri (>= 1.6)
|
62
61
|
rails-html-sanitizer (1.4.2)
|
63
62
|
loofah (~> 2.3)
|
64
|
-
railties (
|
65
|
-
actionpack (=
|
66
|
-
activesupport (=
|
63
|
+
railties (7.0.2)
|
64
|
+
actionpack (= 7.0.2)
|
65
|
+
activesupport (= 7.0.2)
|
67
66
|
method_source
|
68
|
-
rake (>=
|
67
|
+
rake (>= 12.2)
|
69
68
|
thor (~> 1.0)
|
70
|
-
|
69
|
+
zeitwerk (~> 2.5)
|
70
|
+
rainbow (3.1.1)
|
71
71
|
rake (13.0.6)
|
72
|
-
regexp_parser (2.
|
72
|
+
regexp_parser (2.2.0)
|
73
73
|
rexml (3.2.5)
|
74
|
-
rspec (3.
|
75
|
-
rspec-core (~> 3.
|
76
|
-
rspec-expectations (~> 3.
|
77
|
-
rspec-mocks (~> 3.
|
78
|
-
rspec-core (3.
|
79
|
-
rspec-support (~> 3.
|
80
|
-
rspec-expectations (3.
|
74
|
+
rspec (3.11.0)
|
75
|
+
rspec-core (~> 3.11.0)
|
76
|
+
rspec-expectations (~> 3.11.0)
|
77
|
+
rspec-mocks (~> 3.11.0)
|
78
|
+
rspec-core (3.11.0)
|
79
|
+
rspec-support (~> 3.11.0)
|
80
|
+
rspec-expectations (3.11.0)
|
81
81
|
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
-
rspec-support (~> 3.
|
83
|
-
rspec-mocks (3.
|
82
|
+
rspec-support (~> 3.11.0)
|
83
|
+
rspec-mocks (3.11.0)
|
84
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
85
|
-
rspec-support (~> 3.
|
86
|
-
rspec-support (3.
|
87
|
-
rubocop (1.
|
85
|
+
rspec-support (~> 3.11.0)
|
86
|
+
rspec-support (3.11.0)
|
87
|
+
rubocop (1.25.1)
|
88
88
|
parallel (~> 1.10)
|
89
|
-
parser (>= 3.
|
89
|
+
parser (>= 3.1.0.0)
|
90
90
|
rainbow (>= 2.2.2, < 4.0)
|
91
91
|
regexp_parser (>= 1.8, < 3.0)
|
92
92
|
rexml
|
93
|
-
rubocop-ast (>= 1.
|
93
|
+
rubocop-ast (>= 1.15.1, < 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.15.1)
|
97
97
|
parser (>= 3.0.1.1)
|
98
|
-
rubocop-performance (1.
|
98
|
+
rubocop-performance (1.13.2)
|
99
99
|
rubocop (>= 1.7.0, < 2.0)
|
100
100
|
rubocop-ast (>= 0.4.0)
|
101
101
|
rubocop-rake (0.6.0)
|
102
102
|
rubocop (~> 1.0)
|
103
|
-
rubocop-rspec (2.
|
103
|
+
rubocop-rspec (2.8.0)
|
104
104
|
rubocop (~> 1.19)
|
105
105
|
ruby-progressbar (1.11.0)
|
106
|
-
ruby_parser (3.
|
107
|
-
sexp_processor (~> 4.
|
108
|
-
sexp_processor (4.
|
109
|
-
thor (1.1
|
106
|
+
ruby_parser (3.18.1)
|
107
|
+
sexp_processor (~> 4.16)
|
108
|
+
sexp_processor (4.16.0)
|
109
|
+
thor (1.2.1)
|
110
110
|
tzinfo (2.0.4)
|
111
111
|
concurrent-ruby (~> 1.0)
|
112
112
|
unicode-display_width (2.1.0)
|
113
|
-
zeitwerk (2.4
|
113
|
+
zeitwerk (2.5.4)
|
114
114
|
|
115
115
|
PLATFORMS
|
116
116
|
ruby
|
@@ -128,4 +128,4 @@ DEPENDENCIES
|
|
128
128
|
rubocop-rspec
|
129
129
|
|
130
130
|
BUNDLED WITH
|
131
|
-
2.
|
131
|
+
2.3.4
|
data/docs/DATE.md
CHANGED
@@ -72,6 +72,12 @@ Converts a `date` object to a predefined format.
|
|
72
72
|
| Combo | Date | `:date` | %B %-d, %Y | January 9, 2014 |
|
73
73
|
| Combo | Date | `:date_abbr` | %b %-d, %Y | Jan 9, 2014 |
|
74
74
|
| Combo | Date | `:date_iso` | %Y-%m-%d | 2014-01-09 |
|
75
|
+
| Combo | Day month day | `:day` | %A, %B %-d | Sunday, January 9 |
|
76
|
+
| Combo | Day month day | `:day_abbr` | %a, %b %-d | Sun, Jan 9 |
|
77
|
+
| Combo | Day month day | `:day_iso` | %a, %m-%d | Sun, 01-09 |
|
78
|
+
| Combo | Day date | `:day_date` | %A, %B %-d, %Y | Sunday, January 9, 2014 |
|
79
|
+
| Combo | Day date | `:day_date_abbr` | %a, %b %-d, %Y | Sun, Jan 9, 2014 |
|
80
|
+
| Combo | Day date | `:day_date_iso` | %a, %Y-%m-%d | Sun, 2014-01-09 |
|
75
81
|
|
76
82
|
```ruby
|
77
83
|
Date.today.to_format(:year) #=> '2014'
|
data/docs/STRING.md
CHANGED
@@ -110,11 +110,12 @@ Removes the module part from the expression in the string.
|
|
110
110
|
|
111
111
|
`domain`
|
112
112
|
------
|
113
|
-
Extracts the domain
|
113
|
+
Extracts the domain from a URL.
|
114
114
|
|
115
115
|
```ruby
|
116
|
-
'http://www.example.com/fake-page'.domain #=> 'www.example.com'
|
117
|
-
'example
|
116
|
+
'http://www.example.com/fake-page'.domain #=> 'http://www.example.com'
|
117
|
+
'www.example.com'.domain #=> nil
|
118
|
+
'example string'.domain #=> nil
|
118
119
|
```
|
119
120
|
|
120
121
|
`downcase?`
|
@@ -173,6 +174,15 @@ Returns an interpolated string that allows for options.
|
|
173
174
|
'%d + %d'.format([1, 2]) #=> '1 + 2'
|
174
175
|
```
|
175
176
|
|
177
|
+
`fragment`
|
178
|
+
------
|
179
|
+
Extracts the fragment from a URL.
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
'http://www.example.com/fake-page?id=30&limit=5#time=1305298413'.fragment #=> 'time=1305298413'
|
183
|
+
'example string'.fragment #=> nil
|
184
|
+
```
|
185
|
+
|
176
186
|
`from`
|
177
187
|
------
|
178
188
|
Returns a substring from the given position to the end of the string. If the position is negative, it is counted from the end of the string.
|
@@ -190,6 +200,16 @@ Capitalizes each word.
|
|
190
200
|
' example test-sample '.headerize #=> 'Example Test-sample'
|
191
201
|
```
|
192
202
|
|
203
|
+
`host`
|
204
|
+
------
|
205
|
+
Extracts the host from a URL.
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
'http://www.example.com/fake-page'.host #=> 'www.example.com'
|
209
|
+
'www.example.com'.host #=> nil
|
210
|
+
'example string'.host #=> nil
|
211
|
+
```
|
212
|
+
|
193
213
|
`humanize(!)`
|
194
214
|
------
|
195
215
|
Transforms a string to a human readable string.
|
@@ -321,6 +341,16 @@ Makes a string suitable for a dashed url parameter string.
|
|
321
341
|
'example_string'.parameterize(separator: '?') #=> 'example?string'
|
322
342
|
```
|
323
343
|
|
344
|
+
`path`
|
345
|
+
------
|
346
|
+
Extracts the path from a URL.
|
347
|
+
|
348
|
+
```ruby
|
349
|
+
'http://www.example.com/fake-page?id=30&limit=5#time=1305298413'.path #=> '/fake-page'
|
350
|
+
'/fake-page'.path #=> '/fake-page'
|
351
|
+
'example string'.path #=> nil
|
352
|
+
```
|
353
|
+
|
324
354
|
`pathize(!)`
|
325
355
|
------
|
326
356
|
Transforms a string to a suitable file path.
|
@@ -374,6 +404,15 @@ Concats string to self.
|
|
374
404
|
'test'.push('er') #=> 'tester'
|
375
405
|
```
|
376
406
|
|
407
|
+
`query`
|
408
|
+
------
|
409
|
+
Extracts the query from a URL.
|
410
|
+
|
411
|
+
```ruby
|
412
|
+
'http://www.example.com/fake-page?id=30&limit=5#time=1305298413'.query #=> 'id=30&limit=5'
|
413
|
+
'example string'.query #=> nil
|
414
|
+
```
|
415
|
+
|
377
416
|
`quote(!)`
|
378
417
|
------
|
379
418
|
Adds a given quote type to the string.
|
@@ -432,6 +471,15 @@ Removes a random value and returns that value.
|
|
432
471
|
'this thing that'.sample(' thing ') #=> 'that'
|
433
472
|
```
|
434
473
|
|
474
|
+
`scheme`
|
475
|
+
------
|
476
|
+
Extracts the scheme from a URL.
|
477
|
+
|
478
|
+
```ruby
|
479
|
+
'http://www.example.com/fake-page?id=30&limit=5#time=1305298413'.scheme #=> 'http'
|
480
|
+
'example string'.scheme #=> nil
|
481
|
+
```
|
482
|
+
|
435
483
|
`shift(!)`
|
436
484
|
------
|
437
485
|
Removes the first instance of a string.
|
data/docs/TIME.md
CHANGED
@@ -97,6 +97,24 @@ Converts a `time` object to a predefined format.
|
|
97
97
|
| Combo | 12h datetime | `:datetime12_tzn` | %B %-d, %Y %H:%M %Z | January 9, 2014 12:31 am UTC |
|
98
98
|
| Combo | 12h datetime | `:datetime12_abbr_tzn` | %b %-d, %Y %H:%M %Z | Jan 9, 2014 12:31 am UTC |
|
99
99
|
| Combo | 12h datetime | `:datetime12_iso_tzn` | %Y-%m-%d %H:%M %z | 2014-01-09 12:31 am +0000 |
|
100
|
+
| Combo | Day 24h daytime | `:day_daytime` | %B %-d %H:%M | Sunday, January 9 00:31 |
|
101
|
+
| Combo | Day 24h daytime | `:day_daytime_abbr` | %b %-d %H:%M | Sun, Jan 9 00:31 |
|
102
|
+
| Combo | Day 24h daytime | `:day_daytime_iso` | %m-%d %H:%M | Sun, 01-09 00:31 |
|
103
|
+
| Combo | Day 12h daytime | `:day_daytime12` | %B %-d %H:%M | Sunday, January 9 12:31 am |
|
104
|
+
| Combo | Day 12h daytime | `:day_daytime12_abbr` | %b %-d %H:%M | Sun, Jan 9 12:31 am |
|
105
|
+
| Combo | Day 12h daytime | `:day_daytime12_iso` | %m-%d %H:%M | Sun, 01-09 12:31 am |
|
106
|
+
| Combo | Day 24h datetime | `:day_datetime` | %B %-d, %Y %H:%M | Sunday, January 9, 2014 00:31 |
|
107
|
+
| Combo | Day 24h datetime | `:day_datetime_abbr` | %b %-d, %Y %H:%M | Sun, Jan 9, 2014 00:31 |
|
108
|
+
| Combo | Day 24h datetime | `:day_datetime_iso` | %Y-%m-%d %H:%M | Sun, 2014-01-09 00:31 |
|
109
|
+
| Combo | Day 24h datetime | `:day_datetime_tzn` | %B %-d, %Y %H:%M %Z | Sunday, January 9, 2014 00:31 UTC |
|
110
|
+
| Combo | Day 24h datetime | `:day_datetime_abbr_tzn` | %b %-d, %Y %H:%M %Z | Sun, Jan 9, 2014 00:31 UTC |
|
111
|
+
| Combo | Day 24h datetime | `:day_datetime_iso_tzn` | %Y-%m-%d %H:%M %z | Sun, 2014-01-09 00:31 +0000 |
|
112
|
+
| Combo | Day 12h datetime | `:day_datetime12` | %B %-d, %Y %H:%M | Sunday, January 9, 2014 12:31 am |
|
113
|
+
| Combo | Day 12h datetime | `:day_datetime12_abbr` | %b %-d, %Y %H:%M | Sun, Jan 9, 2014 12:31 am |
|
114
|
+
| Combo | Day 12h datetime | `:day_datetime12_iso` | %Y-%m-%d %H:%M | Sun, 2014-01-09 12:31 am |
|
115
|
+
| Combo | Day 12h datetime | `:day_datetime12_tzn` | %B %-d, %Y %H:%M %Z | Sun, Sunday, January 9, 2014 12:31 am UTC |
|
116
|
+
| Combo | Day 12h datetime | `:day_datetime12_abbr_tzn` | %b %-d, %Y %H:%M %Z | Sun, Jan 9, 2014 12:31 am UTC |
|
117
|
+
| Combo | Day 12h datetime | `:day_datetime12_iso_tzn` | %Y-%m-%d %H:%M %z | Sun, 2014-01-09 12:31 am +0000 |
|
100
118
|
|
101
119
|
```ruby
|
102
120
|
Time.now.stamp(:datetime) #=> 'January 09, 2014 02:31 pm'
|
@@ -32,3 +32,9 @@ year_week: '%G-%V'
|
|
32
32
|
date: '%B %-d, %Y'
|
33
33
|
date_abbr: '%b %-d, %Y'
|
34
34
|
date_iso: '%Y-%m-%d'
|
35
|
+
day_day: '%A, %B %-d'
|
36
|
+
day_day_abbr: '%a, %b %-d'
|
37
|
+
day_day_iso: '%a, %m-%d'
|
38
|
+
day_date: '%A, %B %-d, %Y'
|
39
|
+
day_date_abbr: '%a, %b %-d, %Y'
|
40
|
+
day_date_iso: '%a, %Y-%m-%d'
|
@@ -40,3 +40,21 @@ datetime_iso_tzn: '%Y-%m-%d %H:%M %z'
|
|
40
40
|
datetime12_tzn: '%B %-d, %Y %I:%M %P %Z'
|
41
41
|
datetime12_abbr_tzn: '%b %-d, %Y %I:%M %P %Z'
|
42
42
|
datetime12_iso_tzn: '%Y-%m-%d %I:%M %P %z'
|
43
|
+
day_daytime: '%A, %B %-d %H:%M'
|
44
|
+
day_daytime_abbr: '%a, %b %-d %H:%M'
|
45
|
+
day_daytime_iso: '%a, %m-%d %H:%M'
|
46
|
+
day_daytime12: '%A, %B %-d %I:%M %P'
|
47
|
+
day_daytime12_abbr: '%a, %b %-d %I:%M %P'
|
48
|
+
day_daytime12_iso: '%a, %m-%d %I:%M %P'
|
49
|
+
day_datetime: '%A, %B %-d, %Y %H:%M'
|
50
|
+
day_datetime_abbr: '%a, %b %-d, %Y %H:%M'
|
51
|
+
day_datetime_iso: '%a, %Y-%m-%d %H:%M'
|
52
|
+
day_datetime12: '%A, %B %-d, %Y %I:%M %P'
|
53
|
+
day_datetime12_abbr: '%a, %b %-d, %Y %I:%M %P'
|
54
|
+
day_datetime12_iso: '%a, %Y-%m-%d %I:%M %P'
|
55
|
+
day_datetime_tzn: '%A, %B %-d, %Y %H:%M %Z'
|
56
|
+
day_datetime_abbr_tzn: '%a, %b %-d, %Y %H:%M %Z'
|
57
|
+
day_datetime_iso_tzn: '%a, %Y-%m-%d %H:%M %z'
|
58
|
+
day_datetime12_tzn: '%A, %B %-d, %Y %I:%M %P %Z'
|
59
|
+
day_datetime12_abbr_tzn: '%a, %b %-d, %Y %I:%M %P %Z'
|
60
|
+
day_datetime12_iso_tzn: '%a, %Y-%m-%d %I:%M %P %z'
|
data/lib/lite/ruby/integer.rb
CHANGED
@@ -48,11 +48,9 @@ class Integer
|
|
48
48
|
(0...num).inject(1) { |acc, i| (acc * (self - i)) / (i + 1) }
|
49
49
|
end
|
50
50
|
|
51
|
-
# rubocop:disable Lint/AmbiguousRange
|
52
51
|
def factorial
|
53
52
|
(1..self).inject { |acc, i| acc * i } || 0
|
54
53
|
end
|
55
|
-
# rubocop:enable Lint/AmbiguousRange
|
56
54
|
|
57
55
|
def factors
|
58
56
|
limit = Math.sqrt(self).floor
|
data/lib/lite/ruby/numeric.rb
CHANGED
@@ -66,7 +66,7 @@ class Numeric
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def fraction?
|
69
|
-
fraction.to_d != 0.0
|
69
|
+
fraction.to_d != BigDecimal('0.0')
|
70
70
|
end
|
71
71
|
|
72
72
|
def greater_than?(num)
|
@@ -124,7 +124,7 @@ class Numeric
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def one?
|
127
|
-
to_d == 1.0
|
127
|
+
to_d == BigDecimal('1.0')
|
128
128
|
end
|
129
129
|
|
130
130
|
def ordinal
|
@@ -228,11 +228,9 @@ class Numeric
|
|
228
228
|
"#{pad_precision(options.only(:precision))}#{unit}"
|
229
229
|
end
|
230
230
|
|
231
|
-
# rubocop:disable Lint/AmbiguousRange
|
232
231
|
def to_range
|
233
232
|
negative? ? (self..-self) : (-self..self)
|
234
233
|
end
|
235
|
-
# rubocop:enable Lint/AmbiguousRange
|
236
234
|
|
237
235
|
def within?(number, epsilon = 0.01)
|
238
236
|
return number == self if epsilon.zero?
|
data/lib/lite/ruby/string.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
+
require 'uri' unless defined?(URI)
|
3
4
|
require 'yaml' unless defined?(YAML)
|
4
5
|
|
5
6
|
class String
|
@@ -54,9 +55,11 @@ class String
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def domain
|
57
|
-
return
|
58
|
+
return if empty?
|
58
59
|
|
59
|
-
|
60
|
+
URI.join(self, '/').to_s.chomp('/')
|
61
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
62
|
+
nil
|
60
63
|
end
|
61
64
|
|
62
65
|
def downcase?
|
@@ -76,6 +79,14 @@ class String
|
|
76
79
|
"#{self[0, offset]}#{separator}#{self[-offset, offset]}"
|
77
80
|
end
|
78
81
|
|
82
|
+
def fragment
|
83
|
+
return if empty?
|
84
|
+
|
85
|
+
URI.parse(self).fragment
|
86
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
|
79
90
|
def format(*args)
|
80
91
|
super(self, *args.flatten)
|
81
92
|
end
|
@@ -88,6 +99,14 @@ class String
|
|
88
99
|
replace(headerize)
|
89
100
|
end
|
90
101
|
|
102
|
+
def host
|
103
|
+
return if empty?
|
104
|
+
|
105
|
+
URI.parse(self).host
|
106
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
107
|
+
nil
|
108
|
+
end
|
109
|
+
|
91
110
|
def humanize!(capitalize: true)
|
92
111
|
replace(humanize(capitalize: capitalize))
|
93
112
|
end
|
@@ -179,6 +198,14 @@ class String
|
|
179
198
|
replace(parameterize(separator: separator))
|
180
199
|
end
|
181
200
|
|
201
|
+
def path
|
202
|
+
return if empty?
|
203
|
+
|
204
|
+
URI.parse(self).path
|
205
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
206
|
+
nil
|
207
|
+
end
|
208
|
+
|
182
209
|
def pathize
|
183
210
|
dup.pathize!
|
184
211
|
end
|
@@ -224,6 +251,14 @@ class String
|
|
224
251
|
replace(concat(string))
|
225
252
|
end
|
226
253
|
|
254
|
+
def query
|
255
|
+
return if empty?
|
256
|
+
|
257
|
+
URI.parse(self).query
|
258
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
259
|
+
nil
|
260
|
+
end
|
261
|
+
|
227
262
|
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
228
263
|
def quote(type = :double, amount = nil)
|
229
264
|
if type.is_a?(Integer)
|
@@ -313,6 +348,14 @@ class String
|
|
313
348
|
replace(sample(separator))
|
314
349
|
end
|
315
350
|
|
351
|
+
def scheme
|
352
|
+
return if empty?
|
353
|
+
|
354
|
+
URI.parse(self).scheme
|
355
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
356
|
+
nil
|
357
|
+
end
|
358
|
+
|
316
359
|
def shift(*patterns)
|
317
360
|
dup.shift!(*patterns)
|
318
361
|
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: 2.0
|
4
|
+
version: 2.1.0
|
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: 2022-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
227
|
- !ruby/object:Gem::Version
|
228
228
|
version: '0'
|
229
229
|
requirements: []
|
230
|
-
rubygems_version: 3.
|
230
|
+
rubygems_version: 3.3.4
|
231
231
|
signing_key:
|
232
232
|
specification_version: 4
|
233
233
|
summary: Collection of useful Ruby methods for its primitive classes
|