Sha256: 939cc206e412442fb3712258a13323e7c52d9fcf6ec5dfb3438f33fbe72316e6

Contents?: true

Size: 956 Bytes

Versions: 3

Compression:

Stored size: 956 Bytes

Contents

module GitReflow
  module Sandbox
    extend self

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

      if options[:with_system] == true
        system(command)
      elsif options[:loud] == true
        puts `#{command}`
      else
        `#{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

    # WARNING: this currently only supports OS X and UBUNTU
    def ask_to_open_in_browser(url)
      if RUBY_PLATFORM =~ /darwin|linux/i
        open_in_browser = ask "Would you like to open it in your browser? "
        if open_in_browser =~ /^y/i
          if RUBY_PLATFORM =~ /darwin/i
            # OS X
            run "open #{url}"
          else
            # Ubuntu
            run "xdg-open #{url}"
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_reflow-0.4.2 lib/git_reflow/sandbox.rb
git_reflow-0.4.1 lib/git_reflow/sandbox.rb
git_reflow-0.4.0 lib/git_reflow/sandbox.rb