lib/ruby2js.rb in ruby2js-2.0.15 vs lib/ruby2js.rb in ruby2js-2.0.16
- old
+ new
@@ -83,11 +83,11 @@
file,line = source.source_location
source = File.read(file.dup.untaint).untaint
ast, comments = parse(source)
comments = Parser::Source::Comment.associate(ast, comments) if ast
ast = find_block( ast, line )
- options = options.merge(file => file) unless options[:file]
+ options[:file] ||= file
elsif Parser::AST::Node === source
ast, comments = source, {}
source = ast.loc.expression.source_buffer.source
else
ast, comments = parse( source, options[:file] )
@@ -129,10 +129,10 @@
ruby2js
end
def self.parse(source, file=nil)
- Parser::CurrentRuby.parse_with_comments(source.encode('utf-8'))
+ Parser::CurrentRuby.parse_with_comments(source.encode('utf-8'), file)
rescue Parser::SyntaxError => e
split = source[0..e.diagnostic.location.begin_pos].split("\n")
line, col = split.length, split.last.length
message = "line #{line}, column #{col}: #{e.diagnostic.message}"
message += "\n in file #{file}" if file