Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

version 0.6.8pre4, changed Pry::Commands.dup to Pry::Commands.clone d…

…ue to rubinius bug. Made .pryrc run on ordinary pry sessions (not just command line), still need to complete whereami command
  • Loading branch information...
commit d299f3be3004d5ccab5e7369380ef5f6863665ed 1 parent 52349f5
@banister banister authored
View
7 TODO
@@ -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
5 bin/pry
@@ -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
32 lib/pry/pry_class.rb
@@ -1,6 +1,8 @@
# @author John Mair (banisterfiend)
class Pry
+ RC_FILES = ["~/.pryrc"]
+
# class accessors
class << self
@@ -62,15 +64,40 @@ class << self
# 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 @@ def self.run_command(arg_string, options={})
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 @@ def self.reset_defaults
@print = DEFAULT_PRINT
@hooks = DEFAULT_HOOKS
@color = false
+ @should_load_rc = true
+ @rc_loaded = false
+ @cli = false
end
self.reset_defaults
View
2  lib/pry/version.rb
@@ -1,3 +1,3 @@
class Pry
- VERSION = "0.6.7"
+ VERSION = "0.6.8pre4"
end
View
3  test/test.rb
@@ -10,6 +10,9 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.