Class: GitTree::ExecCommand
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- GitTree::ExecCommand
- Defined in:
- lib/commands/git_exec.rb
Constant Summary
Constants included from Logging
Logging::DEBUG, Logging::NORMAL, Logging::QUIET, Logging::VERBOSE
Instance Attribute Summary collapse
-
#runner ⇒ Object
writeonly
Sets the attribute runner.
-
#walker ⇒ Object
writeonly
Sets the attribute walker.
Instance Method Summary collapse
-
#initialize(args = ARGV, options: {}) ⇒ ExecCommand
constructor
A new instance of ExecCommand.
- #run ⇒ Object
Methods inherited from AbstractCommand
Methods included from Logging
#log, #log_stdout, verbosity, verbosity=
Constructor Details
#initialize(args = ARGV, options: {}) ⇒ ExecCommand
Returns a new instance of ExecCommand.
11 12 13 14 15 16 17 |
# File 'lib/commands/git_exec.rb', line 11 def initialize(args = ARGV, options: {}) $PROGRAM_NAME = 'git-exec' super # Allow walker and runner to be injected for testing @runner = @options.delete(:runner) @walker = @options.delete(:walker) end |
Instance Attribute Details
#runner=(value) ⇒ Object (writeonly)
Sets the attribute runner
9 10 11 |
# File 'lib/commands/git_exec.rb', line 9 def runner=(value) @runner = value end |
#walker=(value) ⇒ Object (writeonly)
Sets the attribute walker
9 10 11 |
# File 'lib/commands/git_exec.rb', line 9 def walker=(value) @walker = value end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/commands/git_exec.rb', line 19 def run setup return help('At least one root and a command must be specified.') if @args.length < 2 @runner ||= CommandRunner.new # The last argument is the command to execute, the rest are roots for the walker. @walker ||= GitTreeWalker.new(@args[0..-2], options: @options) command = @args.last @walker.process do |dir, _thread_id, _walker| execute_and_log(dir, command) end end |