ruby-next-core 1.0.0.rc.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +9 -6
- data/lib/.rbnext/2.1/ruby-next/commands/nextify.rb +1 -1
- data/lib/.rbnext/2.1/ruby-next/language.rb +5 -2
- data/lib/.rbnext/2.3/ruby-next/commands/nextify.rb +1 -1
- data/lib/.rbnext/2.3/ruby-next/config.rb +2 -2
- data/lib/.rbnext/2.3/ruby-next/core/data.rb +4 -0
- data/lib/.rbnext/2.3/ruby-next/language/eval.rb +4 -4
- data/lib/.rbnext/2.6/ruby-next/core/data.rb +4 -0
- data/lib/.rbnext/2.7/ruby-next/core/data.rb +4 -0
- data/lib/ruby-next/commands/nextify.rb +1 -1
- data/lib/ruby-next/config.rb +2 -2
- data/lib/ruby-next/core/data.rb +4 -0
- data/lib/ruby-next/language/eval.rb +4 -4
- data/lib/ruby-next/language/parser.rb +8 -5
- data/lib/ruby-next/language/rewriters/3.1/shorthand_hash.rb +2 -1
- data/lib/ruby-next/language.rb +5 -2
- data/lib/ruby-next/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ad6cea22baa599e5a6edeb4fdda1fb7c9bd0b0d5617fb01cf4450374c7d9443
|
4
|
+
data.tar.gz: fa39e7d51cdf70c32dc2067000023e42dbe3b23bd1d8bf520e06a3a028d63b8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7df787bfa90d036bbd45c7bd2dbc85f3513d922b3606dfde12ade0196f7ccb6789aba263d407fc012c7b4625d38b4aa6d7df05a5ac4e784b3b9cfc5db356b0f
|
7
|
+
data.tar.gz: a4c364d32b19003c219670096dd6420d415663445d68deb7e92c8d9763cc705884e7ab7e43fed81c6c084450f6a32e14bd8b50f24629256cb064c84a8bb87583
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 1.0.1 (2024-01-28)
|
6
|
+
|
7
|
+
- Fix using Data with inheritance (`class X < Data.define(...)`). ([@palkan][])
|
8
|
+
|
9
|
+
## 1.0.0 🎄
|
10
|
+
|
5
11
|
- Add `it` block parameter support. ([@palkan][])
|
6
12
|
|
7
13
|
- Deprecate AST transpiling mode. ([@palkan][])
|
@@ -20,7 +26,7 @@
|
|
20
26
|
|
21
27
|
- Use `.rbnextrc` arguments for runtime transpiling and auto-transpiling gems. ([@palkan][])
|
22
28
|
|
23
|
-
- Stop testing Ruby <2.
|
29
|
+
- Stop testing Ruby <2.4. ([@palkan][])
|
24
30
|
|
25
31
|
- Extract `require-hooks`. ([@palkan][])
|
26
32
|
|
data/README.md
CHANGED
@@ -127,7 +127,7 @@ First, install a gem:
|
|
127
127
|
gem "ruby-next-core"
|
128
128
|
|
129
129
|
# gemspec
|
130
|
-
spec.add_dependency "ruby-next-core"
|
130
|
+
spec.add_dependency "ruby-next-core", "~> 1.0"
|
131
131
|
```
|
132
132
|
|
133
133
|
**NOTE:** we use a different gem for _distribution_, `ruby-next-core`, to provide a zero-dependency, polyfills-only version.
|
@@ -170,6 +170,10 @@ Ruby 3.2 has introduced a new core class—[Data](https://bugs.ruby-lang.org/iss
|
|
170
170
|
|
171
171
|
If you want to opt-out from loading Data backport, you must set the `RUBY_NEXT_DISABLE_DATA` env variable to `true`.
|
172
172
|
|
173
|
+
#### Known limitations
|
174
|
+
|
175
|
+
Currently, passing Hash as a last positional argument to `Data.new` is not supported in Ruby <3.0 (due to the difference in keyword arguments handling). We recommend always using keyword arguments when initializing Data objects.
|
176
|
+
|
173
177
|
## Transpiling
|
174
178
|
|
175
179
|
Ruby Next allows you to transpile\* edge Ruby syntax to older versions.
|
@@ -182,10 +186,10 @@ Installation:
|
|
182
186
|
|
183
187
|
```ruby
|
184
188
|
# Gemfile
|
185
|
-
gem "ruby-next"
|
189
|
+
gem "ruby-next", "~> 1.0"
|
186
190
|
|
187
191
|
# gemspec
|
188
|
-
spec.add_dependency "ruby-next"
|
192
|
+
spec.add_dependency "ruby-next", "~> 1.0"
|
189
193
|
```
|
190
194
|
|
191
195
|
```sh
|
@@ -222,7 +226,6 @@ Usage: ruby-next nextify DIRECTORY_OR_FILE [options]
|
|
222
226
|
--overwrite Overwrites the original file with one version of --single-version (works only with --single-version or --rewrite)
|
223
227
|
--edge Enable edge (master) Ruby features
|
224
228
|
--proposed Enable proposed/experimental Ruby features
|
225
|
-
--transpile-mode=MODE Transpiler mode (ast or rewrite). Default: ast
|
226
229
|
--[no-]refine Do not inject `using RubyNext`
|
227
230
|
--list-rewriters List available rewriters
|
228
231
|
--rewrite=REWRITERS... Specify particular Ruby features to rewrite
|
@@ -234,7 +237,7 @@ Usage: ruby-next nextify DIRECTORY_OR_FILE [options]
|
|
234
237
|
|
235
238
|
The behaviour depends on whether you transpile a single file or a directory:
|
236
239
|
|
237
|
-
- When transpiling a directory, the `.rbnext` subfolder is created within the target folder with subfolders for each supported Ruby versions (e.g., `.rbnext/2.
|
240
|
+
- When transpiling a directory, the `.rbnext` subfolder is created within the target folder with subfolders for each supported Ruby versions (e.g., `.rbnext/2.7`, `.rbnext/3.1`, `.rbnext/3.4`, etc.). If you want to create only a single version (the smallest), you can also pass `--single-version` flag. In that case, no version directory is created (i.e., transpiled files go into `.rbnext`).
|
238
241
|
|
239
242
|
- When transpiling a file and providing the output path as a _file_ path, only a single version is created. For example:
|
240
243
|
|
@@ -300,7 +303,7 @@ Configuration file is a YAML with commands as keys and options as multiline stri
|
|
300
303
|
# ./.rbnextrc
|
301
304
|
|
302
305
|
nextify: |
|
303
|
-
--
|
306
|
+
--min-version=2.7
|
304
307
|
--edge
|
305
308
|
```
|
306
309
|
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
gem
|
4
|
-
|
3
|
+
# Checking gem specs doesn't work in ruby.wasm
|
4
|
+
unless RUBY_PLATFORM.match?(/wasm/)
|
5
|
+
gem "ruby-next-parser", ">= 2.8.0.3"
|
6
|
+
gem "unparser", ">= 0.4.7"
|
7
|
+
end
|
5
8
|
|
6
9
|
require "set" # rubocop:disable Lint/RedundantRequireStatement
|
7
10
|
|
@@ -10,10 +10,10 @@ module RubyNext
|
|
10
10
|
# Defines last minor version for every major version
|
11
11
|
LAST_MINOR_VERSIONS = {
|
12
12
|
2 => 8, # 2.8 is required for backward compatibility: some gems already uses it
|
13
|
-
3 =>
|
13
|
+
3 => 4
|
14
14
|
}.freeze
|
15
15
|
|
16
|
-
LATEST_VERSION = [3,
|
16
|
+
LATEST_VERSION = [3, 4].freeze
|
17
17
|
|
18
18
|
# A virtual version number used for proposed features
|
19
19
|
NEXT_VERSION = "1995.next.0"
|
@@ -11,7 +11,7 @@ module RubyNext
|
|
11
11
|
using: ((((__safe_lvar__ = bind) || true) && (!__safe_lvar__.nil? || nil)) && __safe_lvar__.receiver) == TOPLEVEL_BINDING.receiver || ((((__safe_lvar__ = ((((__safe_lvar__ = bind) || true) && (!__safe_lvar__.nil? || nil)) && __safe_lvar__.receiver)) || true) && (!__safe_lvar__.nil? || nil)) && __safe_lvar__.is_a?(Module))
|
12
12
|
)
|
13
13
|
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
14
|
-
super
|
14
|
+
super(new_source, bind, *args)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -25,7 +25,7 @@ module RubyNext
|
|
25
25
|
source = args.shift
|
26
26
|
new_source = ::RubyNext::Language::Runtime.transform(source, using: false)
|
27
27
|
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
28
|
-
super
|
28
|
+
super(new_source, *args)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -39,7 +39,7 @@ module RubyNext
|
|
39
39
|
new_source = ::RubyNext::Language::Runtime.transform(source, using: false)
|
40
40
|
|
41
41
|
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
42
|
-
super
|
42
|
+
super(new_source, *args)
|
43
43
|
end
|
44
44
|
|
45
45
|
def class_eval(*args, &block)
|
@@ -48,7 +48,7 @@ module RubyNext
|
|
48
48
|
source = args.shift
|
49
49
|
new_source = ::RubyNext::Language::Runtime.transform(source, using: false)
|
50
50
|
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
51
|
-
super
|
51
|
+
super(new_source, *args)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
data/lib/ruby-next/config.rb
CHANGED
@@ -10,10 +10,10 @@ module RubyNext
|
|
10
10
|
# Defines last minor version for every major version
|
11
11
|
LAST_MINOR_VERSIONS = {
|
12
12
|
2 => 8, # 2.8 is required for backward compatibility: some gems already uses it
|
13
|
-
3 =>
|
13
|
+
3 => 4
|
14
14
|
}.freeze
|
15
15
|
|
16
|
-
LATEST_VERSION = [3,
|
16
|
+
LATEST_VERSION = [3, 4].freeze
|
17
17
|
|
18
18
|
# A virtual version number used for proposed features
|
19
19
|
NEXT_VERSION = "1995.next.0"
|
data/lib/ruby-next/core/data.rb
CHANGED
@@ -11,7 +11,7 @@ module RubyNext
|
|
11
11
|
using: bind&.receiver == TOPLEVEL_BINDING.receiver || bind&.receiver&.is_a?(Module)
|
12
12
|
)
|
13
13
|
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
14
|
-
super
|
14
|
+
super(new_source, bind, *args)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -25,7 +25,7 @@ module RubyNext
|
|
25
25
|
source = args.shift
|
26
26
|
new_source = ::RubyNext::Language::Runtime.transform(source, using: false)
|
27
27
|
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
28
|
-
super
|
28
|
+
super(new_source, *args)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -39,7 +39,7 @@ module RubyNext
|
|
39
39
|
new_source = ::RubyNext::Language::Runtime.transform(source, using: false)
|
40
40
|
|
41
41
|
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
42
|
-
super
|
42
|
+
super(new_source, *args)
|
43
43
|
end
|
44
44
|
|
45
45
|
def class_eval(*args, &block)
|
@@ -48,7 +48,7 @@ module RubyNext
|
|
48
48
|
source = args.shift
|
49
49
|
new_source = ::RubyNext::Language::Runtime.transform(source, using: false)
|
50
50
|
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
51
|
-
super
|
51
|
+
super(new_source, *args)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -34,7 +34,7 @@ module RubyNext
|
|
34
34
|
end
|
35
35
|
|
36
36
|
class << self
|
37
|
-
attr_accessor :parser_class
|
37
|
+
attr_accessor :parser_class, :parser_syntax_errors
|
38
38
|
|
39
39
|
def parser
|
40
40
|
parser_class.new(Builder.new).tap do |prs|
|
@@ -50,8 +50,8 @@ module RubyNext
|
|
50
50
|
end
|
51
51
|
|
52
52
|
parser.parse(buffer)
|
53
|
-
rescue
|
54
|
-
raise ::SyntaxError, e.message
|
53
|
+
rescue *parser_syntax_errors => e
|
54
|
+
raise ::SyntaxError, e.message, e.backtrace
|
55
55
|
end
|
56
56
|
|
57
57
|
def parse_with_comments(source, file = "(string)")
|
@@ -60,16 +60,19 @@ module RubyNext
|
|
60
60
|
end
|
61
61
|
|
62
62
|
parser.parse_with_comments(buffer)
|
63
|
-
rescue
|
64
|
-
raise ::SyntaxError, e.message
|
63
|
+
rescue *parser_syntax_errors => e
|
64
|
+
raise ::SyntaxError, e.message, e.backtrace
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
self.parser_syntax_errors = [::Parser::SyntaxError]
|
69
|
+
|
68
70
|
# Set up default parser
|
69
71
|
unless parser_class
|
70
72
|
self.parser_class = if defined?(::Parser::RubyNext)
|
71
73
|
::Parser::RubyNext
|
72
74
|
elsif defined?(::Parser::Prism)
|
75
|
+
parser_syntax_errors << ::Prism::ParserCompiler::CompilationError
|
73
76
|
::Parser::Prism
|
74
77
|
else
|
75
78
|
::Parser::Ruby33
|
@@ -9,7 +9,8 @@ module RubyNext
|
|
9
9
|
MIN_SUPPORTED_VERSION = Gem::Version.new("3.1.0")
|
10
10
|
|
11
11
|
def on_pair(node)
|
12
|
-
return super(node) unless node.children[0].loc.last_column == node.children[1].loc.last_column
|
12
|
+
return super(node) unless (node.children[0].loc.last_column == node.children[1].loc.last_column) &&
|
13
|
+
(node.children[1].loc.first_line == node.children[1].loc.last_line)
|
13
14
|
|
14
15
|
context.track! self
|
15
16
|
|
data/lib/ruby-next/language.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
gem
|
4
|
-
|
3
|
+
# Checking gem specs doesn't work in ruby.wasm
|
4
|
+
unless RUBY_PLATFORM.match?(/wasm/)
|
5
|
+
gem "ruby-next-parser", ">= 2.8.0.3"
|
6
|
+
gem "unparser", ">= 0.4.7"
|
7
|
+
end
|
5
8
|
|
6
9
|
require "set" # rubocop:disable Lint/RedundantRequireStatement
|
7
10
|
|
data/lib/ruby-next/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-next-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: require-hooks
|
@@ -220,9 +220,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
220
|
version: 2.2.0
|
221
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
222
|
requirements:
|
223
|
-
- - "
|
223
|
+
- - ">="
|
224
224
|
- !ruby/object:Gem::Version
|
225
|
-
version:
|
225
|
+
version: '0'
|
226
226
|
requirements: []
|
227
227
|
rubygems_version: 3.4.20
|
228
228
|
signing_key:
|