ruby-next-core 1.0.2 → 1.0.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: ac9ab37024b70ac4ba553ceca25b7b63a0029ccf356787295b5d6509eb2b5461
4
- data.tar.gz: a27ef393520aae1513047c234f999993ff0bc1dd6614e7aca8c5acf02561a7af
3
+ metadata.gz: d760d668ee7358474931d4a69ebff41ff99aa2d7e300fdbe58aa023e38644422
4
+ data.tar.gz: f7a982bae326176fb4ac5b991f8b61be10648efe5cfc501a4d81f14b974bc55b
5
5
  SHA512:
6
- metadata.gz: 00b81f2df63fce2fb38da1470315a1d1fa2ae1e4ebc69b150712a9f02f2e5a07c7bb8f2776ae109ec4b3fd259567f674cf6df209f0d06fb4fa6e542467f44c7f
7
- data.tar.gz: 7f201ea784a2707d0aec127086d5b76c1475fa7c60e984988ddb7c37262d6168cc86139112b71ea466502eba330e1fd6cf98fe6c674266dfb7e4b5c62d75d7b4
6
+ metadata.gz: 5093c8523a20d95a073254f09e2226e766df69e9ba48692686f34693ba132fe2d5f6d5b08a558d9ef7f7be2842784aded96a181903577d9fbcef060dc8f8c108
7
+ data.tar.gz: 17df494938c41ce179f64776cb6ce13a966c97ac3ba3f6ac32e0d1d6da7fc38ee7689dc65ef4f6480208ba5190d288f292b03830bcec43756911c0e2092b6669
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.0.3 (2024-04-18)
6
+
7
+ - Fix RuboCop compatibility.
8
+
5
9
  ## 1.0.2 (2024-02-23)
6
10
 
7
11
  - Automatically mark context as dirty if `#safe_rewrite` modifies source code. ([@palkan][])
data/README.md CHANGED
@@ -565,6 +565,9 @@ Wonder what would happen if Ruby get a null coalescing operator (`??=`) or some
565
565
 
566
566
  Ruby Next allows you to write your own syntax rewriters. Full-featured rewriters (used by Ruby Next itself) operate on AST and usually require parser modifications. However, we also support text-based rewriters which can be used to experiment with new syntax much quicker without dealing with grammars, parsers and syntax trees.
567
567
 
568
+ > [!TIP]
569
+ > You can experiment with Ruby Next rewriters at our [online playground][playground]!
570
+
568
571
  To implement a text-based rewriter, you need to create a new class inherited from `RubyNext::Language::Rewriters::Text` and implementing either `#rewrite` or `#safe_rewrite` method. For example, the method reference operator (`.:`) could be implemented as follows:
569
572
 
570
573
  ```ruby
@@ -704,3 +707,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
704
707
  [require-hooks]: https://github.com/ruby-next/require-hooks
705
708
  [Natalie]: https://natalie-lang.org
706
709
  [Paco]: https://github.com/ruby-next/paco
710
+ [playground]: https://ruby-next.github.io
@@ -4,7 +4,7 @@ module RubyNext
4
4
  module Language
5
5
  module PacoParsers
6
6
  class StringLiterals < Base
7
- PAIRS = {"[" => "]", "{" => "}", "<" => ">"}.freeze
7
+ PAIRS = {"[" => "]", "{" => "}", "(" => ")"}.freeze
8
8
 
9
9
  def default
10
10
  all_strings.fmap do |result|
@@ -24,11 +24,15 @@ module RubyNext
24
24
  # heredoc_expanded
25
25
  end
26
26
 
27
+ def literal_start
28
+ alt(string("{"), string("("), string("["))
29
+ end
30
+
27
31
  def quoted
28
32
  seq(
29
- string("%q"),
30
- any_char.bind do |char|
31
- end_symbol = string(PAIRS[char] || char)
33
+ alt(string("%q"), string("%s"), string("%r"), string("%i"), string("%w")),
34
+ literal_start.bind do |char|
35
+ end_symbol = string(PAIRS.fetch(char))
32
36
  escapable_string(succeed(char), end_symbol)
33
37
  end
34
38
  )
@@ -40,9 +44,9 @@ module RubyNext
40
44
 
41
45
  def quoted_expanded
42
46
  seq(
43
- alt(string("%Q"), string("%")),
44
- any_char.bind do |char|
45
- end_symbol = string(PAIRS[char] || char)
47
+ alt(string("%Q"), string("%"), string("%W"), string("%I")),
48
+ literal_start.bind do |char|
49
+ end_symbol = string(PAIRS.fetch(char))
46
50
  escapable_string(succeed(char), end_symbol, interpolate: true)
47
51
  end
48
52
  )
@@ -36,7 +36,7 @@ end
36
36
  module RuboCop
37
37
  class ProcessedSource
38
38
  module ParserClassExt
39
- def parser_class(version)
39
+ def parser_class(version, *__rest__)
40
40
  return super unless version == RUBY_NEXT_VERSION
41
41
 
42
42
  require "parser/rubynext"
@@ -4,7 +4,7 @@ module RubyNext
4
4
  module Language
5
5
  module PacoParsers
6
6
  class StringLiterals < Base
7
- PAIRS = {"[" => "]", "{" => "}", "<" => ">"}.freeze
7
+ PAIRS = {"[" => "]", "{" => "}", "(" => ")"}.freeze
8
8
 
9
9
  def default
10
10
  all_strings.fmap do |result|
@@ -24,11 +24,15 @@ module RubyNext
24
24
  # heredoc_expanded
25
25
  end
26
26
 
27
+ def literal_start
28
+ alt(string("{"), string("("), string("["))
29
+ end
30
+
27
31
  def quoted
28
32
  seq(
29
- string("%q"),
30
- any_char.bind do |char|
31
- end_symbol = string(PAIRS[char] || char)
33
+ alt(string("%q"), string("%s"), string("%r"), string("%i"), string("%w")),
34
+ literal_start.bind do |char|
35
+ end_symbol = string(PAIRS.fetch(char))
32
36
  escapable_string(succeed(char), end_symbol)
33
37
  end
34
38
  )
@@ -40,9 +44,9 @@ module RubyNext
40
44
 
41
45
  def quoted_expanded
42
46
  seq(
43
- alt(string("%Q"), string("%")),
44
- any_char.bind do |char|
45
- end_symbol = string(PAIRS[char] || char)
47
+ alt(string("%Q"), string("%"), string("%W"), string("%I")),
48
+ literal_start.bind do |char|
49
+ end_symbol = string(PAIRS.fetch(char))
46
50
  escapable_string(succeed(char), end_symbol, interpolate: true)
47
51
  end
48
52
  )
@@ -36,7 +36,7 @@ end
36
36
  module RuboCop
37
37
  class ProcessedSource
38
38
  module ParserClassExt
39
- def parser_class(version)
39
+ def parser_class(version, *)
40
40
  return super unless version == RUBY_NEXT_VERSION
41
41
 
42
42
  require "parser/rubynext"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyNext
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
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.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-23 00:00:00.000000000 Z
11
+ date: 2024-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require-hooks
@@ -209,7 +209,7 @@ metadata:
209
209
  homepage_uri: https://github.com/ruby-next/ruby-next
210
210
  source_code_uri: https://github.com/ruby-next/ruby-next
211
211
  funding_uri: https://github.com/sponsors/palkan
212
- post_install_message:
212
+ post_install_message:
213
213
  rdoc_options: []
214
214
  require_paths:
215
215
  - lib
@@ -224,8 +224,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  - !ruby/object:Gem::Version
225
225
  version: '0'
226
226
  requirements: []
227
- rubygems_version: 3.4.20
228
- signing_key:
227
+ rubygems_version: 3.4.19
228
+ signing_key:
229
229
  specification_version: 4
230
230
  summary: Ruby Next core functionality
231
231
  test_files: []