gorilla_patch 4.0.0 → 6.0.0
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 +4 -4
- data/CHANGELOG.md +154 -0
- data/LICENSE.txt +21 -0
- data/README.md +195 -0
- data/lib/gorilla_patch/blank.rb +7 -0
- data/lib/gorilla_patch/deep_dup.rb +11 -0
- data/lib/gorilla_patch/deep_merge.rb +1 -1
- data/lib/gorilla_patch/except.rb +0 -4
- data/lib/gorilla_patch/inflections.rb +5 -6
- data/lib/gorilla_patch/module_parent.rb +1 -1
- data/lib/gorilla_patch/truncate.rb +2 -3
- data/lib/gorilla_patch/version.rb +1 -1
- data/lib/gorilla_patch.rb +1 -1
- metadata +19 -151
- data/lib/gorilla_patch/compact.rb +0 -16
- data/lib/gorilla_patch/cover.rb +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5c9a322f4f8cd48f78e5520aa91b5b5c24a92152a79968cc0b911ce2ca3f3285
|
|
4
|
+
data.tar.gz: 792a20d4a77fa579a837de052731bb07696088c52dec07fdea2ba83ea312fb40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 88cf6bc3394dc20460364fda93ebcf9862a48fc52c6873f379ced7071e740492e04eec4cc8bd525bb5564f98d076020ec6c1cba6e5f93ab65eb5f3dabae46db2
|
|
7
|
+
data.tar.gz: b67a94f5c017b40629819a1388117374072e17936974fb1df6c7d19dc9003621c353ac4b9c14526bb9b8cd26f679ae1846b80f0ef6cfd1b6e447850f845307b4
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 6.0.0 (2026-02-08)
|
|
6
|
+
|
|
7
|
+
* Drop Ruby 3.0 and 3.1 support.
|
|
8
|
+
* Add Ruby 3.2, 3.3, 3.4 and 4.0 support.
|
|
9
|
+
* Improve documentation.
|
|
10
|
+
* Improve specs.
|
|
11
|
+
* Update development dependencies.
|
|
12
|
+
* Resolve new RuboCop offenses.
|
|
13
|
+
* Improve CI config.
|
|
14
|
+
|
|
15
|
+
## 5.0.1 (2022-09-24)
|
|
16
|
+
|
|
17
|
+
* Require stdlib `set` for `Inflections`.
|
|
18
|
+
|
|
19
|
+
## 5.0.0 (2022-09-24)
|
|
20
|
+
|
|
21
|
+
* Drop Ruby 2.4 support.
|
|
22
|
+
* Drop Ruby 2.5 support.
|
|
23
|
+
* Drop Ruby 2.6 support.
|
|
24
|
+
There was the latest patch-version, also `dry-inflector` stopped to support it.
|
|
25
|
+
* Drop Ruby 2.7 support.
|
|
26
|
+
There were no handy methods, like `Set#join`. Let's move on.
|
|
27
|
+
* Add Ruby 3.0 and 3.1 support.
|
|
28
|
+
|
|
29
|
+
* Populate default acronyms for `Inflections`.
|
|
30
|
+
* Fix order of default acronyms in `Inflections`.
|
|
31
|
+
* Change `Inflections.acronyms` from `Array` to `Set`.
|
|
32
|
+
* Improve implementation of `Cover`.
|
|
33
|
+
* Add `Module#deep_dup`.
|
|
34
|
+
* Fix `Blank` for classes, especially `Sequel::Model.`
|
|
35
|
+
|
|
36
|
+
* Update development dependencies.
|
|
37
|
+
* Resolve new RuboCop offenses.
|
|
38
|
+
* Update gemspec metadata.
|
|
39
|
+
* Improve CI.
|
|
40
|
+
|
|
41
|
+
## 4.0.0 (2020-06-06)
|
|
42
|
+
|
|
43
|
+
* Replace `inflecto` with `dry-inflector` (`.from_dry_inflector`)
|
|
44
|
+
* Drop unsupported Ruby 2.3 version
|
|
45
|
+
* Remove `GorillaPatch::Transform` (its methods in stdlib of Ruby >= 2.4)
|
|
46
|
+
* Improve dependencies versions locks
|
|
47
|
+
* Improve code style via new RuboCop cops
|
|
48
|
+
* Write more documentation
|
|
49
|
+
* Create LICENSE file
|
|
50
|
+
|
|
51
|
+
## 3.2.1 (2019-10-08)
|
|
52
|
+
|
|
53
|
+
* Fix `CHANGELOG` updating in `rake release` task
|
|
54
|
+
* Add `FAQ`, `SEO` and `UTM` to default acronyms for `Inflections`
|
|
55
|
+
|
|
56
|
+
## 3.2.0 (2019-10-07)
|
|
57
|
+
|
|
58
|
+
* Add `Object#blank?`
|
|
59
|
+
* Add `Module#module_parent_name` and `Module#module_parent`
|
|
60
|
+
|
|
61
|
+
## 3.0.1 (2018-07-10)
|
|
62
|
+
|
|
63
|
+
* Change `Hash#deep_merge` to do `#deep_dup` for nested objects duplicating
|
|
64
|
+
|
|
65
|
+
## 3.0.0 (2018-05-15)
|
|
66
|
+
|
|
67
|
+
* Add acronyms for `GorillaPatch::Inflections` (#3)
|
|
68
|
+
* Rename `gorilla-patch` to `gorilla_patch`
|
|
69
|
+
* Drop Ruby 2.1 and 2.2 support
|
|
70
|
+
* Add CHANGELOG (yay!)
|
|
71
|
+
|
|
72
|
+
## 2.9.1 (2018-03-26)
|
|
73
|
+
|
|
74
|
+
* Fix `GorillaPatch::Blank` for `Range` (or another `Enumerable`) inside Array or Hash
|
|
75
|
+
|
|
76
|
+
## 2.9.0 (2018-01-20)
|
|
77
|
+
|
|
78
|
+
* Add `nils` option for `Hash#slice*` methods
|
|
79
|
+
|
|
80
|
+
## 2.8.0 (2018-01-17)
|
|
81
|
+
|
|
82
|
+
* Add `[Array, Hash]#nilify_blank_strings{,!}` in `GorillaPatch::Blank`
|
|
83
|
+
|
|
84
|
+
## 2.7.0 (2017-12-26)
|
|
85
|
+
|
|
86
|
+
* Add Ruby 2.5 support
|
|
87
|
+
|
|
88
|
+
## 2.6.0 (2017-11-11)
|
|
89
|
+
|
|
90
|
+
* Add `Delegator#deep_dup` (for `Tempfile` and others) in `GorillaPatch::DeepDup`
|
|
91
|
+
|
|
92
|
+
## 2.5.1 (2017-09-08)
|
|
93
|
+
|
|
94
|
+
* Return `super` from `Hash#transform_values!` if defined
|
|
95
|
+
|
|
96
|
+
## 2.5.0 (2017-09-08)
|
|
97
|
+
|
|
98
|
+
* Add `GorillaPatch::Transform` with `Hash#transform_values{,!}`
|
|
99
|
+
|
|
100
|
+
## 2.4.3 (2017-09-08)
|
|
101
|
+
|
|
102
|
+
* Fix bug (come from `ActiveSupport`) with `Hash#deep_merge!`
|
|
103
|
+
|
|
104
|
+
## 2.4.2 (2017-09-08)
|
|
105
|
+
|
|
106
|
+
* Revert dynamic defining `GorillaPatch::Namespace` methods for `Module`
|
|
107
|
+
|
|
108
|
+
## 2.4.1 (2017-09-08)
|
|
109
|
+
|
|
110
|
+
* Fix `GorillaPatch::Namespace` methods for Modules without names (`Module.new` or `Class.new`)
|
|
111
|
+
|
|
112
|
+
## 2.4.0 (2017-08-10)
|
|
113
|
+
|
|
114
|
+
* Add `[String, Module]#deconstantize` method in `GorillaPatch::Namespace`
|
|
115
|
+
|
|
116
|
+
## 2.3.1 (2017-08-10)
|
|
117
|
+
|
|
118
|
+
* Fix bug with `Class#demodulize` if class was patched with private method
|
|
119
|
+
|
|
120
|
+
## 2.3.0 (2017-07-25)
|
|
121
|
+
|
|
122
|
+
* Add `GorillaPatch::DigEmpty` for `Hash#dig` without arguments
|
|
123
|
+
|
|
124
|
+
## 2.2.1 (2017-07-23)
|
|
125
|
+
|
|
126
|
+
* Add `GorillaPatch::DeepMerge` module with `Hash#deep_merge{,!}` methods
|
|
127
|
+
|
|
128
|
+
## 2.1.1 (2017-01-25)
|
|
129
|
+
|
|
130
|
+
* Add `NilClass#blank?` method in `GorillaPatch::Blank`
|
|
131
|
+
|
|
132
|
+
## 2.1.0 (2017-01-19)
|
|
133
|
+
|
|
134
|
+
* Add `GorillaPatch::Truncate` with `String#truncate`
|
|
135
|
+
|
|
136
|
+
## 2.0.0 (2017-01-13)
|
|
137
|
+
|
|
138
|
+
* Merge `GorillaPatch::LettersCase` and `GorillaPatch::Quantity` into `GorillaPatch::Inflections`
|
|
139
|
+
* Add `GorillaPatch::Inflections.from_inflecto` (`inflecto-refinements` gem)
|
|
140
|
+
* Rename `GorillaPatch::Include` to `GorillaPatch::Cover`
|
|
141
|
+
* Return `Hash` after `Hash#compact!`
|
|
142
|
+
* Add specs for all modules
|
|
143
|
+
|
|
144
|
+
## 1.0.2 (2016-12-29)
|
|
145
|
+
|
|
146
|
+
* Fix `String#camelize` method for camelized strings
|
|
147
|
+
|
|
148
|
+
## 1.0.1 (2016-11-10)
|
|
149
|
+
|
|
150
|
+
* Fix issue with `[Array, Hash]#reject_blank_strings{,!}`
|
|
151
|
+
|
|
152
|
+
## 1.0.0 (2016-11-10)
|
|
153
|
+
|
|
154
|
+
* Rename `GorillaPatch` modules from "which class refined" to "what it does"
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Alexander Popov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Gorilla Patch
|
|
2
|
+
|
|
3
|
+
[](https://cirrus-ci.com/github/AlexWayfer/gorilla_patch)
|
|
4
|
+
[](https://codecov.io/gh/AlexWayfer/gorilla_patch)
|
|
5
|
+
[](https://codeclimate.com/github/AlexWayfer/gorilla_patch)
|
|
6
|
+
[](https://depfu.com/repos/github/AlexWayfer/gorilla_patch)
|
|
7
|
+
[](https://inch-ci.org/github/AlexWayfer/gorilla_patch)
|
|
8
|
+
[](https://github.com/AlexWayfer/gorilla_patch/blob/main/LICENSE.txt)
|
|
9
|
+
[](https://rubygems.org/gems/gorilla_patch)
|
|
10
|
+
|
|
11
|
+
Ruby Gem for refine Ruby Core classes (like [Monkey patch](https://en.wikipedia.org/wiki/Monkey_patch)).
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
$ gem install gorilla_patch
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
or with `bundler`:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
# Gemfile
|
|
23
|
+
gem 'gorilla_patch'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
require 'gorilla_patch' # or 'gorilla_patch/keys' for specific functionallity
|
|
30
|
+
|
|
31
|
+
hash = { a: 1, b: 2 }
|
|
32
|
+
|
|
33
|
+
hash.keys? :a, :b # undefined method!
|
|
34
|
+
|
|
35
|
+
module Foo
|
|
36
|
+
using GorillaPatch::Keys
|
|
37
|
+
|
|
38
|
+
hash.keys? :a, :b # true
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
hash.keys? :a, :b # undefined method!
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### What is `using`?
|
|
45
|
+
|
|
46
|
+
[It's standard feature](http://ruby-doc.org/core/doc/syntax/refinements_rdoc.html).
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### What if a method was implemented in new Ruby versions?
|
|
50
|
+
|
|
51
|
+
Then native method in usage, not a custom implementation.
|
|
52
|
+
|
|
53
|
+
For example, `Hash#except`.
|
|
54
|
+
|
|
55
|
+
Before custom method declaration there is a check for current Ruby version.
|
|
56
|
+
|
|
57
|
+
## Methods
|
|
58
|
+
|
|
59
|
+
* **Blank**
|
|
60
|
+
|
|
61
|
+
* **`String`**, **`NilClass`**
|
|
62
|
+
|
|
63
|
+
* `#blank?`
|
|
64
|
+
|
|
65
|
+
* **`Array`**, **`Hash`**
|
|
66
|
+
|
|
67
|
+
* `#reject_blank_strings`
|
|
68
|
+
|
|
69
|
+
* `#reject_blank_strings!`
|
|
70
|
+
|
|
71
|
+
* `#nilify_blank_strings`
|
|
72
|
+
|
|
73
|
+
* `#nilify_blank_strings!`
|
|
74
|
+
|
|
75
|
+
* **Compact**
|
|
76
|
+
|
|
77
|
+
* **`Hash`**
|
|
78
|
+
|
|
79
|
+
* `#compact`
|
|
80
|
+
|
|
81
|
+
* `#compact!`
|
|
82
|
+
|
|
83
|
+
* **DeepDup**
|
|
84
|
+
|
|
85
|
+
* **`Object`**, **`Hash`**, **`Array`**, **`Module`**, **`Delegator`**
|
|
86
|
+
|
|
87
|
+
* `#deep_dup`
|
|
88
|
+
|
|
89
|
+
* **DeepMerge**
|
|
90
|
+
|
|
91
|
+
* **`Hash`**
|
|
92
|
+
|
|
93
|
+
* `#deep_merge(other_hash, &block)`
|
|
94
|
+
|
|
95
|
+
* `#deep_merge!(other_hash, &block)`
|
|
96
|
+
|
|
97
|
+
* **DigEmpty**
|
|
98
|
+
|
|
99
|
+
* **`Hash`**
|
|
100
|
+
|
|
101
|
+
* `#dig()`
|
|
102
|
+
|
|
103
|
+
* **Except**
|
|
104
|
+
|
|
105
|
+
* **`Hash`**
|
|
106
|
+
|
|
107
|
+
* `#except(*)`
|
|
108
|
+
|
|
109
|
+
* `#except!(*)`
|
|
110
|
+
|
|
111
|
+
* **Inflections**
|
|
112
|
+
|
|
113
|
+
* `.acronyms`
|
|
114
|
+
|
|
115
|
+
* `.from_sequel`
|
|
116
|
+
|
|
117
|
+
* `.from_dry_inflector`
|
|
118
|
+
|
|
119
|
+
* **`String`**, **`Module`**
|
|
120
|
+
|
|
121
|
+
* `#underscore`
|
|
122
|
+
|
|
123
|
+
* **`String`**
|
|
124
|
+
|
|
125
|
+
* `#camelize`
|
|
126
|
+
|
|
127
|
+
* **Keys**
|
|
128
|
+
|
|
129
|
+
* **`Hash`**
|
|
130
|
+
|
|
131
|
+
* `#keys?(*)`
|
|
132
|
+
|
|
133
|
+
* **ModuleParent**
|
|
134
|
+
* **`Module`**
|
|
135
|
+
|
|
136
|
+
* `#module_parent_name`
|
|
137
|
+
|
|
138
|
+
* `#module_parent`
|
|
139
|
+
|
|
140
|
+
* **Namespace**
|
|
141
|
+
* **`String`**, **`Module`**, **`Class`**
|
|
142
|
+
|
|
143
|
+
* `#demodulize`
|
|
144
|
+
|
|
145
|
+
* `#deconstantize`
|
|
146
|
+
|
|
147
|
+
* **Slice**
|
|
148
|
+
|
|
149
|
+
* **`Hash`**
|
|
150
|
+
|
|
151
|
+
* `#slice(*, nils: false)`
|
|
152
|
+
|
|
153
|
+
* `#slice!(*, nils: false)`
|
|
154
|
+
|
|
155
|
+
* `#slice_reverse!(*, nils: false)`
|
|
156
|
+
|
|
157
|
+
* **Symbolize**
|
|
158
|
+
|
|
159
|
+
* **`Hash`**
|
|
160
|
+
|
|
161
|
+
* `#symbolize_keys(deep: false)`
|
|
162
|
+
|
|
163
|
+
* `#symbolize_keys!(deep: false)`
|
|
164
|
+
|
|
165
|
+
* **Truncate**
|
|
166
|
+
|
|
167
|
+
* **`String`**
|
|
168
|
+
|
|
169
|
+
* `#truncate(position, separator: '', omission: '...')`
|
|
170
|
+
|
|
171
|
+
## Testing
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
$ rake spec
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Development
|
|
178
|
+
|
|
179
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
|
180
|
+
|
|
181
|
+
Then, run `toys rspec` to run the tests.
|
|
182
|
+
|
|
183
|
+
To install this gem onto your local machine, run `toys gem install`.
|
|
184
|
+
|
|
185
|
+
To release a new version, run `toys gem release %version%`.
|
|
186
|
+
See how it works [here](https://github.com/AlexWayfer/gem_toys#release).
|
|
187
|
+
|
|
188
|
+
## Contributing
|
|
189
|
+
|
|
190
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/AlexWayfer/gorilla_patch).
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
The gem is available as open source under the terms of the
|
|
195
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
data/lib/gorilla_patch/blank.rb
CHANGED
|
@@ -23,6 +23,13 @@ module GorillaPatch
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
## Also affects `Class`, including `Sequel::Model` with `.empty?`
|
|
27
|
+
refine Module do
|
|
28
|
+
def blank?
|
|
29
|
+
false
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
26
33
|
# rubocop:disable Metrics/BlockLength
|
|
27
34
|
REFINED_ENUMERABLES = [Array, Hash].freeze
|
|
28
35
|
|
|
@@ -23,6 +23,17 @@ module GorillaPatch
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
refine Module do
|
|
27
|
+
def deep_dup
|
|
28
|
+
result = super
|
|
29
|
+
constants(false).each do |constant|
|
|
30
|
+
result.send :remove_const, constant
|
|
31
|
+
result.const_set constant, const_get(constant).deep_dup
|
|
32
|
+
end
|
|
33
|
+
result
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
26
37
|
require 'delegate'
|
|
27
38
|
|
|
28
39
|
refine Delegator do
|
|
@@ -28,7 +28,7 @@ module GorillaPatch
|
|
|
28
28
|
self[other_key] =
|
|
29
29
|
if self_value.is_a?(Hash) && other_value.is_a?(Hash)
|
|
30
30
|
self_value.deep_merge!(other_value, &block)
|
|
31
|
-
elsif
|
|
31
|
+
elsif block && key?(other_key)
|
|
32
32
|
yield(other_key, self_value, other_value)
|
|
33
33
|
else
|
|
34
34
|
other_value
|
data/lib/gorilla_patch/except.rb
CHANGED
|
@@ -6,9 +6,9 @@ module GorillaPatch
|
|
|
6
6
|
class << self
|
|
7
7
|
## Set of acronyms which can be modified externally
|
|
8
8
|
def acronyms
|
|
9
|
-
@acronyms ||=
|
|
10
|
-
API DateTime FAQ HTML HTTP HTTPS ID IP JSON SEO SSL UTM XML
|
|
11
|
-
|
|
9
|
+
@acronyms ||= Set.new(
|
|
10
|
+
%w[API CLI DB DateTime FAQ HTML HTTP HTTPS ID IP JSON SEO SSL UTM XML]
|
|
11
|
+
)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
## Regular expression for detecting known acronyms
|
|
@@ -71,8 +71,7 @@ module GorillaPatch
|
|
|
71
71
|
def define_methods_from_sequel
|
|
72
72
|
Sequel::Inflections.private_instance_methods.each do |method_name|
|
|
73
73
|
define_method method_name do
|
|
74
|
-
Sequel::Inflections.instance_method(method_name)
|
|
75
|
-
.bind(self).call(self)
|
|
74
|
+
Sequel::Inflections.instance_method(method_name).bind_call(self, self)
|
|
76
75
|
end
|
|
77
76
|
end
|
|
78
77
|
end
|
|
@@ -101,7 +100,7 @@ module GorillaPatch
|
|
|
101
100
|
def define_methods_from_dry_inflector
|
|
102
101
|
inflector = Dry::Inflector.new
|
|
103
102
|
|
|
104
|
-
inflector.public_methods.each do |method_name|
|
|
103
|
+
inflector.public_methods(false).each do |method_name|
|
|
105
104
|
define_method method_name do
|
|
106
105
|
inflector.public_send method_name, self
|
|
107
106
|
end
|
|
@@ -8,7 +8,7 @@ module GorillaPatch
|
|
|
8
8
|
if defined?(@module_parent_name)
|
|
9
9
|
@module_parent_name
|
|
10
10
|
else
|
|
11
|
-
module_parent_name = name =~ /::[^:]+\Z/ ?
|
|
11
|
+
module_parent_name = name =~ /::[^:]+\Z/ ? Regexp.last_match.pre_match : nil
|
|
12
12
|
@module_parent_name = module_parent_name unless frozen?
|
|
13
13
|
module_parent_name
|
|
14
14
|
end
|
|
@@ -8,9 +8,8 @@ module GorillaPatch
|
|
|
8
8
|
return dup if length <= position
|
|
9
9
|
|
|
10
10
|
stop = position - omission.length
|
|
11
|
-
if separator.is_a?(Regexp) || !separator.empty?
|
|
12
|
-
|
|
13
|
-
end
|
|
11
|
+
stop = rindex(separator, stop) if separator.is_a?(Regexp) || !separator.empty?
|
|
12
|
+
|
|
14
13
|
"#{self[0, stop]}#{omission}"
|
|
15
14
|
end
|
|
16
15
|
end
|
data/lib/gorilla_patch.rb
CHANGED
metadata
CHANGED
|
@@ -1,165 +1,25 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gorilla_patch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Popov
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: codecov
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.1.0
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.1.0
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: pry-byebug
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '3.0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '3.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rake
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '13.0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '13.0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rspec
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '3.0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '3.0'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: rubocop
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.83.0
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.83.0
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: rubocop-performance
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - "~>"
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: '1.0'
|
|
90
|
-
type: :development
|
|
91
|
-
prerelease: false
|
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
-
requirements:
|
|
94
|
-
- - "~>"
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: '1.0'
|
|
97
|
-
- !ruby/object:Gem::Dependency
|
|
98
|
-
name: rubocop-rspec
|
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - "~>"
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: '1.0'
|
|
104
|
-
type: :development
|
|
105
|
-
prerelease: false
|
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
108
|
-
- - "~>"
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: '1.0'
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: simplecov
|
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
|
114
|
-
requirements:
|
|
115
|
-
- - "~>"
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: 0.18.0
|
|
118
|
-
type: :development
|
|
119
|
-
prerelease: false
|
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
-
requirements:
|
|
122
|
-
- - "~>"
|
|
123
|
-
- !ruby/object:Gem::Version
|
|
124
|
-
version: 0.18.0
|
|
125
|
-
- !ruby/object:Gem::Dependency
|
|
126
|
-
name: dry-inflector
|
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
|
128
|
-
requirements:
|
|
129
|
-
- - "~>"
|
|
130
|
-
- !ruby/object:Gem::Version
|
|
131
|
-
version: 0.2.0
|
|
132
|
-
type: :development
|
|
133
|
-
prerelease: false
|
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
-
requirements:
|
|
136
|
-
- - "~>"
|
|
137
|
-
- !ruby/object:Gem::Version
|
|
138
|
-
version: 0.2.0
|
|
139
|
-
- !ruby/object:Gem::Dependency
|
|
140
|
-
name: sequel
|
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
|
142
|
-
requirements:
|
|
143
|
-
- - "~>"
|
|
144
|
-
- !ruby/object:Gem::Version
|
|
145
|
-
version: '5.0'
|
|
146
|
-
type: :development
|
|
147
|
-
prerelease: false
|
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
-
requirements:
|
|
150
|
-
- - "~>"
|
|
151
|
-
- !ruby/object:Gem::Version
|
|
152
|
-
version: '5.0'
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
153
12
|
description: Refine Ruby Core classes with methods like Active Support.
|
|
154
13
|
email: alex.wayfer@gmail.com
|
|
155
14
|
executables: []
|
|
156
15
|
extensions: []
|
|
157
16
|
extra_rdoc_files: []
|
|
158
17
|
files:
|
|
18
|
+
- CHANGELOG.md
|
|
19
|
+
- LICENSE.txt
|
|
20
|
+
- README.md
|
|
159
21
|
- lib/gorilla_patch.rb
|
|
160
22
|
- lib/gorilla_patch/blank.rb
|
|
161
|
-
- lib/gorilla_patch/compact.rb
|
|
162
|
-
- lib/gorilla_patch/cover.rb
|
|
163
23
|
- lib/gorilla_patch/deep_dup.rb
|
|
164
24
|
- lib/gorilla_patch/deep_merge.rb
|
|
165
25
|
- lib/gorilla_patch/dig_empty.rb
|
|
@@ -175,8 +35,14 @@ files:
|
|
|
175
35
|
homepage: https://github.com/AlexWayfer/gorilla_patch
|
|
176
36
|
licenses:
|
|
177
37
|
- MIT
|
|
178
|
-
metadata:
|
|
179
|
-
|
|
38
|
+
metadata:
|
|
39
|
+
bug_tracker_uri: https://github.com/AlexWayfer/gorilla_patch/issues
|
|
40
|
+
changelog_uri: https://github.com/AlexWayfer/gorilla_patch/blob/v6.0.0/CHANGELOG.md
|
|
41
|
+
documentation_uri: http://www.rubydoc.info/gems/gorilla_patch/6.0.0
|
|
42
|
+
homepage_uri: https://github.com/AlexWayfer/gorilla_patch
|
|
43
|
+
rubygems_mfa_required: 'true'
|
|
44
|
+
source_code_uri: https://github.com/AlexWayfer/gorilla_patch
|
|
45
|
+
wiki_uri: https://github.com/AlexWayfer/gorilla_patch/wiki
|
|
180
46
|
rdoc_options: []
|
|
181
47
|
require_paths:
|
|
182
48
|
- lib
|
|
@@ -184,15 +50,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
184
50
|
requirements:
|
|
185
51
|
- - ">="
|
|
186
52
|
- !ruby/object:Gem::Version
|
|
187
|
-
version: 2
|
|
53
|
+
version: '3.2'
|
|
54
|
+
- - "<"
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '5'
|
|
188
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
58
|
requirements:
|
|
190
59
|
- - ">="
|
|
191
60
|
- !ruby/object:Gem::Version
|
|
192
61
|
version: '0'
|
|
193
62
|
requirements: []
|
|
194
|
-
rubygems_version:
|
|
195
|
-
signing_key:
|
|
63
|
+
rubygems_version: 4.0.3
|
|
196
64
|
specification_version: 4
|
|
197
65
|
summary: Refining core classes
|
|
198
66
|
test_files: []
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module GorillaPatch
|
|
4
|
-
## Adding compact methods
|
|
5
|
-
module Compact
|
|
6
|
-
refine Hash do
|
|
7
|
-
def compact
|
|
8
|
-
select { |_key, value| !value.nil? }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def compact!
|
|
12
|
-
delete_if { |_key, value| value.nil? }
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
data/lib/gorilla_patch/cover.rb
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module GorillaPatch
|
|
4
|
-
## Adding include methods
|
|
5
|
-
module Cover
|
|
6
|
-
refine Range do
|
|
7
|
-
def cover?(value)
|
|
8
|
-
return super unless value.is_a?(Range) && RUBY_VERSION < '2.6'
|
|
9
|
-
|
|
10
|
-
super(value.first) && super(value.last)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|