ruby-next 0.1.0 → 0.1.1

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: a874763234ae5833fd2b6617be24fb2e600acc49c62fd39707d8da73d5810656
4
- data.tar.gz: c6e73faa43b329ac1c3e0d2daff8689d677d19ed28ffb2ac8d09dea526ac1a1c
3
+ metadata.gz: '04759bfe463ed9def346c1d880fbf3ba7f465be6dac80ac47022543c4be67796'
4
+ data.tar.gz: a437b160eb2cc3418361d14c962f86faef73f3319c1c6faf71c70bb605de460c
5
5
  SHA512:
6
- metadata.gz: a9f7d9dff8b79bcc2121b7dbaba38cd8ac5a578b249b463fa6c7a5ef25845fb12537b82e3ee240463d8156512c2039245b0465fb56249f2a6812ce1ce3ff971b
7
- data.tar.gz: e909ab9742e7e1d7a32f00465bfe84c7ba3ad197b126842131a8b4601ab015cb7bf29b8c8aef7d0b5fab6b0bef5a45d1ea5a6c8f2b83d6f63be243cb19c20b8a
6
+ metadata.gz: bddaa30d7cd6000d3de03eab8e3b8372e119e3b1f73cb2a78820ab289dcf2a6e88976852012340263ab113b1bd2256e9d22ffaaae80e36b2eee34f88f2953e6c
7
+ data.tar.gz: a98075ae6d03f4126e2ac2c537d3f86bda82a57e4c446b702e1738fde8c2682442c5731280205ce35e13e96053059a952dd54ce5262456f6d963b9e5dfe815f0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.1.0 (2019-11-18)
6
+
7
+ - Support hash pattern in array and vice versa. ([@palkan][])
8
+
9
+ - Handle multile `-e` in `uby-next`. ([@palkan][])
10
+
5
11
  ## 0.1.0 (2019-11-16)
6
12
 
7
13
  - Add pattern matching. ([@palkan][])
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?
@@ -16,17 +16,12 @@ module RubyNext
16
16
 
17
17
  path = "#{path}.rb" if File.extname(path).empty?
18
18
 
19
- unless Pathname.new(path).absolute?
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
- return if loadpath.nil?
25
-
26
- path = File.join(loadpath, path)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyNext
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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#{$$}/] }.then do |command|
42
+ `ps axw`.split("\n").find { |ps| ps[/\A\s*#{$$}/] }.then do |command|
43
43
  next unless command
44
- command.match(/\-e(.*$)/)
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.0
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-16 00:00:00.000000000 Z
11
+ date: 2019-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser