ruby-next 0.1.0 → 0.1.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 +6 -0
- data/README.md +2 -0
- data/lib/ruby-next/language/rewriters/pattern_matching.rb +14 -0
- data/lib/ruby-next/utils.rb +4 -9
- data/lib/ruby-next/version.rb +1 -1
- data/lib/uby-next.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '04759bfe463ed9def346c1d880fbf3ba7f465be6dac80ac47022543c4be67796'
|
4
|
+
data.tar.gz: a437b160eb2cc3418361d14c962f86faef73f3319c1c6faf71c70bb605de460c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bddaa30d7cd6000d3de03eab8e3b8372e119e3b1f73cb2a78820ab289dcf2a6e88976852012340263ab113b1bd2256e9d22ffaaae80e36b2eee34f88f2953e6c
|
7
|
+
data.tar.gz: a98075ae6d03f4126e2ac2c537d3f86bda82a57e4c446b702e1738fde8c2682442c5731280205ce35e13e96053059a952dd54ce5262456f6d963b9e5dfe815f0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -28,6 +28,8 @@ Thus, polyfills are only available in compatible runtimes (MRI, JRuby, TruffleRu
|
|
28
28
|
Language is responsible for **transpiling** edge Ruby syntax into older versions. It could be done
|
29
29
|
programmatically or via CLI. It also could be done in runtime.
|
30
30
|
|
31
|
+
Currently, Ruby Next supports Ruby versions 2.5+ (including JRuby 9.2.8+).
|
32
|
+
|
31
33
|
## Using only polyfills
|
32
34
|
|
33
35
|
First, install a gem:
|
@@ -230,6 +230,13 @@ module RubyNext
|
|
230
230
|
end
|
231
231
|
end
|
232
232
|
|
233
|
+
def hash_pattern_array_element(node, index)
|
234
|
+
element = arr_item_at(index)
|
235
|
+
locals.with(hash: locals[:arr, index]) do
|
236
|
+
hash_pattern_clause(node, element)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
233
240
|
def match_alt_array_element(node, index)
|
234
241
|
children = node.children.map do |child, i|
|
235
242
|
send :"#{child.type}_array_element", child, index
|
@@ -341,6 +348,13 @@ module RubyNext
|
|
341
348
|
end
|
342
349
|
end
|
343
350
|
|
351
|
+
def array_pattern_hash_element(node, key)
|
352
|
+
element = hash_value_at(key)
|
353
|
+
locals.with(arr: locals[:hash, deconstructed.size]) do
|
354
|
+
array_pattern_clause(node, element)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
344
358
|
def hash_element(head, *tail)
|
345
359
|
send("#{head.type}_hash_element", head).then do |node|
|
346
360
|
next node if tail.empty?
|
data/lib/ruby-next/utils.rb
CHANGED
@@ -16,17 +16,12 @@ module RubyNext
|
|
16
16
|
|
17
17
|
path = "#{path}.rb" if File.extname(path).empty?
|
18
18
|
|
19
|
-
|
20
|
-
loadpath = $LOAD_PATH.find do |lp|
|
21
|
-
File.file?(File.join(lp, path))
|
22
|
-
end
|
19
|
+
return path if Pathname.new(path).absolute?
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
$LOAD_PATH.find do |lp|
|
22
|
+
lpath = File.join(lp, path)
|
23
|
+
return lpath if File.file?(lpath)
|
27
24
|
end
|
28
|
-
|
29
|
-
path
|
30
25
|
end
|
31
26
|
end
|
32
27
|
|
data/lib/ruby-next/version.rb
CHANGED
data/lib/uby-next.rb
CHANGED
@@ -39,9 +39,11 @@ at_exit do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
if $0 == "-e" && e_script.nil?
|
42
|
-
`ps axw`.split("\n").find { |ps| ps[/\A
|
42
|
+
`ps axw`.split("\n").find { |ps| ps[/\A\s*#{$$}/] }.then do |command|
|
43
43
|
next unless command
|
44
|
-
command.
|
44
|
+
command.tr! '\012', "\n"
|
45
|
+
command.tr! "\\", "\n"
|
46
|
+
command.match(/\-e(.*)/m)
|
45
47
|
end.then do |matches|
|
46
48
|
next unless matches
|
47
49
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-next
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.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: 2019-11-
|
11
|
+
date: 2019-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|