ruby2js 3.0.1 → 3.0.2
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 +5 -5
- data/lib/ruby2js/converter.rb +2 -0
- data/lib/ruby2js/converter/casgn.rb +2 -0
- data/lib/ruby2js/converter/cvasgn.rb +2 -0
- data/lib/ruby2js/converter/ivasgn.rb +2 -0
- data/lib/ruby2js/converter/send.rb +2 -0
- data/lib/ruby2js/converter/vasgn.rb +41 -2
- data/lib/ruby2js/filter/functions.rb +2 -2
- data/lib/ruby2js/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '009edffb834a3c8c298d4ad601160d30c4781891a4fe7b229e6dbc6f4284569e'
|
4
|
+
data.tar.gz: 186d6e6ec33a0fee107623c3ed7994e9dea0741cf454bb79005acbb6be7f6429
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de2efb3d8d13a282af0401ce3a6216423564933483d3be4ed160eb1ef2bbf3092fdae6c9325d09298d6c86012de936c764178a0767a08b66b49b6d6d53bd9daa
|
7
|
+
data.tar.gz: 3558c528e771c98fd50ece66410dd12d3a33c57af85e89e47a1c04f743f4a531cb971dbdf197291f8e6b1530d1895ea9c40aaf8814d64d094eb2f397092504a2
|
data/lib/ruby2js/converter.rb
CHANGED
@@ -151,6 +151,8 @@ module Ruby2JS
|
|
151
151
|
(group_target ? group(target) : parse(target))
|
152
152
|
|
153
153
|
elsif method =~ /=$/
|
154
|
+
multi_assign_declarations if @state == :statement
|
155
|
+
|
154
156
|
parse receiver
|
155
157
|
put "#{ '.' if receiver }#{ method.to_s.sub(/=$/, ' =') } "
|
156
158
|
parse args.first, (@state == :method ? :method : :expression)
|
@@ -21,8 +21,13 @@ module Ruby2JS
|
|
21
21
|
end
|
22
22
|
|
23
23
|
unless undecls.empty?
|
24
|
-
|
25
|
-
|
24
|
+
if es2015
|
25
|
+
put 'let '
|
26
|
+
else
|
27
|
+
put 'var '
|
28
|
+
end
|
29
|
+
put undecls.map(&:to_s).join(', ') + @sep
|
30
|
+
undecls.each {|var| @vars[var] = true}
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
@@ -49,5 +54,39 @@ module Ruby2JS
|
|
49
54
|
end
|
50
55
|
end
|
51
56
|
end
|
57
|
+
|
58
|
+
def multi_assign_declarations
|
59
|
+
undecls = []
|
60
|
+
child = @ast
|
61
|
+
loop do
|
62
|
+
if [:send, :casgn].include? child.type
|
63
|
+
subchild = child.children[2]
|
64
|
+
else
|
65
|
+
subchild = child.children[1]
|
66
|
+
end
|
67
|
+
|
68
|
+
if subchild.type == :send
|
69
|
+
break unless subchild.children[1] =~ /=$/
|
70
|
+
else
|
71
|
+
break unless [:send, :cvasgn, :ivasgn, :gvasgn, :lvasgn].
|
72
|
+
include? subchild.type
|
73
|
+
end
|
74
|
+
|
75
|
+
child = subchild
|
76
|
+
|
77
|
+
if child.type == :lvasgn and not @vars.include?(child.children[0])
|
78
|
+
undecls << child.children[0]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
unless undecls.empty?
|
83
|
+
if es2015
|
84
|
+
put "let "
|
85
|
+
else
|
86
|
+
put "var "
|
87
|
+
end
|
88
|
+
put "#{undecls.map(&:to_s).join(', ')}#@sep"
|
89
|
+
end
|
90
|
+
end
|
52
91
|
end
|
53
92
|
end
|
@@ -17,8 +17,8 @@ module Ruby2JS
|
|
17
17
|
|
18
18
|
if [:max, :min].include? method and args.length == 0
|
19
19
|
return super unless node.is_method?
|
20
|
-
process S(:send, s(:
|
21
|
-
|
20
|
+
process S(:send, s(:const, nil, :Math), node.children[1],
|
21
|
+
s(:splat, target))
|
22
22
|
|
23
23
|
elsif method == :call and target and target.type == :ivar
|
24
24
|
process S(:send, s(:self), "_#{target.children.first.to_s[1..-1]}",
|
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.2
|
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-01-
|
11
|
+
date: 2018-01-24 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.
|
133
|
+
rubygems_version: 2.7.4
|
134
134
|
signing_key:
|
135
135
|
specification_version: 4
|
136
136
|
summary: Minimal yet extensible Ruby to JavaScript conversion.
|