ruby-next-core 0.13.3 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -0
  3. data/README.md +65 -5
  4. data/bin/transform +5 -1
  5. data/lib/.rbnext/2.1/ruby-next/core.rb +7 -1
  6. data/lib/.rbnext/2.1/ruby-next/language.rb +44 -23
  7. data/lib/.rbnext/2.3/ruby-next/commands/nextify.rb +15 -2
  8. data/lib/.rbnext/2.3/ruby-next/language/eval.rb +1 -0
  9. data/lib/.rbnext/2.3/ruby-next/language/rewriters/{endless_range.rb → 2.6/endless_range.rb} +0 -0
  10. data/lib/.rbnext/2.3/ruby-next/language/rewriters/{pattern_matching.rb → 2.7/pattern_matching.rb} +121 -34
  11. data/lib/.rbnext/2.3/ruby-next/language/rewriters/3.1/anonymous_block.rb +68 -0
  12. data/lib/.rbnext/2.3/ruby-next/language/rewriters/base.rb +14 -2
  13. data/lib/.rbnext/2.7/ruby-next/core.rb +7 -1
  14. data/lib/.rbnext/2.7/ruby-next/language/rewriters/2.7/pattern_matching.rb +1061 -0
  15. data/lib/ruby-next/commands/nextify.rb +15 -2
  16. data/lib/ruby-next/config.rb +2 -2
  17. data/lib/ruby-next/core/enumerable/compact.rb +22 -0
  18. data/lib/ruby-next/core/integer/try_convert.rb +16 -0
  19. data/lib/ruby-next/core/matchdata/match.rb +9 -0
  20. data/lib/ruby-next/core/refinement/import.rb +60 -0
  21. data/lib/ruby-next/core.rb +7 -1
  22. data/lib/ruby-next/irb.rb +24 -0
  23. data/lib/ruby-next/language/eval.rb +1 -0
  24. data/lib/ruby-next/language/rewriters/{numeric_literals.rb → 2.1/numeric_literals.rb} +0 -0
  25. data/lib/ruby-next/language/rewriters/{required_kwargs.rb → 2.1/required_kwargs.rb} +0 -0
  26. data/lib/ruby-next/language/rewriters/{safe_navigation.rb → 2.3/safe_navigation.rb} +0 -0
  27. data/lib/ruby-next/language/rewriters/{squiggly_heredoc.rb → 2.3/squiggly_heredoc.rb} +0 -0
  28. data/lib/ruby-next/language/rewriters/{runtime → 2.4}/dir.rb +0 -0
  29. data/lib/ruby-next/language/rewriters/2.5/rescue_within_block.rb +39 -0
  30. data/lib/ruby-next/language/rewriters/{endless_range.rb → 2.6/endless_range.rb} +0 -0
  31. data/lib/ruby-next/language/rewriters/{args_forward.rb → 2.7/args_forward.rb} +0 -0
  32. data/lib/ruby-next/language/rewriters/{numbered_params.rb → 2.7/numbered_params.rb} +0 -0
  33. data/lib/ruby-next/language/rewriters/{pattern_matching.rb → 2.7/pattern_matching.rb} +121 -34
  34. data/lib/ruby-next/language/rewriters/{args_forward_leading.rb → 3.0/args_forward_leading.rb} +0 -0
  35. data/lib/ruby-next/language/rewriters/{endless_method.rb → 3.0/endless_method.rb} +15 -12
  36. data/lib/ruby-next/language/rewriters/{find_pattern.rb → 3.0/find_pattern.rb} +1 -3
  37. data/lib/ruby-next/language/rewriters/3.0/in_pattern.rb +22 -0
  38. data/lib/ruby-next/language/rewriters/3.1/anonymous_block.rb +68 -0
  39. data/lib/ruby-next/language/rewriters/3.1/endless_method_command.rb +46 -0
  40. data/lib/ruby-next/language/rewriters/3.1/oneline_pattern_parensless.rb +41 -0
  41. data/lib/ruby-next/language/rewriters/3.1/pin_vars_pattern.rb +50 -0
  42. data/lib/ruby-next/language/rewriters/3.1/refinement_import_methods.rb +60 -0
  43. data/lib/ruby-next/language/rewriters/{shorthand_hash.rb → 3.1/shorthand_hash.rb} +6 -4
  44. data/lib/ruby-next/language/rewriters/base.rb +14 -2
  45. data/lib/ruby-next/language/{edge.rb → rewriters/edge.rb} +0 -0
  46. data/lib/ruby-next/language/rewriters/proposed/bind_vars_pattern.rb +50 -0
  47. data/lib/ruby-next/language/rewriters/{method_reference.rb → proposed/method_reference.rb} +0 -0
  48. data/lib/ruby-next/language/rewriters/proposed.rb +9 -0
  49. data/lib/ruby-next/language/rewriters/runtime.rb +1 -2
  50. data/lib/ruby-next/language/setup.rb +1 -1
  51. data/lib/ruby-next/language.rb +44 -23
  52. data/lib/ruby-next/pry.rb +90 -0
  53. data/lib/ruby-next/rubocop.rb +24 -4
  54. data/lib/ruby-next/version.rb +1 -1
  55. data/lib/uby-next/irb.rb +3 -0
  56. data/lib/uby-next/pry.rb +3 -0
  57. metadata +40 -43
  58. data/lib/ruby-next/language/proposed.rb +0 -9
  59. data/lib/ruby-next/language/rewriters/in_pattern.rb +0 -56
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: 0.13.3
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-09 00:00:00.000000000 Z
11
+ date: 2022-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-next-parser
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0.3
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 3.1.0.0
19
+ version: 3.1.1.0
23
20
  type: :development
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 3.0.0.3
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 3.1.0.0
26
+ version: 3.1.1.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: unparser
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,20 +38,6 @@ dependencies:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
40
  version: 0.6.0
47
- - !ruby/object:Gem::Dependency
48
- name: parser
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "<"
52
- - !ruby/object:Gem::Version
53
- version: 3.0.3.0
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "<"
59
- - !ruby/object:Gem::Version
60
- version: 3.0.3.0
61
41
  description: "\n Ruby Next Core is a zero deps version of Ruby Next meant to be
62
42
  used\n as as dependency in your gems.\n\n It contains all the polyfills and
63
43
  utility files but doesn't require transpiler\n dependencies to be install.\n
@@ -81,11 +61,13 @@ files:
81
61
  - lib/.rbnext/2.3/ruby-next/commands/core_ext.rb
82
62
  - lib/.rbnext/2.3/ruby-next/commands/nextify.rb
83
63
  - lib/.rbnext/2.3/ruby-next/language/eval.rb
64
+ - lib/.rbnext/2.3/ruby-next/language/rewriters/2.6/endless_range.rb
65
+ - lib/.rbnext/2.3/ruby-next/language/rewriters/2.7/pattern_matching.rb
66
+ - lib/.rbnext/2.3/ruby-next/language/rewriters/3.1/anonymous_block.rb
84
67
  - lib/.rbnext/2.3/ruby-next/language/rewriters/base.rb
85
- - lib/.rbnext/2.3/ruby-next/language/rewriters/endless_range.rb
86
- - lib/.rbnext/2.3/ruby-next/language/rewriters/pattern_matching.rb
87
68
  - lib/.rbnext/2.3/ruby-next/utils.rb
88
69
  - lib/.rbnext/2.7/ruby-next/core.rb
70
+ - lib/.rbnext/2.7/ruby-next/language/rewriters/2.7/pattern_matching.rb
89
71
  - lib/ruby-next.rb
90
72
  - lib/ruby-next/cli.rb
91
73
  - lib/ruby-next/commands/base.rb
@@ -98,6 +80,7 @@ files:
98
80
  - lib/ruby-next/core/array/intersect.rb
99
81
  - lib/ruby-next/core/constants/frozen_error.rb
100
82
  - lib/ruby-next/core/constants/no_matching_pattern_error.rb
83
+ - lib/ruby-next/core/enumerable/compact.rb
101
84
  - lib/ruby-next/core/enumerable/filter.rb
102
85
  - lib/ruby-next/core/enumerable/filter_map.rb
103
86
  - lib/ruby-next/core/enumerable/tally.rb
@@ -105,8 +88,11 @@ files:
105
88
  - lib/ruby-next/core/hash/deconstruct_keys.rb
106
89
  - lib/ruby-next/core/hash/except.rb
107
90
  - lib/ruby-next/core/hash/merge.rb
91
+ - lib/ruby-next/core/integer/try_convert.rb
108
92
  - lib/ruby-next/core/kernel/then.rb
93
+ - lib/ruby-next/core/matchdata/match.rb
109
94
  - lib/ruby-next/core/proc/compose.rb
95
+ - lib/ruby-next/core/refinement/import.rb
110
96
  - lib/ruby-next/core/runtime.rb
111
97
  - lib/ruby-next/core/string/split.rb
112
98
  - lib/ruby-next/core/struct/deconstruct.rb
@@ -117,38 +103,49 @@ files:
117
103
  - lib/ruby-next/core/time/floor.rb
118
104
  - lib/ruby-next/core/unboundmethod/bind_call.rb
119
105
  - lib/ruby-next/core_ext.rb
106
+ - lib/ruby-next/irb.rb
120
107
  - lib/ruby-next/language.rb
121
108
  - lib/ruby-next/language/bootsnap.rb
122
- - lib/ruby-next/language/edge.rb
123
109
  - lib/ruby-next/language/eval.rb
124
110
  - lib/ruby-next/language/parser.rb
125
- - lib/ruby-next/language/proposed.rb
126
- - lib/ruby-next/language/rewriters/args_forward.rb
127
- - lib/ruby-next/language/rewriters/args_forward_leading.rb
111
+ - lib/ruby-next/language/rewriters/2.1/numeric_literals.rb
112
+ - lib/ruby-next/language/rewriters/2.1/required_kwargs.rb
113
+ - lib/ruby-next/language/rewriters/2.3/safe_navigation.rb
114
+ - lib/ruby-next/language/rewriters/2.3/squiggly_heredoc.rb
115
+ - lib/ruby-next/language/rewriters/2.4/dir.rb
116
+ - lib/ruby-next/language/rewriters/2.5/rescue_within_block.rb
117
+ - lib/ruby-next/language/rewriters/2.6/endless_range.rb
118
+ - lib/ruby-next/language/rewriters/2.7/args_forward.rb
119
+ - lib/ruby-next/language/rewriters/2.7/numbered_params.rb
120
+ - lib/ruby-next/language/rewriters/2.7/pattern_matching.rb
121
+ - lib/ruby-next/language/rewriters/3.0/args_forward_leading.rb
122
+ - lib/ruby-next/language/rewriters/3.0/endless_method.rb
123
+ - lib/ruby-next/language/rewriters/3.0/find_pattern.rb
124
+ - lib/ruby-next/language/rewriters/3.0/in_pattern.rb
125
+ - lib/ruby-next/language/rewriters/3.1/anonymous_block.rb
126
+ - lib/ruby-next/language/rewriters/3.1/endless_method_command.rb
127
+ - lib/ruby-next/language/rewriters/3.1/oneline_pattern_parensless.rb
128
+ - lib/ruby-next/language/rewriters/3.1/pin_vars_pattern.rb
129
+ - lib/ruby-next/language/rewriters/3.1/refinement_import_methods.rb
130
+ - lib/ruby-next/language/rewriters/3.1/shorthand_hash.rb
128
131
  - lib/ruby-next/language/rewriters/base.rb
129
- - lib/ruby-next/language/rewriters/endless_method.rb
130
- - lib/ruby-next/language/rewriters/endless_range.rb
131
- - lib/ruby-next/language/rewriters/find_pattern.rb
132
- - lib/ruby-next/language/rewriters/in_pattern.rb
133
- - lib/ruby-next/language/rewriters/method_reference.rb
134
- - lib/ruby-next/language/rewriters/numbered_params.rb
135
- - lib/ruby-next/language/rewriters/numeric_literals.rb
136
- - lib/ruby-next/language/rewriters/pattern_matching.rb
137
- - lib/ruby-next/language/rewriters/required_kwargs.rb
132
+ - lib/ruby-next/language/rewriters/edge.rb
133
+ - lib/ruby-next/language/rewriters/proposed.rb
134
+ - lib/ruby-next/language/rewriters/proposed/bind_vars_pattern.rb
135
+ - lib/ruby-next/language/rewriters/proposed/method_reference.rb
138
136
  - lib/ruby-next/language/rewriters/runtime.rb
139
- - lib/ruby-next/language/rewriters/runtime/dir.rb
140
- - lib/ruby-next/language/rewriters/safe_navigation.rb
141
- - lib/ruby-next/language/rewriters/shorthand_hash.rb
142
- - lib/ruby-next/language/rewriters/squiggly_heredoc.rb
143
137
  - lib/ruby-next/language/runtime.rb
144
138
  - lib/ruby-next/language/setup.rb
145
139
  - lib/ruby-next/language/unparser.rb
146
140
  - lib/ruby-next/logging.rb
141
+ - lib/ruby-next/pry.rb
147
142
  - lib/ruby-next/rubocop.rb
148
143
  - lib/ruby-next/setup_self.rb
149
144
  - lib/ruby-next/utils.rb
150
145
  - lib/ruby-next/version.rb
151
146
  - lib/uby-next.rb
147
+ - lib/uby-next/irb.rb
148
+ - lib/uby-next/pry.rb
152
149
  homepage: http://github.com/palkan/ruby-next
153
150
  licenses:
154
151
  - MIT
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Load experimental, proposed etc. Ruby features
4
-
5
- require "ruby-next/language/rewriters/method_reference"
6
- RubyNext::Language.rewriters << RubyNext::Language::Rewriters::MethodReference
7
-
8
- require "ruby-next/language/rewriters/shorthand_hash"
9
- RubyNext::Language.rewriters << RubyNext::Language::Rewriters::ShorthandHash
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "ruby-next/language/rewriters/pattern_matching"
4
-
5
- module RubyNext
6
- module Language
7
- module Rewriters
8
- using RubyNext
9
-
10
- # Separate pattern matching rewriter for Ruby 2.7 to
11
- # transpile only `in` patterns
12
- class InPattern < PatternMatching
13
- NAME = "pattern-matching-in"
14
- SYNTAX_PROBE = "1 in 2"
15
- MIN_SUPPORTED_VERSION = Gem::Version.new("3.0.0")
16
-
17
- # Make case-match no-op
18
- def on_case_match(node)
19
- node
20
- end
21
-
22
- def on_match_pattern_p(node)
23
- context.track! self
24
-
25
- @deconstructed_keys = {}
26
- @predicates = Predicates::Noop.new
27
-
28
- matchee =
29
- s(:begin, s(:lvasgn, MATCHEE, node.children[0]))
30
-
31
- pattern =
32
- locals.with(
33
- matchee: MATCHEE,
34
- arr: MATCHEE_ARR,
35
- hash: MATCHEE_HASH
36
- ) do
37
- send(
38
- :"#{node.children[1].type}_clause",
39
- node.children[1]
40
- )
41
- end
42
-
43
- node.updated(
44
- :and,
45
- [
46
- matchee,
47
- pattern
48
- ]
49
- ).tap do |new_node|
50
- replace(node.loc.expression, inline_blocks(unparse(new_node)))
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end