mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
merge hook/print/prompt constants into pry.rb and remove files
This commit is contained in:
parent
60f164d8c4
commit
37dcc6b85b
4 changed files with 60 additions and 66 deletions
64
lib/pry.rb
64
lib/pry.rb
|
@ -1,6 +1,65 @@
|
|||
# (C) John Mair (banisterfiend) 2011
|
||||
# MIT License
|
||||
|
||||
class Pry
|
||||
# The default hooks - display messages when beginning and ending Pry sessions.
|
||||
DEFAULT_HOOKS = {
|
||||
:before_session => proc do |out, target|
|
||||
# ensure we're actually in a method
|
||||
meth_name = target.eval('__method__')
|
||||
file = target.eval('__FILE__')
|
||||
|
||||
# /unknown/ for rbx
|
||||
if file !~ /(\(.*\))|<.*>/ && file !~ /__unknown__/ && file != "" && file != "-e"
|
||||
Pry.run_command "whereami 5", :output => out, :show_output => true, :context => target, :commands => Pry::Commands
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
# The default prints
|
||||
DEFAULT_PRINT = proc do |output, value|
|
||||
if Pry.color
|
||||
output.puts "=> #{CodeRay.scan(Pry.view(value), :ruby).term}"
|
||||
else
|
||||
output.puts "=> #{Pry.view(value)}"
|
||||
end
|
||||
end
|
||||
|
||||
# Will only show the first line of the backtrace
|
||||
DEFAULT_EXCEPTION_HANDLER = proc do |output, exception|
|
||||
output.puts "#{exception.class}: #{exception.message}"
|
||||
output.puts "from #{exception.backtrace.first}"
|
||||
end
|
||||
|
||||
# The default prompt; includes the target and nesting level
|
||||
DEFAULT_PROMPT = [
|
||||
proc { |target_self, nest_level|
|
||||
if nest_level == 0
|
||||
"pry(#{Pry.view_clip(target_self)})> "
|
||||
else
|
||||
"pry(#{Pry.view_clip(target_self)}):#{Pry.view_clip(nest_level)}> "
|
||||
end
|
||||
},
|
||||
|
||||
proc { |target_self, nest_level|
|
||||
if nest_level == 0
|
||||
"pry(#{Pry.view_clip(target_self)})* "
|
||||
else
|
||||
"pry(#{Pry.view_clip(target_self)}):#{Pry.view_clip(nest_level)}* "
|
||||
end
|
||||
}
|
||||
]
|
||||
|
||||
# A simple prompt - doesn't display target or nesting level
|
||||
SIMPLE_PROMPT = [proc { ">> " }, proc { ">* " }]
|
||||
|
||||
SHELL_PROMPT = [
|
||||
proc { |target_self, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " },
|
||||
proc { |target_self, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} * " }
|
||||
]
|
||||
|
||||
end
|
||||
|
||||
require "method_source"
|
||||
require 'shellwords'
|
||||
require "readline"
|
||||
|
@ -20,16 +79,13 @@ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
|
|||
end
|
||||
|
||||
require "pry/version"
|
||||
require "pry/hooks"
|
||||
require "pry/print"
|
||||
require "pry/helpers"
|
||||
require "pry/command_set"
|
||||
require "pry/commands"
|
||||
require "pry/command_context"
|
||||
require "pry/prompts"
|
||||
require "pry/custom_completions"
|
||||
require "pry/completion"
|
||||
require "pry/plugins"
|
||||
require "pry/core_extensions"
|
||||
require "pry/pry_class"
|
||||
require "pry/pry_instance"
|
||||
require "pry/pry_instance"
|
|
@ -1,17 +0,0 @@
|
|||
class Pry
|
||||
|
||||
# The default hooks - display messages when beginning and ending Pry sessions.
|
||||
DEFAULT_HOOKS = {
|
||||
|
||||
:before_session => proc do |out, target|
|
||||
# ensure we're actually in a method
|
||||
meth_name = target.eval('__method__')
|
||||
file = target.eval('__FILE__')
|
||||
|
||||
# /unknown/ for rbx
|
||||
if file !~ /(\(.*\))|<.*>/ && file !~ /__unknown__/ && file != "" && file != "-e"
|
||||
Pry.run_command "whereami 5", :output => out, :show_output => true, :context => target, :commands => Pry::Commands
|
||||
end
|
||||
end,
|
||||
}
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
class Pry
|
||||
DEFAULT_PRINT = proc do |output, value|
|
||||
if Pry.color
|
||||
output.puts "=> #{CodeRay.scan(Pry.view(value), :ruby).term}"
|
||||
else
|
||||
output.puts "=> #{Pry.view(value)}"
|
||||
end
|
||||
end
|
||||
|
||||
# Will only show the first line of the backtrace
|
||||
DEFAULT_EXCEPTION_HANDLER = proc do |output, exception|
|
||||
output.puts "#{exception.class}: #{exception.message}"
|
||||
output.puts "from #{exception.backtrace.first}"
|
||||
end
|
||||
end
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
class Pry
|
||||
|
||||
# The default prompt; includes the target and nesting level
|
||||
DEFAULT_PROMPT = [
|
||||
proc { |target_self, nest_level|
|
||||
if nest_level == 0
|
||||
"pry(#{Pry.view_clip(target_self)})> "
|
||||
else
|
||||
"pry(#{Pry.view_clip(target_self)}):#{Pry.view_clip(nest_level)}> "
|
||||
end
|
||||
},
|
||||
|
||||
proc { |target_self, nest_level|
|
||||
if nest_level == 0
|
||||
"pry(#{Pry.view_clip(target_self)})* "
|
||||
else
|
||||
"pry(#{Pry.view_clip(target_self)}):#{Pry.view_clip(nest_level)}* "
|
||||
end
|
||||
}
|
||||
]
|
||||
|
||||
# A simple prompt - doesn't display target or nesting level
|
||||
SIMPLE_PROMPT = [proc { ">> " }, proc { ">* " }]
|
||||
|
||||
SHELL_PROMPT = [
|
||||
proc { |target_self, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " },
|
||||
proc { |target_self, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} * " }
|
||||
]
|
||||
end
|
Loading…
Add table
Reference in a new issue