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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 898de1113136ed6652275e5a83ee7e2866bf287ec1533dee71ffefdaf4f8fcae
4
- data.tar.gz: 5ccd6bb1f8256c048d9bd18246b0ab372770500111ed265c775ab37498d6814c
3
+ metadata.gz: 5ad6cea22baa599e5a6edeb4fdda1fb7c9bd0b0d5617fb01cf4450374c7d9443
4
+ data.tar.gz: fa39e7d51cdf70c32dc2067000023e42dbe3b23bd1d8bf520e06a3a028d63b8d
5
5
  SHA512:
6
- metadata.gz: 36876dea9517b88f1390bfe72781f77b13f00c5020079476f485f90642b8d8ec66061e2f3693f1cb2c350e9ccdb3a63f1e4c965b4f7010e36cbb226e5a8e7682
7
- data.tar.gz: 24d8e22d98e9a3a33a29237b27b02e195bea98d6dda5d1fadb3f5a0ba5a9664bf205b783299f6ed7aeda6879396129a590dbe3aaf7a9e65072b9c4ef9caddfef
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.3. ([@palkan][])
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.6`, `.rbnext/2.7`, `.rbnext/3.0`, 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`).
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
- --transpiler-mode=rewrite
306
+ --min-version=2.7
304
307
  --edge
305
308
  ```
306
309
 
@@ -280,7 +280,7 @@ module RubyNext
280
280
  end
281
281
 
282
282
  def next_dir_path
283
- @next_dir_path ||= (out_path || File.join(lib_path, RUBY_NEXT_DIR))
283
+ @next_dir_path ||= out_path || File.join(lib_path, RUBY_NEXT_DIR)
284
284
  end
285
285
 
286
286
  def stdout?
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- gem "ruby-next-parser", ">= 2.8.0.3"
4
- gem "unparser", ">= 0.4.7"
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
 
@@ -280,7 +280,7 @@ module RubyNext
280
280
  end
281
281
 
282
282
  def next_dir_path
283
- @next_dir_path ||= (out_path || File.join(lib_path, RUBY_NEXT_DIR))
283
+ @next_dir_path ||= out_path || File.join(lib_path, RUBY_NEXT_DIR)
284
284
  end
285
285
 
286
286
  def stdout?
@@ -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 => 1
13
+ 3 => 4
14
14
  }.freeze
15
15
 
16
- LATEST_VERSION = [3, 1].freeze
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"
@@ -66,6 +66,10 @@ if !Object.const_defined?(:Data) || !Data.respond_to?(:define)
66
66
  klass
67
67
  end
68
68
 
69
+ def self.inherited(subclass)
70
+ subclass.instance_variable_set(:@members, members)
71
+ end
72
+
69
73
  def members
70
74
  self.class.members
71
75
  end
@@ -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 new_source, bind, *args
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 new_source, *args
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 new_source, *args
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 new_source, *args
51
+ super(new_source, *args)
52
52
  end
53
53
  end
54
54
  end
@@ -66,6 +66,10 @@ if !Object.const_defined?(:Data) || !Data.respond_to?(:define)
66
66
  klass
67
67
  end
68
68
 
69
+ def self.inherited(subclass)
70
+ subclass.instance_variable_set(:@members, members)
71
+ end
72
+
69
73
  def members
70
74
  self.class.members
71
75
  end
@@ -66,6 +66,10 @@ if !Object.const_defined?(:Data) || !Data.respond_to?(:define)
66
66
  klass
67
67
  end
68
68
 
69
+ def self.inherited(subclass)
70
+ subclass.instance_variable_set(:@members, members)
71
+ end
72
+
69
73
  def members
70
74
  self.class.members
71
75
  end
@@ -282,7 +282,7 @@ module RubyNext
282
282
  end
283
283
 
284
284
  def next_dir_path
285
- @next_dir_path ||= (out_path || File.join(lib_path, RUBY_NEXT_DIR))
285
+ @next_dir_path ||= out_path || File.join(lib_path, RUBY_NEXT_DIR)
286
286
  end
287
287
 
288
288
  def stdout?
@@ -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 => 1
13
+ 3 => 4
14
14
  }.freeze
15
15
 
16
- LATEST_VERSION = [3, 1].freeze
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"
@@ -66,6 +66,10 @@ if !Object.const_defined?(:Data) || !Data.respond_to?(:define)
66
66
  klass
67
67
  end
68
68
 
69
+ def self.inherited(subclass)
70
+ subclass.instance_variable_set(:@members, members)
71
+ end
72
+
69
73
  def members
70
74
  self.class.members
71
75
  end
@@ -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 new_source, bind, *args
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 new_source, *args
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 new_source, *args
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 new_source, *args
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 ::Parser::SyntaxError => e
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 ::Parser::SyntaxError => e
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
 
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- gem "ruby-next-parser", ">= 2.8.0.3"
4
- gem "unparser", ">= 0.4.7"
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyNext
4
- VERSION = "1.0.0.rc.1"
4
+ VERSION = "1.0.1"
5
5
  end
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.0.rc.1
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: 2023-12-18 00:00:00.000000000 Z
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: 1.3.1
225
+ version: '0'
226
226
  requirements: []
227
227
  rubygems_version: 3.4.20
228
228
  signing_key: