diff --git a/lib/pry/command.rb b/lib/pry/command.rb index 45ea5100..6bad49a4 100644 --- a/lib/pry/command.rb +++ b/lib/pry/command.rb @@ -37,7 +37,7 @@ class Pry # Define or get the command's options def command_options(arg=nil) - @command_options ||= DEFAULT_OPTIONS.call(match) + @command_options ||= default_options(match) @command_options.merge!(arg) if arg @command_options end @@ -77,6 +77,19 @@ class Pry Array(block.source_location).last end alias_method :line, :source_line + + def default_options(match) + { + :requires_gem => [], + :keep_retval => false, + :argument_required => false, + :interpolate => true, + :shellwords => true, + :listing => (String === match ? match : match.inspect), + :use_prefix => true, + :takes_block => false + } + end end # Make those properties accessible to instances @@ -196,19 +209,6 @@ class Pry end end - DEFAULT_OPTIONS = proc do |match| - { - :requires_gem => [], - :keep_retval => false, - :argument_required => false, - :interpolate => true, - :shellwords => true, - :listing => (String === match ? match : match.inspect), - :use_prefix => true, - :takes_block => false - } - end - # Properties of one execution of a command (passed by {Pry#run_command} as a hash of # context and expanded in `#initialize` attr_accessor :output diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb index b3c79e84..adafd084 100644 --- a/lib/pry/command_set.rb +++ b/lib/pry/command_set.rb @@ -81,7 +81,7 @@ class Pry # # number-N regex command def block_command(match, description="No description.", options={}, &block) description, options = ["No description.", description] if description.is_a?(Hash) - options = Pry::Command::DEFAULT_OPTIONS.call(match).merge!(options) + options = Pry::Command.default_options(match).merge!(options) commands[match] = Pry::BlockCommand.subclass(match, description, options, helper_module, &block) end @@ -113,7 +113,7 @@ class Pry # def create_command(match, description="No description.", options={}, &block) description, options = ["No description.", description] if description.is_a?(Hash) - options = Pry::Command::DEFAULT_OPTIONS.call(match).merge!(options) + options = Pry::Command.default_options(match).merge!(options) commands[match] = Pry::ClassCommand.subclass(match, description, options, helper_module, &block) commands[match].class_eval(&block)