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

save before computer crash

This commit is contained in:
John Mair 2011-06-11 22:44:30 +12:00
parent ff4781a24e
commit 3c7a1c2eca
6 changed files with 19 additions and 12 deletions

View file

@ -2,7 +2,7 @@
# MIT License
require 'pp'
require 'pry/helpers/base_helpers'
class Pry
# The default hooks - display messages when beginning and ending Pry sessions.
DEFAULT_HOOKS = {
@ -20,11 +20,7 @@ class Pry
# The default prints
DEFAULT_PRINT = proc do |output, value|
if Pry.color
output.puts "=> #{CodeRay.scan(value.pretty_inspect, :ruby).term}"
else
output.puts "=> #{Pry.view(value)}"
end
Helpers::BaseHelpers.stagger_output("=> #{Helpers::BaseHelpers.colorize_code(value.pretty_inspect)}", output)
end
# Will only show the first line of the backtrace
@ -53,7 +49,7 @@ class Pry
]
# A simple prompt - doesn't display target or nesting level
SIMPLE_PROMPT = [proc { ">> " }, proc { ">* " }]
SIMPLE_PROMPT = [proc { ">> " }, proc { " | " }]
SHELL_PROMPT = [
proc { |target_self, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " },

View file

@ -22,8 +22,5 @@ class Pry
import DefaultCommands::Shell
import DefaultCommands::Introspection
import DefaultCommands::EasterEggs
# Helpers::CommandHelpers.try_to_load_pry_doc
end
end

View file

@ -89,8 +89,12 @@ class Pry
# @return [OpenStruct]
attr_accessor :plugins
# @return [Integer] Amount of results that will be stored into _out_
# @return [Integer] Amount of results that will be stored into out
attr_accessor :memory_size
# @return [Boolean] Whether or not evalation results (`=>`) are sent
# through a pager.
attr_accessor :result_pager
end
end

View file

@ -67,6 +67,7 @@ class Pry
alias_command "!!@", "exit-all", ""
command "exit-program", "End the current program. Aliases: quit-program, !!!" do
Pry.active_instance.save_history if Pry.config.history.should_save
exit
end

View file

@ -63,6 +63,14 @@ class Pry
end
end
def colorize_code(code)
if Pry.color
CodeRay.scan(code, :ruby).term
else
code
end
end
def highlight(string, regexp, highlight_color=:bright_yellow)
highlighted = string.gsub(regexp) { |match| "<#{highlight_color}>#{match}</#{highlight_color}>" }
end
@ -93,7 +101,7 @@ class Pry
# Try to use `less` for paging, if it fails then use
# simple_pager. Also do not page if Pry.pager is falsey
# FIXME! Another JRuby hack
def stagger_output(text)
def stagger_output(text, output=output())
if text.lines.count < page_size || !Pry.pager
output.puts text
return

View file

@ -201,6 +201,7 @@ class Pry
config.history.file = File.expand_path("~/.pry_history")
config.memory_size = 100
config.results_pager = true
end
# Set all the configurable options back to their default values