mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
fixed tempfile-related bug and failing test and got rid of Pry.view() around nest_level in DEFAULT_PROMPT
This commit is contained in:
parent
b460bc89c5
commit
af11439d55
5 changed files with 26 additions and 13 deletions
|
@ -17,7 +17,7 @@ class Pry
|
|||
end
|
||||
}
|
||||
|
||||
# The default prints
|
||||
# The default print
|
||||
DEFAULT_PRINT = proc do |output, value|
|
||||
stringified = begin
|
||||
value.pretty_inspect
|
||||
|
@ -57,7 +57,7 @@ class Pry
|
|||
if nest_level == 0
|
||||
"pry(#{Pry.view_clip(target_self)})> "
|
||||
else
|
||||
"pry(#{Pry.view_clip(target_self)}):#{Pry.view_clip(nest_level)}> "
|
||||
"pry(#{Pry.view_clip(target_self)}):#{nest_level}> "
|
||||
end
|
||||
},
|
||||
|
||||
|
@ -65,7 +65,7 @@ class Pry
|
|||
if nest_level == 0
|
||||
"pry(#{Pry.view_clip(target_self)})* "
|
||||
else
|
||||
"pry(#{Pry.view_clip(target_self)}):#{Pry.view_clip(nest_level)}* "
|
||||
"pry(#{Pry.view_clip(target_self)}):#{nest_level}* "
|
||||
end
|
||||
}
|
||||
]
|
||||
|
|
|
@ -146,8 +146,9 @@ class Pry
|
|||
should_reload_at_top_level = opts[:n] ? false : true
|
||||
|
||||
elsif opts.t? || args.first.nil?
|
||||
file_name = Tempfile.new(["tmp", ".rb"]).tap(&:close).path
|
||||
File.open(file_name, "w") { |f| f.puts eval_string } if !eval_string.empty?
|
||||
file_name = temp_file do |f|
|
||||
f.puts eval_string if !eval_string.empty?
|
||||
end
|
||||
line = eval_string.lines.count + 1
|
||||
should_reload_locally = opts[:n] ? false : true
|
||||
else
|
||||
|
|
|
@ -39,6 +39,16 @@ class Pry
|
|||
end
|
||||
end
|
||||
|
||||
# Open a temp file and yield it to the block, closing it after
|
||||
# @return [String] The path of the temp file
|
||||
def temp_file
|
||||
file = Tempfile.new(["tmp", ".rb"])
|
||||
yield file
|
||||
file.path
|
||||
ensure
|
||||
file.close
|
||||
end
|
||||
|
||||
########### RBX HELPERS #############
|
||||
def is_core_rbx_path?(path)
|
||||
rbx? &&
|
||||
|
|
|
@ -1135,12 +1135,12 @@ describe Pry do
|
|||
end
|
||||
end
|
||||
|
||||
# describe "given the 'main' object" do
|
||||
# it "returns the #inspect of main (special case)" do
|
||||
# o = TOPLEVEL_BINDING.eval('self')
|
||||
# Pry.view_clip(o, VC_MAX_LENGTH).should == o.inspect
|
||||
# end
|
||||
# end
|
||||
describe "given the 'main' object" do
|
||||
it "returns the #inspect of main (special case)" do
|
||||
o = TOPLEVEL_BINDING.eval('self')
|
||||
Pry.view_clip(o, VC_MAX_LENGTH).should == o.inspect
|
||||
end
|
||||
end
|
||||
|
||||
describe "given an object with an #inspect string as long as the maximum specified" do
|
||||
it "returns the #<> format of the object (never use inspect)" do
|
||||
|
|
|
@ -5,7 +5,8 @@ describe Pry do
|
|||
|
||||
before do
|
||||
Pry.history.clear
|
||||
@hist = Tempfile.new(["tmp", ".pry_history"]).tap(&:close).path
|
||||
@file = Tempfile.new(["tmp", ".pry_history"])
|
||||
@hist = @file.path
|
||||
File.open(@hist, 'w') {|f| f << "1\n2\n3\n" }
|
||||
@old_hist = Pry.config.history.file
|
||||
Pry.config.history.file = @hist
|
||||
|
@ -13,7 +14,8 @@ describe Pry do
|
|||
end
|
||||
|
||||
after do
|
||||
File.unlink @hist
|
||||
@file.close
|
||||
File.unlink(@hist)
|
||||
Pry.config.history.file = @old_hist
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue