Sha256: 10f9e611fac4d29bbda70bc49411428b344f5ea5bf2f26344281e65dca5a0e16

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

module GitReflow
  module Sandbox
    extend self

    COLOR_FOR_LABEL = {
      notice:         :yellow,
      error:          :red,
      deliver_halted: :red,
      review_halted:  :red,
      success:        :green,
      plain:          :white
    }

    def run(command, options = {})
      options = { loud: true }.merge(options)

      if options[:with_system] == true
        system(command)
      elsif options[:loud] == true
        output = %x{#{command}}
        puts output
        output
      else
        %x{#{command}}
      end
    end

    def run_command_with_label(command, options = {})
      label_color = options.delete(:color) || :green
      puts command.colorize(label_color)
      run(command, options)
    end

    def say(message, 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}#{message}"
      else
        puts message
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
git_reflow-0.8.6 lib/git_reflow/sandbox.rb
git_reflow-0.8.4 lib/git_reflow/sandbox.rb
git_reflow-0.8.3 lib/git_reflow/sandbox.rb
git_reflow-0.8.2 lib/git_reflow/sandbox.rb
git_reflow-0.8.1 lib/git_reflow/sandbox.rb
git_reflow-0.8.0 lib/git_reflow/sandbox.rb