Module: GitReflow::Sandbox
- Extended by:
- Sandbox
- Included in:
- GitReflow, GitHelpers, GitServer::GitHub, Sandbox, Workflow::ClassMethods
- Defined in:
- lib/git_reflow/sandbox.rb
Defined Under Namespace
Classes: CommandError
Constant Summary collapse
- COLOR_FOR_LABEL =
{ notice: :yellow, info: :yellow, error: :red, deliver_halted: :red, review_halted: :red, success: :green, plain: :white }
Instance Method Summary collapse
- #run(command, options = {}) ⇒ Object
- #run_command_with_label(command, options = {}) ⇒ Object
- #say(message, label_type = :plain) ⇒ Object
Instance Method Details
#run(command, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/git_reflow/sandbox.rb', line 23 def run(command, = {}) = { loud: true, blocking: true, raise: false }.merge() GitReflow.logger.debug "Running... #{command}" if [:with_system] == true system(command) else output = %x{#{command}} if !$?.success? raise CommandError.new(output, "\"#{command}\" failed to run.") if [:raise] == true abort "\"#{command}\" failed to run." if [:blocking] == true end puts output if [:loud] == true output end end |
#run_command_with_label(command, options = {}) ⇒ Object
43 44 45 46 47 |
# File 'lib/git_reflow/sandbox.rb', line 43 def run_command_with_label(command, = {}) label_color = .delete(:color) || :green puts command.colorize(label_color) run(command, ) end |
#say(message, label_type = :plain) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/git_reflow/sandbox.rb', line 49 def say(, label_type = :plain) if COLOR_FOR_LABEL[label_type] label = (label_type.to_s == "plain") ? "" : "[#{ label_type.to_s.gsub('_', ' ').colorize(COLOR_FOR_LABEL[label_type]) }] " puts "#{label}#{}" else puts end end |