lib/tailor/lexer.rb in tailor-1.2.1 vs lib/tailor/lexer.rb in tailor-1.3.0
- old
+ new
@@ -21,11 +21,11 @@
def initialize(file)
@original_file_text = if File.exists? file
@file_name = file
File.open(@file_name, 'r').read
else
- @file_name = "<notafile>"
+ @file_name = '<notafile>'
file
end
@file_text = ensure_trailing_newline(@original_file_text)
@file_text = sub_line_ending_backslashes(@file_text)
@@ -212,11 +212,11 @@
# occur when a newline is encountered, but the statement that was expressed
# on that line was not completed on that line.
#
# @param [String] token The token that the lexer matched.
def on_ignored_nl(token)
- log "IGNORED_NL"
+ log 'IGNORED_NL'
current_line = LexedLine.new(super, lineno)
ignored_nl_changed
notify_ignored_nl_observers(current_line, lineno, column)
@@ -304,11 +304,11 @@
super(token)
end
# This is the first thing that exists on a new line--NOT the last!
def on_nl(token)
- log "NL"
+ log 'NL'
current_line = LexedLine.new(super, lineno)
nl_changed
notify_nl_observers(current_line, lineno, column)
@@ -558,20 +558,20 @@
# Used internally as part of the hack to deal with Ripper's lack of dealing
# with line-ending backslashes that break up statements.
#
# @param [String] file_text The file test to check.
- # @param [String] The altered file text.
+ # @return [String] The altered file text.
def sub_line_ending_backslashes(file_text)
- backslash_replacement = "# TAILOR REMOVED BACKSLASH"
+ backslash_replacement = '# TAILOR REMOVED BACKSLASH'
file_text.gsub!(/\\\s*\n?$/, backslash_replacement)
-
+
file_text
end
-
+
def log(*args)
- l = begin; lineno; rescue; "<EOF>"; end
- c = begin; column; rescue; "<EOF>"; end
+ l = begin; lineno; rescue; '<EOF>'; end
+ c = begin; column; rescue; '<EOF>'; end
subclass_name = self.class.to_s.sub(/^Tailor::/, '')
args.first.insert(0, "<#{subclass_name}> #{l}[#{c}]: ")
Tailor::Logger.log(*args)
end
end