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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f618a9accd72849acb0de7d39fcf58c09d8c9414dedc7257188cb8339329914
4
- data.tar.gz: 5f456d2c4456fa66e7124a0091e97c32c48d75dda722cfb9b5d76354a0164ef4
3
+ metadata.gz: aabed6279d43a45280eb596358b59ca87a5caac5471f277897d3b2e03de43b30
4
+ data.tar.gz: 6a8e023016eeb23f67edf6d784422ce3682fd17caed9abaf929060b3f4d42b38
5
5
  SHA512:
6
- metadata.gz: 0ee30ce1e21bfe1d7e397d75dbef5c8c5200dbb81a54e58d4cf5710c8bc110937eaa84a1bb2c52bdc2d1047a6bbcde2d17f9ae6bb50a6d3644df23f353190378
7
- data.tar.gz: 8875cdf86a4a913974491c25fcf6682bec7cfce866b67bc76be37b4777a34e661a14dee58f508e8465d35be0c2536370425fc978ce38beef482c14f0bef2bbbb
6
+ metadata.gz: 4c6e7cfefd3add89b69408e7570822c138c077a8c30e9ddec4769e8d42f59dae02291cc7e362b69935c3f7ff841280ecaad882921419ec8b9bcee1270f19ae58
7
+ data.tar.gz: b2b1ca556a29e02a65fb2d4e019b3ed18bca8aed7e1befe04ada9b69822ef7acf474b8a60da3e5effec1e6dfc51c0690028e08b91394efd79261eba71ff1b36f
@@ -2,4 +2,4 @@
2
2
 
3
3
  Dir.glob(
4
4
  File.join(__dir__, 'gorilla_patch', '*.rb')
5
- ).each { |file| require file }
5
+ ).sort.each { |file| require file }
@@ -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 { |el| el.deep_dup }
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
- Sequel::Inflections.private_instance_methods.each do |method|
57
- define_method method do
58
- Sequel::Inflections.instance_method(method).bind(self).call(self)
59
- end
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
- def self.from_inflecto
66
- require 'inflecto-refinements'
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
- Inflecto::Refinements
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GorillaPatch
4
- VERSION = '3.2.1'
4
+ VERSION = '4.0.0'
5
5
  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: 3.2.1
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: 2019-10-08 00:00:00.000000000 Z
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: '0'
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: '0'
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.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: 0.75.0
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: '0'
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: '0'
124
+ version: 0.18.0
83
125
  - !ruby/object:Gem::Dependency
84
- name: inflecto-refinements
126
+ name: dry-inflector
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
129
  - - "~>"
88
130
  - !ruby/object:Gem::Version
89
- version: '0'
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: '0'
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.3.0
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.0.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,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'blank'
4
-
5
- module GorillaPatch
6
- ## Adding blank methods
7
- module Present
8
- refine Object do
9
- using GorillaPatch::Blank
10
-
11
- def present?
12
- !blank?
13
- end
14
- end
15
- end
16
- end
@@ -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