ruby3-backward-compatibility 0.1.1 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51d70008eea3cb48c1da8481927fe88adb2bd1db0baa52f3fe523fd907115fe0
4
- data.tar.gz: 6edbd2094831aa71c11ea4b383e8b091b7c72ac2298fe6ee120856739a736951
3
+ metadata.gz: 9d573d3c08d404195e71dd9c7a1c4deee4de8c5277486c382f6be9fc633955a4
4
+ data.tar.gz: d854da5c1956e17bfb887a46f768828f96bd8dd8241568c4e1eaea768e2619dc
5
5
  SHA512:
6
- metadata.gz: da98f4615e945570a21273e18eca619c169899ee7c9c2c3163548c96ad99e592b3f872abb81427578ae5604f31cbb7fafce3893d608dba0ce73995f9f2f33146
7
- data.tar.gz: f6bc9922ae4b504b216c44dc38e01e19e2ea8b3b89e3fd171cee06fa7c887d8ad2b87e21d1ccfdaaf6a1661cbe5749b0349f5a21ef97630d66c6e517a9ef231d
6
+ metadata.gz: 35e33c63d438e5ea0d03ca0cdc5ca5f6938ab1b9cddcb02a2ea85a27580ee3cc5d83d11a721ada769abfefcdc30896e972dd07869639071bfc28bc4a98e374e4
7
+ data.tar.gz: 866e11431ce3380725f9d82a161729132359da6fff9587e2cd6db35d6ac43b187c3f62db42605a742194130db0a1bcf555c657934cc91c0efa0ae57dd8a4d4d9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2022-10-24
3
+ ## [0.1.3] - 2022-10-25
4
+
5
+ - Allow `ruby3_keywords` to work if method is also defined in a prepended module.
6
+
7
+ ## [0.1.2] - 2022-10-25
8
+
9
+ - `ruby3_keywords` does not change visibility of private or protected methods.
10
+
11
+ ## [0.1.1] - 2022-10-25
4
12
 
5
13
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby3-backward-compatibility (0.1.0)
4
+ ruby3-backward-compatibility (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -67,6 +67,8 @@ Ruby3Class.new.some_method({ foo: 'bar' }) # now works as well
67
67
 
68
68
  This will wrap the given method and convert a hash given as the last argument into keywords, similar to how it worked in Ruby 2.
69
69
 
70
+ *Note:* In case the method is also defined in a prepended module, you need to put the `extend Ruby3BackwardCompatibility::Ruby3Keywords` above the `prepend`.
71
+
70
72
  ### ERB
71
73
 
72
74
  `ERB.new` used to have the signature
@@ -1,13 +1,28 @@
1
1
  module Ruby3BackwardCompatibility
2
2
  module Ruby3Keywords
3
+ def self.extended(by)
4
+ # prepend the anonymous module now, so the user has a chance to control where exactly we will end
5
+ # up in the prepend chain...
6
+ by.send(:_ruby3_keywords_module)
7
+ end
8
+
3
9
  def ruby3_keywords(*methods)
4
10
  methods.each do |method|
11
+ method_is_private = private_instance_methods.include?(method)
12
+ method_is_protected = protected_instance_methods.include?(method)
13
+
5
14
  _ruby3_keywords_module.define_method(method) do |*args, **keyword_args|
6
15
  if args.last.is_a?(Hash)
7
16
  keyword_args.merge!(args.pop)
8
17
  end
9
18
  super(*args, **keyword_args)
10
19
  end
20
+
21
+ if method_is_private
22
+ _ruby3_keywords_module.send(:private, method)
23
+ elsif method_is_protected
24
+ _ruby3_keywords_module.send(:protected, method)
25
+ end
11
26
  end
12
27
  end
13
28
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ruby3BackwardCompatibility
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby3-backward-compatibility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  requirements: []
62
- rubygems_version: 3.3.7
62
+ rubygems_version: 3.2.3
63
63
  signing_key:
64
64
  specification_version: 4
65
65
  summary: Backward compatibility for Ruby 3 stdlib