lite-ruby 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5259c7027cc54284ebcdc00f0ae5c2624f6e4832b076802b8c5997ebf3d541e1
4
- data.tar.gz: 46442407a045d0ea2b33b0b8875a2c68d116467bfec13ff5885ae4fabe2199f6
3
+ metadata.gz: ee69ca4fcfaa7ff5e1af8805fba36795e13bb191ec57c150add24cb26a908cef
4
+ data.tar.gz: dccc37c364c1771639199af8ee5aa838bc03536840f48acbeace3728fdd1fea2
5
5
  SHA512:
6
- metadata.gz: afb85e87add0403b552c6be760f68a7b1bc0a4b893e8474f5779266d3c3743b2c6164dcf4cf7d71071a03584ccfc5d4bee3c30bbdcc0e44728b600f462721a71
7
- data.tar.gz: '098b205a552cb43ea81cef034321119b2452853cac7a42a602e0aa6971c62f18144ed527ab8131333bf46a658c5946cf38ac801049a779065026ccf0551ecfd4'
6
+ metadata.gz: ba4ff364318fc3c9a6f420f063964e31554080b668fbbc4d90eb89d2895644e53f0677e2cbfcd3c1482fbd7b0682f61b586963f585cd90c1eeb0d725dbfa3a69
7
+ data.tar.gz: d530805fba53fe9d2b1ea67f5b81fc003a2e4d85685cfbfe84fd5d0562521970f31632b44d46d4476793ab50e00aab30a98b32c6c5676f4487a190798f2b3a69
data/CHANGELOG.md CHANGED
@@ -6,6 +6,15 @@ 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
+
9
18
  ## [2.2.0] - 2022-02-17
10
19
  ### Added
11
20
  - Added Hash => `deep_fetch`
@@ -13,6 +22,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
22
  ## [2.1.0] - 2022-02-09
14
23
  ### Added
15
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
16
30
  - Added Date => `day_day` format
17
31
  - Added Date => `day_day_abbr` format
18
32
  - Added Date => `day_day_iso` format
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-ruby (2.2.0)
4
+ lite-ruby (2.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/docs/STRING.md CHANGED
@@ -108,16 +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 from a URL.
114
-
115
- ```ruby
116
- 'http://www.example.com/fake-page'.domain #=> 'http://www.example.com'
117
- 'www.example.com'.domain #=> nil
118
- 'example string'.domain #=> nil
119
- ```
120
-
121
111
  `downcase?`
122
112
  ------
123
113
  Returns true if all characters are lowercase.
@@ -174,15 +164,6 @@ Returns an interpolated string that allows for options.
174
164
  '%d + %d'.format([1, 2]) #=> '1 + 2'
175
165
  ```
176
166
 
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
-
186
167
  `from`
187
168
  ------
188
169
  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.
@@ -200,16 +181,6 @@ Capitalizes each word.
200
181
  ' example test-sample '.headerize #=> 'Example Test-sample'
201
182
  ```
202
183
 
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
-
213
184
  `humanize(!)`
214
185
  ------
215
186
  Transforms a string to a human readable string.
@@ -341,16 +312,6 @@ Makes a string suitable for a dashed url parameter string.
341
312
  'example_string'.parameterize(separator: '?') #=> 'example?string'
342
313
  ```
343
314
 
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
-
354
315
  `pathize(!)`
355
316
  ------
356
317
  Transforms a string to a suitable file path.
@@ -404,15 +365,6 @@ Concats string to self.
404
365
  'test'.push('er') #=> 'tester'
405
366
  ```
406
367
 
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
-
416
368
  `quote(!)`
417
369
  ------
418
370
  Adds a given quote type to the string.
@@ -471,15 +423,6 @@ Removes a random value and returns that value.
471
423
  'this thing that'.sample(' thing ') #=> 'that'
472
424
  ```
473
425
 
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
-
483
426
  `shift(!)`
484
427
  ------
485
428
  Removes the first instance of a string.
@@ -645,6 +588,63 @@ Removes any quote types from a given string.
645
588
  '`example`'.unquote #=> 'example'
646
589
  ```
647
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
+
648
648
  `variablize(!)`
649
649
  ------
650
650
  Prepend an "@" to the beginning of a string and replace non-valid characters with underscores.
@@ -54,14 +54,6 @@ class String
54
54
  replace(demodulize)
55
55
  end
56
56
 
57
- def domain
58
- return if empty?
59
-
60
- URI.join(self, '/').to_s.chomp('/')
61
- rescue URI::BadURIError, URI::InvalidURIError
62
- nil
63
- end
64
-
65
57
  def downcase?
66
58
  downcase == self
67
59
  end
@@ -79,14 +71,6 @@ class String
79
71
  "#{self[0, offset]}#{separator}#{self[-offset, offset]}"
80
72
  end
81
73
 
82
- def fragment
83
- return if empty?
84
-
85
- URI.parse(self).fragment
86
- rescue URI::BadURIError, URI::InvalidURIError
87
- nil
88
- end
89
-
90
74
  def format(*args)
91
75
  super(self, *args.flatten)
92
76
  end
@@ -99,14 +83,6 @@ class String
99
83
  replace(headerize)
100
84
  end
101
85
 
102
- def host
103
- return if empty?
104
-
105
- URI.parse(self).host
106
- rescue URI::BadURIError, URI::InvalidURIError
107
- nil
108
- end
109
-
110
86
  def humanize!(capitalize: true)
111
87
  replace(humanize(capitalize: capitalize))
112
88
  end
@@ -198,14 +174,6 @@ class String
198
174
  replace(parameterize(separator: separator))
199
175
  end
200
176
 
201
- def path
202
- return if empty?
203
-
204
- URI.parse(self).path
205
- rescue URI::BadURIError, URI::InvalidURIError
206
- nil
207
- end
208
-
209
177
  def pathize
210
178
  dup.pathize!
211
179
  end
@@ -251,14 +219,6 @@ class String
251
219
  replace(concat(string))
252
220
  end
253
221
 
254
- def query
255
- return if empty?
256
-
257
- URI.parse(self).query
258
- rescue URI::BadURIError, URI::InvalidURIError
259
- nil
260
- end
261
-
262
222
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
263
223
  def quote(type = :double, amount = nil)
264
224
  if type.is_a?(Integer)
@@ -348,14 +308,6 @@ class String
348
308
  replace(sample(separator))
349
309
  end
350
310
 
351
- def scheme
352
- return if empty?
353
-
354
- URI.parse(self).scheme
355
- rescue URI::BadURIError, URI::InvalidURIError
356
- nil
357
- end
358
-
359
311
  def shift(*patterns)
360
312
  dup.shift!(*patterns)
361
313
  end
@@ -451,6 +403,54 @@ class String
451
403
  self
452
404
  end
453
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
+
454
454
  def unshift(*patterns)
455
455
  patterns.each_with_object('') { |pat, str| str << pat }
456
456
  .concat(self)
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Ruby
5
5
 
6
- VERSION = '2.2.0'
6
+ VERSION = '2.3.0'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez