Revert "Get rid of Code#highlighted"

This reverts commit 5599b0a976.

And fixes jruby-head.

https://travis-ci.org/pry/pry/jobs/30420112
This commit is contained in:
Kyrylo Silin 2014-07-20 17:31:02 -07:00
parent 80f1b41f39
commit c6f8d5c632
6 changed files with 13 additions and 8 deletions

View File

@ -253,7 +253,12 @@ class Pry
# @return [String] a formatted representation (based on the configuration of
# the object).
def to_s
print_to_output("")
print_to_output("", false)
end
# @return [String] a (possibly highlighted) copy of the source code.
def highlighted
print_to_output("", true)
end
# Writes a formatted representation (based on the configuration of the
@ -261,7 +266,7 @@ class Pry
def print_to_output(output, color=false)
@lines.each do |loc|
loc = loc.dup
loc.colorize(@code_type)
loc.colorize(@code_type) if color
loc.add_line_number(max_lineno_width, color) if @with_line_numbers
loc.add_marker(@marker_lineno) if @with_marker
loc.indent(@indentation_num) if @with_indentation

View File

@ -8,7 +8,7 @@ class Pry
def decorate(content)
content.code_type = code_type
content.between(*between_lines).
with_line_numbers(use_line_numbers?)
with_line_numbers(use_line_numbers?).highlighted
end
def code_type

View File

@ -40,7 +40,7 @@ class Pry
# The source for code_object prepared for display.
def content_for(code_object)
Code.new(code_object.source, start_line_for(code_object)).
with_line_numbers(use_line_numbers?)
with_line_numbers(use_line_numbers?).highlighted
end
end

View File

@ -88,7 +88,7 @@ class Pry
def add_expression(arguments)
expressions << Expression.new(_pry_, target, arg_string)
output.puts "Watching #{Code.new(arg_string)}"
output.puts "Watching #{Code.new(arg_string).highlighted}"
end
def add_hook

View File

@ -6,7 +6,7 @@ class Pry
def initialize(_pry_, target, source)
@_pry_ = _pry_
@target = target
@source = source.strip
@source = Code.new(source).strip
end
def eval!
@ -15,7 +15,7 @@ class Pry
end
def to_s
"#{Code.new(source).strip} => #{value}"
"#{Code.new(source).highlighted.strip} => #{value}"
end
# Has the value of the expression changed?

View File

@ -89,7 +89,7 @@ class Pry
set_file_and_dir_locals(@file)
out = "\n#{text.bold('From:')} #{location}:\n\n" <<
code.with_line_numbers(use_line_numbers?).with_marker(marker) << "\n"
code.with_line_numbers(use_line_numbers?).with_marker(marker).highlighted << "\n"
_pry_.pager.page out
end