lite-ruby 1.1.1 → 1.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f597c253b81c6355a9ae743833feccd90ac05ba6a81d4999f9f38c8e3631bee
4
- data.tar.gz: 648dc86d5bb49d58fa7eeed633bb811724e783e92c385ea3743b268c27be4b6d
3
+ metadata.gz: e9698ba1912f845b31a817812d15ed70ed57b79ab30dc5bfd3708b02ef9838ef
4
+ data.tar.gz: 2acb14111968be548e83b9543af2e2076214a31ced8b8c1b155a4ddfeec5198c
5
5
  SHA512:
6
- metadata.gz: 5ae87db67f4e74672342cc4c5309aa733eb8e09816c2da8c03fef690bc4d182c19c3a94b473e6091e04d61835439a753f2e04e6418f255d2bcc325f546fcab17
7
- data.tar.gz: 59de994a412932844e3e0fbca147ac3e008c4b862f3aecb82940afb2ac77da43eead9fa82b7de3091616187ba66b53e19cfb9262d0c671c72562ef35cfe858f2
6
+ metadata.gz: 4a1c8802ec234da2307f028f34a3ce4665a7b67c1a987e39799bdb5b5ec5711018b787b5a80d678ee6bcd078f5bd9d9a5ce94118b681014160aaf2be51fc5185
7
+ data.tar.gz: 7dc0c0225a8e5595e770145e3b26bedfce80f9d1b1103f4ab0290f9369d3abd06c3f44be81d44dd5129752900dc473792fb4e4ad3b34d1e3888adaf4f9e96eca
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.1.2] - 2020-11-08
10
+ ### Changed
11
+ - Array `extract!` does not alias except
12
+ - Update string methods to mutate self
13
+
9
14
  ## [1.1.1] - 2020-11-08
10
15
  ### Changed
11
16
  - Revert String => `transliterize` to `transliterate`
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-ruby (1.1.1)
4
+ lite-ruby (1.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -163,6 +163,16 @@ Removes given values from the array.
163
163
  [1, 2, 3, 4].except(1, 3) #=> [2, 4]
164
164
  ```
165
165
 
166
+ `extract!`
167
+ ------
168
+ Removes and returns the elements for which the block returns a true value. If no block is given, an Enumerator is returned instead.
169
+
170
+ ```ruby
171
+ a1 = [1, 2, 3, 4]
172
+ a1.extract!(&:odd?) #=> [1, 3]
173
+ a1 #=> [2, 4]
174
+ ```
175
+
166
176
  `from`
167
177
  ------
168
178
  Returns the tail of the array from a given position.
@@ -271,7 +271,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
271
271
  self
272
272
  end
273
273
 
274
- alias extract! except!
275
274
  alias indices indexes
276
275
  alias reject_values except
277
276
  alias reject_values! except!
@@ -341,11 +341,11 @@ if Lite::Ruby.configuration.monkey_patches.include?('hash')
341
341
  each_with_object({}) do |(key, val), hash|
342
342
  new_key = begin
343
343
  str = key.dup.to_s
344
- str = str.gsub!(/::/, '/') || str
345
- str = str.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') || str
346
- str = str.gsub!(/([a-z\d])([A-Z])/, '\1_\2') || str
347
- str = str.tr!(' -', '_') || str
348
- str = str.downcase!
344
+ str.gsub!(/::/, '/') || str
345
+ str.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') || str
346
+ str.gsub!(/([a-z\d])([A-Z])/, '\1_\2') || str
347
+ str.tr!(' -', '_') || str
348
+ str.downcase!
349
349
  str.to_sym
350
350
  rescue StandardError
351
351
  key
@@ -6,6 +6,14 @@ class Array
6
6
  map(&:deep_dup)
7
7
  end
8
8
 
9
+ def extract!
10
+ return to_enum(:extract!) { size } unless block_given?
11
+
12
+ extracted_elements = []
13
+ reject! { |element| extracted_elements << element if yield(element) }
14
+ extracted_elements
15
+ end
16
+
9
17
  def from(position)
10
18
  self[position, size] || []
11
19
  end
@@ -16,8 +16,9 @@ class String
16
16
 
17
17
  def classify
18
18
  str = dup
19
- str = str.sub!(/.*\./, '')
19
+ str.sub!(/.*\./, '')
20
20
  str.camelize!
21
+ str || self
21
22
  end
22
23
 
23
24
  def constantize
@@ -52,12 +53,12 @@ class String
52
53
 
53
54
  def humanize(capitalize: true)
54
55
  str = dup
55
- str = str.underscore!
56
- str = str.delete_suffix!('_id')
57
- str = str.tr!('_', ' ')
58
- str = str.squish!
59
- str = str.gsub!(/([a-z\d]*)/i, &:downcase)
60
- str = str.gsub!(/\A\w/) { |s| capitalize ? s.upcase : s }
56
+ str.underscore!
57
+ str.delete_suffix!('_id')
58
+ str.tr!('_', ' ')
59
+ str.squish!
60
+ str.gsub!(/([a-z\d]*)/i, &:downcase)
61
+ str.gsub!(/\A\w/) { |s| capitalize ? s.upcase : s }
61
62
  str || self
62
63
  end
63
64
 
@@ -85,9 +86,9 @@ class String
85
86
 
86
87
  def parameterize(separator: '-')
87
88
  str = dup
88
- str = str.underscore!
89
- str = str.gsub!(/\s+/, separator)
90
- str = str.downcase!
89
+ str.underscore!
90
+ str.gsub!(/\s+/, separator)
91
+ str.downcase!
91
92
  str || self
92
93
  end
93
94
 
@@ -112,9 +113,9 @@ class String
112
113
 
113
114
  def titleize
114
115
  str = dup
115
- str = str.underscore!
116
- str = str.humanize!
117
- str = str.gsub!(/\b(?<!['’`])[a-z]/) { $&.capitalize }
116
+ str.underscore!
117
+ str.humanize!
118
+ str.gsub!(/\b(?<!['’`])[a-z]/) { $&.capitalize }
118
119
  str || self
119
120
  end
120
121
 
@@ -164,12 +165,12 @@ class String
164
165
 
165
166
  def underscore
166
167
  str = dup
167
- str = str.camelize!
168
- str = str.gsub!(/::/, '/')
169
- str = str.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
170
- str = str.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
171
- str = str.tr!('-', '_')
172
- str = str.downcase!
168
+ str.camelize!
169
+ str.gsub!(/::/, '/')
170
+ str.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
171
+ str.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
172
+ str.tr!('-', '_')
173
+ str.downcase!
173
174
  str || self
174
175
  end
175
176
 
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Ruby
5
5
 
6
- VERSION ||= '1.1.1'
6
+ VERSION ||= '1.1.2'
7
7
 
8
8
  end
9
9
  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.1
4
+ version: 1.1.2
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-08 00:00:00.000000000 Z
11
+ date: 2020-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler