rr 3.0.4 → 3.0.5

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: 303d118de2a2762d0b82b84ce5074540e77008a95805fb0b3b8df64872e3bb26
4
- data.tar.gz: 84a6e68fae515e2c5c1e6bed26dd55cbfba98e846e54d03b353266acb681a056
3
+ metadata.gz: 6d187dcfce0831255213627383d159a05f73412307407dc0b5a1771956780735
4
+ data.tar.gz: d85e6dbbdddc435ff00927e5892f2346ac1057cb48d2f21a2788d65be976b8e6
5
5
  SHA512:
6
- metadata.gz: c5b89becb9e9df041c472826206c92e0c9b9b6755246ce8e0c6bd84b81b5cb498c77222aaf22dbaa20f55b3315483dff85dd3b910f2ef16a0b4405d51c697dc9
7
- data.tar.gz: f590f980d6fb93a5c173efe8a0f85676402262bd4fcec944e9804602f2372426b2a78cd9e2120569520667e9eaf213e72cb70c5db08d62373bee831a2f75387e
6
+ metadata.gz: cc6bdb14cd6690ed0fd83da54c8165218647896e2bd505c882d2fbdfef424f069f7a67a95b481f5f382ccfde3625b87fbeb023abb70f17e8dd1788e88fb616c2
7
+ data.tar.gz: 13ce13bef3e88bb683083d2680176665368f8862742f956beabf23828a92a378ecadbd6c877f7d35f9e0cff6e84e98ba71450090cc0650e827f2107f3bf1f9ea
data/CHANGES.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.5 - 2021-06-26
4
+
5
+ ### Improvements
6
+
7
+ * Improved keyword arguments support on Ruby 2.7.
8
+ [GitHub#85][Patch by akira yamada]
9
+
10
+ ### Thanks
11
+
12
+ * akira yamada
13
+
3
14
  ## 3.0.4 - 2021-06-23
4
15
 
5
16
  ### Fixes
@@ -22,6 +22,7 @@ module RR
22
22
  def method_missing(method_name, *args, &block)
23
23
  @double_definition_create.call(method_name, args, {}, &block)
24
24
  end
25
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
25
26
  end
26
27
 
27
28
  def __double_definition_create__
@@ -36,8 +36,6 @@ module RR
36
36
  def permissive_argument
37
37
  if args.empty? and kwargs.empty?
38
38
  definition.with_any_args
39
- elsif kwargs.empty?
40
- definition.with(*args)
41
39
  else
42
40
  definition.with(*args, **kwargs)
43
41
  end
@@ -137,25 +137,15 @@ module RR
137
137
  id = BoundObjects.size
138
138
  BoundObjects[id] = subject_class
139
139
 
140
- if KeywordArguments.fully_supported? && KeywordArguments.accept_kwargs?(subject_class, method_name)
141
- subject_class.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
142
- def #{method_name}(*args, **kwargs, &block)
143
- ::RR::Injections::DoubleInjection::BoundObjects[#{id}].class_eval do
144
- remove_method(:#{method_name})
145
- end
146
- method_missing(:#{method_name}, *args, **kwargs, &block)
147
- end
148
- RUBY
149
- else
150
- subject_class.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
151
- def #{method_name}(*args, &block)
152
- ::RR::Injections::DoubleInjection::BoundObjects[#{id}].class_eval do
153
- remove_method(:#{method_name})
154
- end
155
- method_missing(:#{method_name}, *args, &block)
140
+ subject_class.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
141
+ def #{method_name}(*args, &block)
142
+ ::RR::Injections::DoubleInjection::BoundObjects[#{id}].class_eval do
143
+ remove_method(:#{method_name})
156
144
  end
157
- RUBY
158
- end
145
+ method_missing(:#{method_name}, *args, &block)
146
+ end
147
+ ruby2_keywords(:#{method_name}) if respond_to?(:ruby2_keywords, true)
148
+ RUBY
159
149
  self
160
150
  end
161
151
 
@@ -163,7 +153,7 @@ module RR
163
153
  id = BoundObjects.size
164
154
  BoundObjects[id] = subject_class
165
155
 
166
- if KeywordArguments.fully_supported? && KeywordArguments.accept_kwargs?(subject_class, method_name)
156
+ if KeywordArguments.fully_supported?
167
157
  subject_class.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
168
158
  def #{method_name}(*args, **kwargs, &block)
169
159
  arguments = MethodArguments.new(args, kwargs, block)
@@ -192,6 +182,7 @@ module RR
192
182
  arguments.block
193
183
  )
194
184
  end
185
+ ruby2_keywords(:#{method_name}) if respond_to?(:ruby2_keywords, true)
195
186
  RUBY
196
187
  end
197
188
  self
@@ -106,6 +106,7 @@ module RR
106
106
  ).call
107
107
  end
108
108
  end
109
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
109
110
  METHOD
110
111
  end
111
112
  end
@@ -1,7 +1,7 @@
1
1
  module RR
2
2
  module KeywordArguments
3
3
  class << self
4
- if (RUBY_VERSION <=> "2.7.0") >= 0
4
+ if (RUBY_VERSION <=> "3.0.0") >= 0
5
5
  def fully_supported?
6
6
  true
7
7
  end
@@ -10,12 +10,6 @@ module RR
10
10
  false
11
11
  end
12
12
  end
13
-
14
- def accept_kwargs?(subject_class, method_name)
15
- subject_class.instance_method(method_name).parameters.any? { |t, _| t == :key || t == :keyrest }
16
- rescue NameError
17
- true
18
- end
19
13
  end
20
14
  end
21
15
  end
@@ -31,7 +31,7 @@ module RR
31
31
 
32
32
  def call_original_method
33
33
  if subject_has_original_method?
34
- if KeywordArguments.fully_supported? && !kwargs.empty?
34
+ if KeywordArguments.fully_supported?
35
35
  subject.__send__(original_method_alias_name, *args, **kwargs, &block)
36
36
  else
37
37
  subject.__send__(original_method_alias_name, *args, &block)
@@ -53,7 +53,7 @@ module RR
53
53
  call_original_method
54
54
  else
55
55
  if implementation
56
- if KeywordArguments.fully_supported? && !kwargs.empty?
56
+ if KeywordArguments.fully_supported?
57
57
  implementation.call(*args, **kwargs, &block)
58
58
  else
59
59
  implementation.call(*args, &block)
@@ -52,7 +52,7 @@ module RR
52
52
  if double_injection = Injections::DoubleInjection.find(subject_class, method_name)
53
53
  double_injection.bind_method
54
54
  # The DoubleInjection takes care of calling double.method_call
55
- if KeywordArguments.fully_supported? && !kwargs.empty?
55
+ if KeywordArguments.fully_supported?
56
56
  subject.__send__(method_name, *args, **kwargs, &block)
57
57
  else
58
58
  subject.__send__(method_name, *args, &block)
data/lib/rr/space.rb CHANGED
@@ -22,6 +22,7 @@ module RR
22
22
  def method_missing(method_name, *args, &block)
23
23
  instance.__send__(method_name, *args, &block)
24
24
  end
25
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
25
26
  end
26
27
  end
27
28
 
data/lib/rr/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module RR
2
- VERSION = '3.0.4'.freeze
2
+ VERSION = '3.0.5'.freeze
3
3
  def self.version; VERSION; end
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rr
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-06-23 00:00:00.000000000 Z
13
+ date: 2021-06-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler