ruby2js 3.0.10 → 3.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe86f145da2a356f2f0356636b82b7e3dd03c3c20b18e4f4df73c02e94eb8517
4
- data.tar.gz: cd4ddff033e394e8752acdf8c28ac36a9c8a9b659514b4e6eed5f1ed6af0d01c
3
+ metadata.gz: 6da7644d192eea8de1e3a6fe6b8550ef9b373912aed034a88d50cb0b0e27b988
4
+ data.tar.gz: 558b980ae2a39e47cb4b17f354a5378b183606acd5700ed30f44070b5e180131
5
5
  SHA512:
6
- metadata.gz: 3dfe608effc755e3e9f17e68710b9ad5833184fa022a8632ca7227ddeabf2894c207a021a4083da617c865e0499807127a7cb0dc8b32f332cc0de21419c887e2
7
- data.tar.gz: 94fe88ca8908058f69d590602108d586a0b191012603648e072686bd35bf8b3413241f4d04200aff3820f823dd22cf6e1dec9548293c343636632f7405390c7f
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 parse s(:begin, *children)
48
+ return scope s(:begin, *children)
49
49
  end
50
50
 
51
- puts "try {"; parse body, :statement; sput '}'
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
- parse recovers.first.children.last, :statement; sput '}'
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
- parse recovery, :statement; puts ''
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 {'; parse finally, :statement; sput '}') if finally
98
+ (puts ' finally {'; scope finally; sput '}') if finally
99
99
  end
100
100
  end
101
101
  end
@@ -33,7 +33,7 @@ module Ruby2JS
33
33
 
34
34
  hoist = false
35
35
  if state == :statement and not @vars.include?(name)
36
- hoist = hoist?(@scope, @inner, name) if @inner
36
+ hoist = hoist?(@scope, @inner, name) if @inner and @scope != @inner
37
37
  if not hoist
38
38
  if es2015
39
39
  var = 'let '
@@ -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
@@ -2,7 +2,7 @@ module Ruby2JS
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 10
5
+ TINY = 11
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
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.10
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-07 00:00:00.000000000 Z
11
+ date: 2018-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser