ruby-next-core 1.0.0 → 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: 87d93cf2f90d65b784dc88faa364ce5bd1cca02443610a370bcd24389e727872
4
- data.tar.gz: d6f995ee6175fe8e65c237900639b7a62e10876a1f479ce076c9e671218cfc7a
3
+ metadata.gz: 5ad6cea22baa599e5a6edeb4fdda1fb7c9bd0b0d5617fb01cf4450374c7d9443
4
+ data.tar.gz: fa39e7d51cdf70c32dc2067000023e42dbe3b23bd1d8bf520e06a3a028d63b8d
5
5
  SHA512:
6
- metadata.gz: f73e75f758e537e32c2d0cd79f57483337fcb9ee10f9b76daa6d5a560f7e2269ebf574974cd5b620249e177ef6edd746eae08def2f10f1b2094466a4717f238a
7
- data.tar.gz: 54e14beaef6122ceff3514c270a0fe2877c3ad727037c08eb6d0537b93d36ef9e305e7d67626f14123e9916c1663ea8af7c188389d9a7f4aa85b93abaa1c6bcb
6
+ metadata.gz: e7df787bfa90d036bbd45c7bd2dbc85f3513d922b3606dfde12ade0196f7ccb6789aba263d407fc012c7b4625d38b4aa6d7df05a5ac4e784b3b9cfc5db356b0f
7
+ data.tar.gz: a4c364d32b19003c219670096dd6420d415663445d68deb7e92c8d9763cc705884e7ab7e43fed81c6c084450f6a32e14bd8b50f24629256cb064c84a8bb87583
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
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
+
5
9
  ## 1.0.0 🎄
6
10
 
7
11
  - Add `it` block parameter support. ([@palkan][])
data/README.md CHANGED
@@ -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.
@@ -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?
@@ -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?
@@ -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
@@ -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"
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
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