mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Remove output.write
Many plugins only define a puts method on the output object. This change removse the ability to customize the formatter used when outputting variables in `ls`. We should reconsider the best way to do this.
This commit is contained in:
parent
92a1b86e1e
commit
1aacb10cb3
5 changed files with 8 additions and 8 deletions
|
@ -46,6 +46,7 @@ class Pry
|
|||
colorized = colorized.sub(/(\n*)\z/, "\e[0m\\1") if Pry.color
|
||||
|
||||
result = colorized.gsub(/%<(.*?)#{nonce}/, '#<\1')
|
||||
result = "=> #{result}"if options[:hashrocket]
|
||||
Helpers::BaseHelpers.stagger_output(result, output)
|
||||
end
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ class Pry
|
|||
|
||||
def format_value(value)
|
||||
accumulator = StringIO.new
|
||||
Pry.print.call(accumulator, value)
|
||||
Pry.output_with_default_format(accumulator, value, :hashrocket => false)
|
||||
accumulator.string
|
||||
end
|
||||
|
||||
|
|
|
@ -336,7 +336,6 @@ class Pry
|
|||
if last_result_is_exception?
|
||||
exception_handler.call(output, result, self)
|
||||
elsif should_print?
|
||||
output.write(Pry.config.output_prefix)
|
||||
print.call(output, result)
|
||||
else
|
||||
# nothin'
|
||||
|
|
|
@ -92,7 +92,7 @@ describe "test Pry defaults" do
|
|||
end
|
||||
|
||||
it "should set the print default, and the default should be overridable" do
|
||||
new_print = proc { |out, value| out.puts "LOL" }
|
||||
new_print = proc { |out, value| out.puts "=> LOL" }
|
||||
Pry.print = new_print
|
||||
|
||||
Pry.new.print.should == Pry.print
|
||||
|
@ -102,7 +102,7 @@ describe "test Pry defaults" do
|
|||
@str_output = StringIO.new
|
||||
Pry.new(:input => InputTester.new("\"test\""), :output => @str_output,
|
||||
:print => proc { |out, value| out.puts value.reverse }).rep
|
||||
@str_output.string.should == "=> tset\n"
|
||||
@str_output.string.should == "tset\n"
|
||||
|
||||
Pry.new.print.should == Pry.print
|
||||
@str_output = StringIO.new
|
||||
|
|
|
@ -34,10 +34,10 @@ describe Pry do
|
|||
mock_pry("[1]").should =~ /^=> \[1\]/
|
||||
end
|
||||
|
||||
it "should not include the =>" do
|
||||
it "should include the =>" do
|
||||
accumulator = StringIO.new
|
||||
Pry.config.print.call(accumulator, [1])
|
||||
accumulator.string.should == "\[1\]\n"
|
||||
accumulator.string.should == "=> \[1\]\n"
|
||||
end
|
||||
|
||||
it "should not be phased by un-inspectable things" do
|
||||
|
@ -57,7 +57,7 @@ describe Pry do
|
|||
it "should colorize strings as though they were ruby" do
|
||||
accumulator = StringIO.new
|
||||
Pry.config.print.call(accumulator, [1])
|
||||
accumulator.string.should == "[\e[1;34m1\e[0m]\e[0m\n"
|
||||
accumulator.string.should == "=> [\e[1;34m1\e[0m]\e[0m\n"
|
||||
end
|
||||
|
||||
it "should not colorize strings that already include color" do
|
||||
|
@ -68,7 +68,7 @@ describe Pry do
|
|||
accumulator = StringIO.new
|
||||
Pry.config.print.call(accumulator, f)
|
||||
# We add an extra \e[0m to prevent color leak
|
||||
accumulator.string.should == "\e[1;31mFoo\e[0m\e[0m\n"
|
||||
accumulator.string.should == "=> \e[1;31mFoo\e[0m\e[0m\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue