Class: Papa::Command::Base
- Inherits:
-
Object
- Object
- Papa::Command::Base
- Defined in:
- lib/papa/command/base.rb
Direct Known Subclasses
Git::Branch, Git::BranchDelete, Git::Checkout, Git::Fetch, Git::Merge, Git::MergeAbort, Git::Pull, Git::Push, Git::PushForce, Git::Rebase, Git::RebaseAbort, Git::ResetHard, Git::Tag, Git::TagPush, Larga::Deploy, Larga::Type, Slack::SendMessage
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#exit_status ⇒ Object
Returns the value of attribute exit_status.
-
#silent ⇒ Object
Returns the value of attribute silent.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #failed? ⇒ Boolean
- #failure_message ⇒ Object
-
#initialize(command, options = {}) ⇒ Base
constructor
A new instance of Base.
- #run ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(command, options = {}) ⇒ Base
Returns a new instance of Base.
9 10 11 12 |
# File 'lib/papa/command/base.rb', line 9 def initialize(command, = {}) @command = command @silent = .has_key?(:silent) ? [:silent] : false end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
7 8 9 |
# File 'lib/papa/command/base.rb', line 7 def command @command end |
#exit_status ⇒ Object
Returns the value of attribute exit_status.
7 8 9 |
# File 'lib/papa/command/base.rb', line 7 def exit_status @exit_status end |
#silent ⇒ Object
Returns the value of attribute silent.
7 8 9 |
# File 'lib/papa/command/base.rb', line 7 def silent @silent end |
#stderr ⇒ Object
Returns the value of attribute stderr.
7 8 9 |
# File 'lib/papa/command/base.rb', line 7 def stderr @stderr end |
#stdout ⇒ Object
Returns the value of attribute stdout.
7 8 9 |
# File 'lib/papa/command/base.rb', line 7 def stdout @stdout end |
Instance Method Details
#cleanup ⇒ Object
29 30 31 |
# File 'lib/papa/command/base.rb', line 29 def cleanup # Override me end |
#failed? ⇒ Boolean
37 38 39 |
# File 'lib/papa/command/base.rb', line 37 def failed? exit_status != 0 end |
#failure_message ⇒ Object
22 23 24 25 26 27 |
# File 'lib/papa/command/base.rb', line 22 def = "Error while running #{command.bold}" Helper::Output.error Helper::Output.error stderr end |
#run ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/papa/command/base.rb', line 14 def run return if command.nil? Helper::Output.stdout "Running #{command.bold}..." unless silent @stdout, @stderr, status = Open3.capture3(command) @exit_status = status.exitstatus self end |
#success? ⇒ Boolean
33 34 35 |
# File 'lib/papa/command/base.rb', line 33 def success? !failed? end |