This repository has been archived by the owner on Jun 8, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
46 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Kumade | ||
class Base < Thor::Shell::Color | ||
def initialize | ||
super() | ||
end | ||
|
||
def run_or_error(commands, error_message) | ||
all_commands = [commands].flatten.join(' && ') | ||
if @pretending | ||
say_status(:run, all_commands) | ||
else | ||
error(error_message) unless run(all_commands) | ||
end | ||
end | ||
|
||
def run(command, config = {}) | ||
say_status :run, command | ||
config[:capture] ? `#{command}` : system("#{command}") | ||
end | ||
|
||
def error(message) | ||
say("==> ! #{message}", :red) | ||
exit 1 | ||
end | ||
|
||
def success(message) | ||
say("==> #{message}", :green) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'spec_helper' | ||
|
||
describe Kumade::Base, "#success" do | ||
it "exists" do | ||
subject.should respond_to(:success) | ||
end | ||
end | ||
|
||
describe Kumade::Base, "#error" do | ||
it "exists" do | ||
subject.should respond_to(:error) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters