1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Revert "refactored add_line_numbers to use colorize method"

This reverts commit 3c6f8ecc9c.
This commit is contained in:
Rob Gleeson 2011-05-06 14:52:27 +01:00
parent 54975c1a33
commit c611b45f57

View file

@ -23,16 +23,15 @@ class Pry
end
end
def colorize text
Pry.color ? CodeRay.scan(text.to_s, :ruby).term : text
end
def add_line_numbers(lines, start_line)
line_array = lines.each_line.to_a
line_array.each_with_index.map do |line, idx|
adjusted_index = idx + start_line
if Pry.color
cindex = CodeRay.scan("#{adjusted_index}", :ruby).term
"#{cindex}: #{line}"
else
"#{idx}: #{line}"
end
"#{colorize adjusted_index}: #{line}"
end.join
end
@ -67,6 +66,19 @@ class Pry
end
end
def remove_first_word(text)
text.split.drop(1).join(' ')
end
# turn off color for duration of block
def no_color(&block)
old_color_state = Pry.color
Pry.color = false
yield
ensure
Pry.color = old_color_state
end
def code_and_code_type_for(meth)
case code_type = code_type_for(meth)
when nil