lib/ruby2js.rb in ruby2js-1.1.1 vs lib/ruby2js.rb in ruby2js-1.1.2
- old
+ new
@@ -45,19 +45,19 @@
lines = ruby2js.to_js.split("\n")
pre = ''
pending = false
blank = true
lines.each do |line|
- if line.start_with? '}' or line.start_with? ']'
+ if ')}]'.include? line[0]
pre.sub!(/^ /,'')
line.sub!(/([,;])$/,"\\1\n")
pending = true
else
pending = false
end
line.sub! /^/, pre
- if line.end_with? '{' or line.end_with? '['
+ if '({['.include? line[-1]
pre += ' '
line.sub!(/^/,"\n") unless blank or pending
pending = true
end