summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyrylo Silin <silin@kyrylo.org>2019-04-06 02:43:56 +0300
committerKyrylo Silin <silin@kyrylo.org>2019-04-08 00:49:39 +0300
commit51120c5f14fa69ef7907a474ed26f0414e34bcfc (patch)
tree1516603e49f447a1b0bb2ad0ad79cc45dabce8a8
parent6b4a303bfb4213044978ee395b08ce59d2d0cd39 (diff)
downloadpry-51120c5f14fa69ef7907a474ed26f0414e34bcfc.tar.gz
command: move BlockCommand to a separate file
-rw-r--r--lib/pry.rb1
-rw-r--r--lib/pry/block_command.rb23
-rw-r--r--lib/pry/command.rb22
3 files changed, 24 insertions, 22 deletions
diff --git a/lib/pry.rb b/lib/pry.rb
index 59c3d350..51227e59 100644
--- a/lib/pry.rb
+++ b/lib/pry.rb
@@ -15,6 +15,7 @@ require 'pry/hooks'
require 'pry/input_completer'
require 'pry/command'
require 'pry/class_command'
+require 'pry/block_command'
require 'pry/command_set'
require 'pry/syntax_highlighter'
diff --git a/lib/pry/block_command.rb b/lib/pry/block_command.rb
new file mode 100644
index 00000000..7491fb06
--- /dev/null
+++ b/lib/pry/block_command.rb
@@ -0,0 +1,23 @@
+class Pry
+ # A super-class for Commands that are created with a single block.
+ #
+ # This class ensures that the block is called with the correct number of
+ # arguments and the right context.
+ #
+ # Create subclasses using {Pry::CommandSet#command}.
+ class BlockCommand < Command
+ # backwards compatibility
+ alias opts context
+
+ # Call the block that was registered with this command.
+ # @param [Array<String>] args The arguments passed
+ # @return [Object] The return value of the block
+ def call(*args)
+ instance_exec(*correct_arg_arity(block.arity, args), &block)
+ end
+
+ def help
+ "#{command_options[:listing].to_s.ljust(18)} #{description}"
+ end
+ end
+end
diff --git a/lib/pry/command.rb b/lib/pry/command.rb
index 8b311a1a..b5846cd8 100644
--- a/lib/pry/command.rb
+++ b/lib/pry/command.rb
@@ -516,26 +516,4 @@ class Pry
end
end
end
-
- # A super-class for Commands that are created with a single block.
- #
- # This class ensures that the block is called with the correct number of arguments
- # and the right context.
- #
- # Create subclasses using {Pry::CommandSet#command}.
- class BlockCommand < Command
- # backwards compatibility
- alias opts context
-
- # Call the block that was registered with this command.
- # @param [Array<String>] args The arguments passed
- # @return [Object] The return value of the block
- def call(*args)
- instance_exec(*correct_arg_arity(block.arity, args), &block)
- end
-
- def help
- "#{command_options[:listing].to_s.ljust(18)} #{description}"
- end
- end
end