ruby2js 3.0.10 → 3.0.11
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/converter/def.rb +9 -3
- data/lib/ruby2js/converter/kwbegin.rb +5 -5
- data/lib/ruby2js/converter/vasgn.rb +1 -1
- data/lib/ruby2js/serializer.rb +3 -3
- data/lib/ruby2js/version.rb +1 -1
- 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: 6da7644d192eea8de1e3a6fe6b8550ef9b373912aed034a88d50cb0b0e27b988
|
4
|
+
data.tar.gz: 558b980ae2a39e47cb4b17f354a5378b183606acd5700ed30f44070b5e180131
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0819a2eeecd764f301f0bc8ec1d50cb4014dc715e850849e572fd0962247f46e2799a9265e474d79837f2cb17de201bb205762da018100eaa0b62eb7cb8a069
|
7
|
+
data.tar.gz: bc64c4729076b98dc9589e4e27a7d873c5a1185604eaca6ee38923b560f57dfcb51509e1f4e55caa4a9ec2fb5b20c539146a2cd5d4e365d9507356e22b9e5989
|
@@ -92,8 +92,6 @@ module Ruby2JS
|
|
92
92
|
not name and es2015 and @state != :method and @ast.type != :defm and
|
93
93
|
not @prop
|
94
94
|
then
|
95
|
-
put '('; parse args; put ') => '
|
96
|
-
|
97
95
|
expr = body
|
98
96
|
expr = expr.children.first while expr.type == :autoreturn
|
99
97
|
while expr.type == :begin and expr.children.length == 1
|
@@ -117,8 +115,16 @@ module Ruby2JS
|
|
117
115
|
style = :statement
|
118
116
|
end
|
119
117
|
|
118
|
+
if args.children.length == 1 and style == :expression
|
119
|
+
parse args; put ' => '
|
120
|
+
else
|
121
|
+
put '('; parse args; put ') => '
|
122
|
+
end
|
123
|
+
|
120
124
|
if style == :expression
|
121
|
-
expr.type == :hash ? group(expr) : parse(expr)
|
125
|
+
expr.type == :hash ? group(expr) : wrap('(', ')') { parse(expr) }
|
126
|
+
elsif body.type == :begin and body.children.length == 0
|
127
|
+
put "{}"
|
122
128
|
else
|
123
129
|
put "{#{@nl}"; scope body, vars; put "#{@nl}}"
|
124
130
|
end
|
@@ -45,10 +45,10 @@ module Ruby2JS
|
|
45
45
|
end
|
46
46
|
|
47
47
|
if not recovers and not finally
|
48
|
-
return
|
48
|
+
return scope s(:begin, *children)
|
49
49
|
end
|
50
50
|
|
51
|
-
puts "try {";
|
51
|
+
puts "try {"; scope body; sput '}'
|
52
52
|
|
53
53
|
if recovers
|
54
54
|
var ||= s(:gvar, :$EXCEPTION)
|
@@ -56,7 +56,7 @@ module Ruby2JS
|
|
56
56
|
if recovers.length == 1 and not recovers.first.children.first
|
57
57
|
# single catch with no exception named
|
58
58
|
put " catch ("; parse var; puts ") {"
|
59
|
-
|
59
|
+
scope recovers.first.children.last; sput '}'
|
60
60
|
else
|
61
61
|
put " catch ("; parse var; puts ') {'
|
62
62
|
|
@@ -84,7 +84,7 @@ module Ruby2JS
|
|
84
84
|
puts '} else {'
|
85
85
|
end
|
86
86
|
|
87
|
-
|
87
|
+
scope recovery; puts ''
|
88
88
|
end
|
89
89
|
|
90
90
|
if recovers.last.children.first
|
@@ -95,7 +95,7 @@ module Ruby2JS
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
(puts ' finally {';
|
98
|
+
(puts ' finally {'; scope finally; sput '}') if finally
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
data/lib/ruby2js/serializer.rb
CHANGED
@@ -203,8 +203,8 @@ module Ruby2JS
|
|
203
203
|
end
|
204
204
|
|
205
205
|
# wrap long statements in curly braces
|
206
|
-
def wrap
|
207
|
-
puts
|
206
|
+
def wrap(open = '{', close = '}')
|
207
|
+
puts open
|
208
208
|
mark = output_location
|
209
209
|
yield
|
210
210
|
|
@@ -212,7 +212,7 @@ module Ruby2JS
|
|
212
212
|
@lines.length > mark.first+1 or
|
213
213
|
@lines[mark.first-1].join.length + @line.join.length >= @width
|
214
214
|
then
|
215
|
-
sput
|
215
|
+
sput close
|
216
216
|
else
|
217
217
|
@line = @lines[mark.first-1]
|
218
218
|
@line[-1..-1] = @lines.pop
|
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.11
|
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-06-
|
11
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|