lite-ruby 2.0.6 → 2.3.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 +35 -0
- data/Gemfile.lock +47 -47
- data/docs/DATE.md +6 -0
- data/docs/HASH.md +18 -5
- data/docs/RANGE.md +8 -0
- data/docs/STRING.md +57 -9
- 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/hash.rb +4 -0
- data/lib/lite/ruby/integer.rb +0 -2
- data/lib/lite/ruby/numeric.rb +2 -4
- data/lib/lite/ruby/range.rb +4 -0
- data/lib/lite/ruby/string.rb +49 -6
- 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: ee69ca4fcfaa7ff5e1af8805fba36795e13bb191ec57c150add24cb26a908cef
|
4
|
+
data.tar.gz: dccc37c364c1771639199af8ee5aa838bc03536840f48acbeace3728fdd1fea2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba4ff364318fc3c9a6f420f063964e31554080b668fbbc4d90eb89d2895644e53f0677e2cbfcd3c1482fbd7b0682f61b586963f585cd90c1eeb0d725dbfa3a69
|
7
|
+
data.tar.gz: d530805fba53fe9d2b1ea67f5b81fc003a2e4d85685cfbfe84fd5d0562521970f31632b44d46d4476793ab50e00aab30a98b32c6c5676f4487a190798f2b3a69
|
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,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.3.0] - 2022-02-17
|
10
|
+
### Changed
|
11
|
+
- Rename String => `domain` to `uri_domain`
|
12
|
+
- Rename String => `fragment` to `uri_fragment`
|
13
|
+
- Rename String => `host` to `uri_host`
|
14
|
+
- Rename String => `path` to `uri_path`
|
15
|
+
- Rename String => `query` to `uri_query`
|
16
|
+
- Rename String => `scheme` to `uri_scheme`
|
17
|
+
|
18
|
+
## [2.2.0] - 2022-02-17
|
19
|
+
### Added
|
20
|
+
- Added Hash => `deep_fetch`
|
21
|
+
|
22
|
+
## [2.1.0] - 2022-02-09
|
23
|
+
### Added
|
24
|
+
- Added String `domain` to include protocol (more inline with URI method names) [BREAKING]
|
25
|
+
- Added String => `fragment`
|
26
|
+
- Added String => `host`
|
27
|
+
- Added String => `path`
|
28
|
+
- Added String => `query`
|
29
|
+
- Added String => `scheme
|
30
|
+
- Added Date => `day_day` format
|
31
|
+
- Added Date => `day_day_abbr` format
|
32
|
+
- Added Date => `day_day_iso` format
|
33
|
+
- Added Date => `day_date` format
|
34
|
+
- Added Date => `day_date_abbr` format
|
35
|
+
- Added Date => `day_date_iso` format
|
36
|
+
### Changed
|
37
|
+
- Rename String `domain` to `host`
|
38
|
+
- String `host` to use URI instead of a regexp
|
39
|
+
|
40
|
+
## [2.0.7] - 2021-09-29
|
41
|
+
### Added
|
42
|
+
- Added Range => `bounds`
|
43
|
+
|
9
44
|
## [2.0.6] - 2021-09-26
|
10
45
|
### Changed
|
11
46
|
- Added DateTimeHelper => added missing comma to imperical date
|
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.3.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.2)
|
10
|
+
actionview (= 7.0.2.2)
|
11
|
+
activesupport (= 7.0.2.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.2)
|
17
|
+
activesupport (= 7.0.2.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.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.10.0)
|
42
41
|
concurrent-ruby (~> 1.0)
|
43
|
-
loofah (2.
|
42
|
+
loofah (2.14.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.2)
|
64
|
+
actionpack (= 7.0.2.2)
|
65
|
+
activesupport (= 7.0.2.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.1)
|
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.2)
|
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/HASH.md
CHANGED
@@ -149,18 +149,20 @@ h1 = { a: [1], b: [1, 2], c: 3, d: [] }
|
|
149
149
|
h1.dearray_singular_values #=> { a: 1, b: [1, 2], c: 3, d: nil }
|
150
150
|
```
|
151
151
|
|
152
|
-
`
|
152
|
+
`deep_fetch`
|
153
153
|
------
|
154
|
-
Returns a
|
154
|
+
Returns a nested value if found or raises an error similar to `fetch`.
|
155
155
|
|
156
156
|
```ruby
|
157
157
|
h1 = { a: true, b: { c: [1, 2, 3] } }
|
158
|
-
h2 = { a: false, b: { x: [3, 4, 5] } }
|
159
158
|
|
160
|
-
h1.
|
159
|
+
h1.deep_fetch(:a) #=> true
|
160
|
+
h1.deep_fetch(:b, :c) #=> [1, 2, 3]
|
161
|
+
h1.deep_fetch(:b, :y) #=> raises KeyError
|
162
|
+
h1.deep_fetch(:b, :y) { nil } #=> nil
|
161
163
|
```
|
162
164
|
|
163
|
-
`deep_key
|
165
|
+
`deep_key?`
|
164
166
|
------
|
165
167
|
Returns if a set of nested keys exists.
|
166
168
|
|
@@ -173,6 +175,17 @@ h1.deep_key?(:x) #=> false
|
|
173
175
|
h1.deep_key?(:a, :c, :x) #=> false
|
174
176
|
```
|
175
177
|
|
178
|
+
`deep_merge(!)`
|
179
|
+
------
|
180
|
+
Returns a new hash with self and other_hash merged recursively.
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
h1 = { a: true, b: { c: [1, 2, 3] } }
|
184
|
+
h2 = { a: false, b: { x: [3, 4, 5] } }
|
185
|
+
|
186
|
+
h1.deep_merge(h2) #=> { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
|
187
|
+
```
|
188
|
+
|
176
189
|
`delete_unless`
|
177
190
|
------
|
178
191
|
Inverse of `delete_if`.
|
data/docs/RANGE.md
CHANGED
data/docs/STRING.md
CHANGED
@@ -108,15 +108,6 @@ Removes the module part from the expression in the string.
|
|
108
108
|
'String'.demodulize #=> 'String'
|
109
109
|
```
|
110
110
|
|
111
|
-
`domain`
|
112
|
-
------
|
113
|
-
Extracts the domain name from a URL.
|
114
|
-
|
115
|
-
```ruby
|
116
|
-
'http://www.example.com/fake-page'.domain #=> 'www.example.com'
|
117
|
-
'example string'.domain #=> 'example string'
|
118
|
-
```
|
119
|
-
|
120
111
|
`downcase?`
|
121
112
|
------
|
122
113
|
Returns true if all characters are lowercase.
|
@@ -597,6 +588,63 @@ Removes any quote types from a given string.
|
|
597
588
|
'`example`'.unquote #=> 'example'
|
598
589
|
```
|
599
590
|
|
591
|
+
`uri_domain`
|
592
|
+
------
|
593
|
+
Extracts the uri_domain from a URL.
|
594
|
+
|
595
|
+
```ruby
|
596
|
+
'http://www.example.com/fake-page'.uri_domain #=> 'http://www.example.com'
|
597
|
+
'www.example.com'.uri_domain #=> nil
|
598
|
+
'example string'.uri_domain #=> nil
|
599
|
+
```
|
600
|
+
|
601
|
+
`uri_fragment`
|
602
|
+
------
|
603
|
+
Extracts the uri_fragment from a URL.
|
604
|
+
|
605
|
+
```ruby
|
606
|
+
'http://www.example.com/fake-page?id=30&limit=5#time=1305298413'.uri_fragment #=> 'time=1305298413'
|
607
|
+
'example string'.uri_fragment #=> nil
|
608
|
+
```
|
609
|
+
|
610
|
+
`uri_host`
|
611
|
+
------
|
612
|
+
Extracts the uri_host from a URL.
|
613
|
+
|
614
|
+
```ruby
|
615
|
+
'http://www.example.com/fake-page'.uri_host #=> 'www.example.com'
|
616
|
+
'www.example.com'.uri_host #=> nil
|
617
|
+
'example string'.uri_host #=> nil
|
618
|
+
```
|
619
|
+
|
620
|
+
`uri_path`
|
621
|
+
------
|
622
|
+
Extracts the uri_path from a URL.
|
623
|
+
|
624
|
+
```ruby
|
625
|
+
'http://www.example.com/fake-page?id=30&limit=5#time=1305298413'.uri_path #=> '/fake-page'
|
626
|
+
'/fake-page'.uri_path #=> '/fake-page'
|
627
|
+
'example string'.uri_path #=> nil
|
628
|
+
```
|
629
|
+
|
630
|
+
`uri_query`
|
631
|
+
------
|
632
|
+
Extracts the uri_query from a URL.
|
633
|
+
|
634
|
+
```ruby
|
635
|
+
'http://www.example.com/fake-page?id=30&limit=5#time=1305298413'.uri_query #=> 'id=30&limit=5'
|
636
|
+
'example string'.uri_query #=> nil
|
637
|
+
```
|
638
|
+
|
639
|
+
`uri_scheme`
|
640
|
+
------
|
641
|
+
Extracts the uri_scheme from a URL.
|
642
|
+
|
643
|
+
```ruby
|
644
|
+
'http://www.example.com/fake-page?id=30&limit=5#time=1305298413'.uri_scheme #=> 'http'
|
645
|
+
'example string'.uri_scheme #=> nil
|
646
|
+
```
|
647
|
+
|
600
648
|
`variablize(!)`
|
601
649
|
------
|
602
650
|
Prepend an "@" to the beginning of a string and replace non-valid characters with underscores.
|
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 | 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/hash.rb
CHANGED
@@ -160,6 +160,10 @@ class Hash
|
|
160
160
|
replace(dearray_singular_values)
|
161
161
|
end
|
162
162
|
|
163
|
+
def deep_fetch(*keys, &block)
|
164
|
+
keys.reduce(self) { |hash_object, key| hash_object.fetch(key, &block) }
|
165
|
+
end
|
166
|
+
|
163
167
|
def deep_key?(*keys)
|
164
168
|
last_hash = self
|
165
169
|
found_key = false
|
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/range.rb
CHANGED
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
|
@@ -53,12 +54,6 @@ class String
|
|
53
54
|
replace(demodulize)
|
54
55
|
end
|
55
56
|
|
56
|
-
def domain
|
57
|
-
return self unless self =~ %r{^(?:\w+://)?([^/?]+)(?:/|\?|$)}
|
58
|
-
|
59
|
-
Regexp.last_match(1)
|
60
|
-
end
|
61
|
-
|
62
57
|
def downcase?
|
63
58
|
downcase == self
|
64
59
|
end
|
@@ -408,6 +403,54 @@ class String
|
|
408
403
|
self
|
409
404
|
end
|
410
405
|
|
406
|
+
def uri_domain
|
407
|
+
return if empty?
|
408
|
+
|
409
|
+
URI.join(self, '/').to_s.chomp('/')
|
410
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
411
|
+
nil
|
412
|
+
end
|
413
|
+
|
414
|
+
def uri_fragment
|
415
|
+
return if empty?
|
416
|
+
|
417
|
+
URI.parse(self).fragment
|
418
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
419
|
+
nil
|
420
|
+
end
|
421
|
+
|
422
|
+
def uri_host
|
423
|
+
return if empty?
|
424
|
+
|
425
|
+
URI.parse(self).host
|
426
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
427
|
+
nil
|
428
|
+
end
|
429
|
+
|
430
|
+
def uri_path
|
431
|
+
return if empty?
|
432
|
+
|
433
|
+
URI.parse(self).path
|
434
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
435
|
+
nil
|
436
|
+
end
|
437
|
+
|
438
|
+
def uri_query
|
439
|
+
return if empty?
|
440
|
+
|
441
|
+
URI.parse(self).query
|
442
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
443
|
+
nil
|
444
|
+
end
|
445
|
+
|
446
|
+
def uri_scheme
|
447
|
+
return if empty?
|
448
|
+
|
449
|
+
URI.parse(self).scheme
|
450
|
+
rescue URI::BadURIError, URI::InvalidURIError
|
451
|
+
nil
|
452
|
+
end
|
453
|
+
|
411
454
|
def unshift(*patterns)
|
412
455
|
patterns.each_with_object('') { |pat, str| str << pat }
|
413
456
|
.concat(self)
|
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.3.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-17 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
|