version 0.6.8pre4, changed Pry::Commands.dup to Pry::Commands.clone due to rubinius bug. Made .pryrc run on ordinary pry sessions (not just command line), still need to complete whereami command

This commit is contained in:
John Mair 2011-03-05 01:37:59 +13:00
parent 52349f552a
commit d299f3be30
5 changed files with 43 additions and 6 deletions

7
TODO
View File

@ -1,7 +1,10 @@
Future
* add whereami command, a la the `ir_b` gem
FUTURE
* allows pipes (|) for commands
0.6.8
* add whereami command, a la the `ir_b` gem
* make .pryrc be loaded by run-time pry sessions
0.6.7
* color support
* --simple-prompt for pry commandline

View File

@ -65,10 +65,11 @@ See: `https://github.com/banister` for more information.
end
end.parse!
rcpath = File.expand_path("~/.pryrc")
# invoked via cli
Pry.cli = true
# load ~/.pryrc, if not suppressed with -f option
load rcpath if File.exists?(rcpath) && options[:loadrc]
Pry.should_load_rc = false if !options[:loadrc]
# create the actual context
context = Pry.binding_for(eval(options[:context_string]))

View File

@ -1,6 +1,8 @@
# @author John Mair (banisterfiend)
class Pry
RC_FILES = ["~/.pryrc"]
# class accessors
class << self
@ -62,15 +64,40 @@ class Pry
# Determines whether colored output is enabled.
# @return [Boolean]
attr_accessor :color
# Determines whether the rc file (~/.pryrc) should be loaded.
# @return [Boolean]
attr_accessor :should_load_rc
# Set to true if Pry is invoked from command line using `pry` executable
# @return [Boolean]
attr_accessor :cli
end
# Load the rc files given in the `Pry::RC_FILES` array.
# Defaults to loading just `~/.pryrc`. This method can also
# be used to reload the files if they have changed.
def self.load_rc
RC_FILES.each do |file_name|
file_name = File.expand_path(file_name)
load(file_name) if File.exists?(file_name)
end
end
# Start a Pry REPL.
# This method also loads the files specified in `Pry::RC_FILES` the
# first time it is invoked.
# @param [Object, Binding] target The receiver of the Pry session
# @param [Hash] options
# @option options (see Pry#initialize)
# @example
# Pry.start(Object.new, :input => MyInput.new)
def self.start(target=TOPLEVEL_BINDING, options={})
if should_load_rc && !@rc_loaded
load_rc
@rc_loaded = true
end
new(options).repl(target)
end
@ -129,7 +156,7 @@ class Pry
null_output = Object.new.tap { |v| v.instance_eval { def puts(*) end } }
commands = Pry.commands.dup
commands = Pry.commands.clone
commands.output = options[:show_output] ? Pry.output : null_output
commands.target = Pry.binding_for(options[:context])
@ -151,6 +178,9 @@ class Pry
@print = DEFAULT_PRINT
@hooks = DEFAULT_HOOKS
@color = false
@should_load_rc = true
@rc_loaded = false
@cli = false
end
self.reset_defaults

View File

@ -1,3 +1,3 @@
class Pry
VERSION = "0.6.7"
VERSION = "0.6.8pre4"
end

View File

@ -10,6 +10,9 @@ puts "Testing Pry #{Pry::VERSION}"
puts "With method_source version #{MethodSource::VERSION}"
puts "--"
# Ensure we do not execute any rc files
Pry::RC_FILES.clear
describe Pry do
describe "open a Pry session on an object" do
describe "rep" do