gorilla_patch 3.2.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gorilla_patch.rb +1 -1
- data/lib/gorilla_patch/deep_dup.rb +1 -6
- data/lib/gorilla_patch/inflections.rb +50 -7
- data/lib/gorilla_patch/version.rb +1 -1
- metadata +64 -24
- data/lib/gorilla_patch/present.rb +0 -16
- data/lib/gorilla_patch/transform.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aabed6279d43a45280eb596358b59ca87a5caac5471f277897d3b2e03de43b30
|
4
|
+
data.tar.gz: 6a8e023016eeb23f67edf6d784422ce3682fd17caed9abaf929060b3f4d42b38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c6e7cfefd3add89b69408e7570822c138c077a8c30e9ddec4769e8d42f59dae02291cc7e362b69935c3f7ff841280ecaad882921419ec8b9bcee1270f19ae58
|
7
|
+
data.tar.gz: b2b1ca556a29e02a65fb2d4e019b3ed18bca8aed7e1befe04ada9b69822ef7acf474b8a60da3e5effec1e6dfc51c0690028e08b91394efd79261eba71ff1b36f
|
data/lib/gorilla_patch.rb
CHANGED
@@ -6,11 +6,6 @@ module GorillaPatch
|
|
6
6
|
refine Object do
|
7
7
|
def deep_dup
|
8
8
|
dup
|
9
|
-
rescue TypeError
|
10
|
-
# :nocov:
|
11
|
-
# For Ruby < 2.4: https://bugs.ruby-lang.org/issues/12979
|
12
|
-
self
|
13
|
-
# :nocov:
|
14
9
|
end
|
15
10
|
end
|
16
11
|
|
@@ -24,7 +19,7 @@ module GorillaPatch
|
|
24
19
|
|
25
20
|
refine Array do
|
26
21
|
def deep_dup
|
27
|
-
map
|
22
|
+
map(&:deep_dup)
|
28
23
|
end
|
29
24
|
end
|
30
25
|
|
@@ -4,12 +4,14 @@ module GorillaPatch
|
|
4
4
|
## Inflections
|
5
5
|
module Inflections
|
6
6
|
class << self
|
7
|
+
## Set of acronyms which can be modified externally
|
7
8
|
def acronyms
|
8
9
|
@acronyms ||= %w[
|
9
10
|
API DateTime FAQ HTML HTTP HTTPS ID IP JSON SEO SSL UTM XML
|
10
11
|
]
|
11
12
|
end
|
12
13
|
|
14
|
+
## Regular expression for detecting known acronyms
|
13
15
|
def acronyms_regex
|
14
16
|
/(?:(?<=([A-Z\d_]))|\b)((?i)#{acronyms.join('|')})(?=\b|[^a-z])/
|
15
17
|
end
|
@@ -48,24 +50,65 @@ module GorillaPatch
|
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
53
|
+
## Use inflections from Sequel
|
51
54
|
def self.from_sequel
|
52
55
|
@from_sequel ||= Module.new do
|
53
56
|
require 'sequel'
|
54
57
|
|
55
58
|
refine String do
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
extend MethodsFromSequel
|
60
|
+
|
61
|
+
define_methods_from_sequel
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
## Module for definition methods from Sequel
|
67
|
+
## https://sequel.jeremyevans.net/
|
68
|
+
module MethodsFromSequel
|
69
|
+
private
|
70
|
+
|
71
|
+
def define_methods_from_sequel
|
72
|
+
Sequel::Inflections.private_instance_methods.each do |method_name|
|
73
|
+
define_method method_name do
|
74
|
+
Sequel::Inflections.instance_method(method_name)
|
75
|
+
.bind(self).call(self)
|
60
76
|
end
|
61
77
|
end
|
62
78
|
end
|
63
79
|
end
|
64
80
|
|
65
|
-
|
66
|
-
|
81
|
+
private_constant :MethodsFromSequel
|
82
|
+
|
83
|
+
## Use inflections from DRY Inflector
|
84
|
+
## https://dry-rb.org/gems/dry-inflector/
|
85
|
+
def self.from_dry_inflector
|
86
|
+
@from_dry_inflector ||= Module.new do
|
87
|
+
require 'dry/inflector'
|
67
88
|
|
68
|
-
|
89
|
+
refine String do
|
90
|
+
extend MethodsFromDryInflector
|
91
|
+
|
92
|
+
define_methods_from_dry_inflector
|
93
|
+
end
|
94
|
+
end
|
69
95
|
end
|
96
|
+
|
97
|
+
## Module for definition methods from Dry::Inflector
|
98
|
+
module MethodsFromDryInflector
|
99
|
+
private
|
100
|
+
|
101
|
+
def define_methods_from_dry_inflector
|
102
|
+
inflector = Dry::Inflector.new
|
103
|
+
|
104
|
+
inflector.public_methods.each do |method_name|
|
105
|
+
define_method method_name do
|
106
|
+
inflector.public_send method_name, self
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
private_constant :MethodsFromDryInflector
|
70
113
|
end
|
71
114
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gorilla_patch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Popov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codecov
|
@@ -16,98 +16,140 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.1.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
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'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '13'
|
47
|
+
version: '13.0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '13'
|
54
|
+
version: '13.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3'
|
61
|
+
version: '3.0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3'
|
68
|
+
version: '3.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rubocop
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
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'
|
62
104
|
type: :development
|
63
105
|
prerelease: false
|
64
106
|
version_requirements: !ruby/object:Gem::Requirement
|
65
107
|
requirements:
|
66
108
|
- - "~>"
|
67
109
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
110
|
+
version: '1.0'
|
69
111
|
- !ruby/object:Gem::Dependency
|
70
112
|
name: simplecov
|
71
113
|
requirement: !ruby/object:Gem::Requirement
|
72
114
|
requirements:
|
73
115
|
- - "~>"
|
74
116
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
117
|
+
version: 0.18.0
|
76
118
|
type: :development
|
77
119
|
prerelease: false
|
78
120
|
version_requirements: !ruby/object:Gem::Requirement
|
79
121
|
requirements:
|
80
122
|
- - "~>"
|
81
123
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
124
|
+
version: 0.18.0
|
83
125
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
126
|
+
name: dry-inflector
|
85
127
|
requirement: !ruby/object:Gem::Requirement
|
86
128
|
requirements:
|
87
129
|
- - "~>"
|
88
130
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
131
|
+
version: 0.2.0
|
90
132
|
type: :development
|
91
133
|
prerelease: false
|
92
134
|
version_requirements: !ruby/object:Gem::Requirement
|
93
135
|
requirements:
|
94
136
|
- - "~>"
|
95
137
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
138
|
+
version: 0.2.0
|
97
139
|
- !ruby/object:Gem::Dependency
|
98
140
|
name: sequel
|
99
141
|
requirement: !ruby/object:Gem::Requirement
|
100
142
|
requirements:
|
101
143
|
- - "~>"
|
102
144
|
- !ruby/object:Gem::Version
|
103
|
-
version: '5'
|
145
|
+
version: '5.0'
|
104
146
|
type: :development
|
105
147
|
prerelease: false
|
106
148
|
version_requirements: !ruby/object:Gem::Requirement
|
107
149
|
requirements:
|
108
150
|
- - "~>"
|
109
151
|
- !ruby/object:Gem::Version
|
110
|
-
version: '5'
|
152
|
+
version: '5.0'
|
111
153
|
description: Refine Ruby Core classes with methods like Active Support.
|
112
154
|
email: alex.wayfer@gmail.com
|
113
155
|
executables: []
|
@@ -126,17 +168,15 @@ files:
|
|
126
168
|
- lib/gorilla_patch/keys.rb
|
127
169
|
- lib/gorilla_patch/module_parent.rb
|
128
170
|
- lib/gorilla_patch/namespace.rb
|
129
|
-
- lib/gorilla_patch/present.rb
|
130
171
|
- lib/gorilla_patch/slice.rb
|
131
172
|
- lib/gorilla_patch/symbolize.rb
|
132
|
-
- lib/gorilla_patch/transform.rb
|
133
173
|
- lib/gorilla_patch/truncate.rb
|
134
174
|
- lib/gorilla_patch/version.rb
|
135
175
|
homepage: https://github.com/AlexWayfer/gorilla_patch
|
136
176
|
licenses:
|
137
177
|
- MIT
|
138
178
|
metadata: {}
|
139
|
-
post_install_message:
|
179
|
+
post_install_message:
|
140
180
|
rdoc_options: []
|
141
181
|
require_paths:
|
142
182
|
- lib
|
@@ -144,15 +184,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
184
|
requirements:
|
145
185
|
- - ">="
|
146
186
|
- !ruby/object:Gem::Version
|
147
|
-
version: 2.
|
187
|
+
version: 2.4.0
|
148
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
189
|
requirements:
|
150
190
|
- - ">="
|
151
191
|
- !ruby/object:Gem::Version
|
152
192
|
version: '0'
|
153
193
|
requirements: []
|
154
|
-
rubygems_version: 3.
|
155
|
-
signing_key:
|
194
|
+
rubygems_version: 3.1.2
|
195
|
+
signing_key:
|
156
196
|
specification_version: 4
|
157
197
|
summary: Refining core classes
|
158
198
|
test_files: []
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GorillaPatch
|
4
|
-
## Module for transformations methods
|
5
|
-
module Transform
|
6
|
-
refine Hash do
|
7
|
-
def transform_values
|
8
|
-
return super if defined? super
|
9
|
-
|
10
|
-
each_with_object(self.class.new) do |(key, value), result|
|
11
|
-
result[key] = yield value
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def transform_values!
|
16
|
-
return super if defined? super
|
17
|
-
|
18
|
-
each do |key, value|
|
19
|
-
self[key] = yield value
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|