ruby2js 3.0.7 → 3.0.8
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 +4 -4
- data/lib/ruby2js/filter/vue.rb +44 -4
- data/lib/ruby2js/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2990f20dc46745e6e632c5cf672ce516f3ca64819a9129024efd7cc333714638
|
4
|
+
data.tar.gz: 77df7775a4146e1e45278002737c24304b4d4f0ccdb49825c372286cfbb2a44b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e0fd19ebc555112ea283f6d112cac30c47c16c3701568acd725d70115c2fe3aa9ba5870145d1ec002f8d7c7f463f26a0fe5fce9f61eb4492539638b938a8219
|
7
|
+
data.tar.gz: 8423b871acb6c37b44b4d5e2878fc8b8eba3c3114768b37a8003cccafabf137253b02f4e55c13aea447521a944662b1554d848834fe5ec61e07381dfc967d3de
|
data/lib/ruby2js/filter/vue.rb
CHANGED
@@ -335,10 +335,8 @@ module Ruby2JS
|
|
335
335
|
statement.type == :defs and statement.children[0] == s(:self)
|
336
336
|
end
|
337
337
|
|
338
|
-
|
339
|
-
defn
|
340
|
-
else
|
341
|
-
s(:begin, defn, *process_all(class_methods.map {|method|
|
338
|
+
unless class_methods.empty? and @vue_reactive.empty?
|
339
|
+
defn = s(:begin, defn, *process_all(class_methods.map {|method|
|
342
340
|
fn = if method.is_method?
|
343
341
|
if not method.children[1].to_s.end_with? '='
|
344
342
|
# class method
|
@@ -397,6 +395,8 @@ module Ruby2JS
|
|
397
395
|
fn
|
398
396
|
}).compact, *@vue_reactive)
|
399
397
|
end
|
398
|
+
|
399
|
+
vue_collapse_pushes(defn)
|
400
400
|
end
|
401
401
|
|
402
402
|
# expand 'wunderbar' like method calls
|
@@ -889,6 +889,46 @@ module Ruby2JS
|
|
889
889
|
end
|
890
890
|
end
|
891
891
|
|
892
|
+
# collapse consecutive pushes into a single call to push
|
893
|
+
def vue_collapse_pushes(node)
|
894
|
+
if node.type == :begin
|
895
|
+
prev = nil
|
896
|
+
(node.children.length-1).downto(0) do |i|
|
897
|
+
child = node.children[i]
|
898
|
+
if
|
899
|
+
child.type == :send and child.children[0] == s(:gvar, :$_) and
|
900
|
+
child.children[1] == :push
|
901
|
+
then
|
902
|
+
if prev
|
903
|
+
node = node.updated(nil, [*node.children[0...i],
|
904
|
+
node.children[i].updated(nil, node.children[i].children +
|
905
|
+
node.children[i+1].children[2..-1]),
|
906
|
+
*node.children[prev+1..-1]])
|
907
|
+
end
|
908
|
+
prev = i
|
909
|
+
else
|
910
|
+
prev = nil
|
911
|
+
end
|
912
|
+
end
|
913
|
+
end
|
914
|
+
|
915
|
+
# recurse
|
916
|
+
children = node.children
|
917
|
+
children.each_with_index do |child, index|
|
918
|
+
if Parser::AST::Node === child
|
919
|
+
replacement = vue_collapse_pushes(child)
|
920
|
+
unless replacement.equal? child
|
921
|
+
children = children.dup if children.frozen?
|
922
|
+
children[index] = replacement
|
923
|
+
end
|
924
|
+
end
|
925
|
+
end
|
926
|
+
|
927
|
+
node = node.updated(nil, children) unless children.frozen?
|
928
|
+
|
929
|
+
node
|
930
|
+
end
|
931
|
+
|
892
932
|
# convert blocks to proc arguments
|
893
933
|
def on_block(node)
|
894
934
|
child = node.children.first
|
data/lib/ruby2js/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.7.
|
133
|
+
rubygems_version: 2.7.6
|
134
134
|
signing_key:
|
135
135
|
specification_version: 4
|
136
136
|
summary: Minimal yet extensible Ruby to JavaScript conversion.
|