From 6f7e483884d9792920f1a9a1874769c502d38261 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Thu, 27 Dec 2012 13:21:34 +0200 Subject: [PATCH] Move command options Proc under Command namespace Because it fits better there and is also hidden from the user. Signed-off-by: Kyrylo Silin --- lib/pry.rb | 13 ------------- lib/pry/command.rb | 15 ++++++++++++++- lib/pry/command_set.rb | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/pry.rb b/lib/pry.rb index 9cf0615d..3e7211ce 100644 --- a/lib/pry.rb +++ b/lib/pry.rb @@ -130,19 +130,6 @@ class Pry end end - Pry::DEFAULT_COMMAND_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 - # Store the current working directory. This allows show-source etc. to work if # your process has changed directory since boot. [Issue #675] INITIAL_PWD = Dir.pwd diff --git a/lib/pry/command.rb b/lib/pry/command.rb index 8c615d0c..d30e8b8c 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 ||= Pry::DEFAULT_COMMAND_OPTIONS.call(match) + @command_options ||= DEFAULT_OPTIONS.call(match) @command_options.merge!(arg) if arg @command_options end @@ -196,6 +196,19 @@ 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 c5c94608..b3c79e84 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::DEFAULT_COMMAND_OPTIONS.call(match).merge!(options) + options = Pry::Command::DEFAULT_OPTIONS.call(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::DEFAULT_COMMAND_OPTIONS.call(match).merge!(options) + options = Pry::Command::DEFAULT_OPTIONS.call(match).merge!(options) commands[match] = Pry::ClassCommand.subclass(match, description, options, helper_module, &block) commands[match].class_eval(&block)