lite-ruby 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/docs/ARRAY.md +10 -0
- data/lib/lite/ruby/array.rb +0 -1
- data/lib/lite/ruby/hash.rb +5 -5
- data/lib/lite/ruby/safe/array.rb +8 -0
- data/lib/lite/ruby/safe/string.rb +20 -19
- data/lib/lite/ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9698ba1912f845b31a817812d15ed70ed57b79ab30dc5bfd3708b02ef9838ef
|
4
|
+
data.tar.gz: 2acb14111968be548e83b9543af2e2076214a31ced8b8c1b155a4ddfeec5198c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a1c8802ec234da2307f028f34a3ce4665a7b67c1a987e39799bdb5b5ec5711018b787b5a80d678ee6bcd078f5bd9d9a5ce94118b681014160aaf2be51fc5185
|
7
|
+
data.tar.gz: 7dc0c0225a8e5595e770145e3b26bedfce80f9d1b1103f4ab0290f9369d3abd06c3f44be81d44dd5129752900dc473792fb4e4ad3b34d1e3888adaf4f9e96eca
|
data/CHANGELOG.md
CHANGED
@@ -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`
|
data/Gemfile.lock
CHANGED
data/docs/ARRAY.md
CHANGED
@@ -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.
|
data/lib/lite/ruby/array.rb
CHANGED
data/lib/lite/ruby/hash.rb
CHANGED
@@ -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
|
345
|
-
str
|
346
|
-
str
|
347
|
-
str
|
348
|
-
str
|
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
|
data/lib/lite/ruby/safe/array.rb
CHANGED
@@ -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
|
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
|
56
|
-
str
|
57
|
-
str
|
58
|
-
str
|
59
|
-
str
|
60
|
-
str
|
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
|
89
|
-
str
|
90
|
-
str
|
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
|
116
|
-
str
|
117
|
-
str
|
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
|
168
|
-
str
|
169
|
-
str
|
170
|
-
str
|
171
|
-
str
|
172
|
-
str
|
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
|
|
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: 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-
|
11
|
+
date: 2020-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|