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 +4 -4
- data/CHANGELOG.md +9 -1
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/ruby3_backward_compatibility/ruby3_keywords.rb +15 -0
- data/lib/ruby3_backward_compatibility/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d573d3c08d404195e71dd9c7a1c4deee4de8c5277486c382f6be9fc633955a4
|
4
|
+
data.tar.gz: d854da5c1956e17bfb887a46f768828f96bd8dd8241568c4e1eaea768e2619dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
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
|
|
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.
|
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
|
62
|
+
rubygems_version: 3.2.3
|
63
63
|
signing_key:
|
64
64
|
specification_version: 4
|
65
65
|
summary: Backward compatibility for Ruby 3 stdlib
|