Module: Kamaze::Project::Concern::Cli::WithExitOnFailure

Includes:
Kamaze::Project::Concern::Cli
Included in:
Tools::Gemspec::Packer::Command, Tools::Git::Hooks::BaseHook, Tools::Rspec, Tools::Rubocop, Tools::Vagrant::Shell
Defined in:
lib/kamaze/project/concern/cli/with_exit_on_failure.rb

Overview

TODO:

Add (rspec) test and examples

Concern exit on failure

Use retcode to exit in with_exit_on_failure blocks.

Instance Method Summary collapse

Instance Method Details

#failure?Boolean Also known as: failed? Originally defined in module Kamaze::Project::Concern::Cli

Denote execution is a failure.

Returns:

  • (Boolean)

#retcodeFixnum Originally defined in module Kamaze::Project::Concern::Cli

Status code usable to eventually initiates the termination.

Returns:

  • (Fixnum)

#success?Boolean Also known as: successful? Originally defined in module Kamaze::Project::Concern::Cli

Denote execution is a success.

Returns:

  • (Boolean)

#with_exit_on_failure {|Object| ... } ⇒ Object (protected)

Initiates termination by raising SystemExit exception depending on success of given block.

Yields:

Yield Parameters:

  • (self)

Returns:

Raises:

  • (SystemExit)


29
30
31
# File 'lib/kamaze/project/concern/cli/with_exit_on_failure.rb', line 29

def with_exit_on_failure
  yield(self).tap { exit(retcode) if failure? }
end