Sha256: 7a90019092f63dde8450d15c5a087e150746850cc562d184486faa166c590bd8

Contents?: true

Size: 829 Bytes

Versions: 6

Compression:

Stored size: 829 Bytes

Contents

module RubyClock::Shell
  def shell_runner
    @shell_runner ||= begin
      require 'terrapin'
      unless Terrapin::CommandLine.runner.class == Terrapin::CommandLine::ProcessRunner
        puts <<~MESSAGE

          🤷 terrapin is installed, but for some reason terrapin is
            using backticks as its runner.

        MESSAGE
      end

      puts '🐆 Using terrapin for shell commands.'
      :terrapin
    rescue LoadError
      puts <<~MESSAGE

        🦥 Using ruby backticks for shell commands.
           For better performance, install the terrapin gem.
           See README.md for more info.

      MESSAGE
      :backticks
    end
  end

  def shell(command)
    case shell_runner
    when :terrapin
      Terrapin::CommandLine.new(command).run
    when :backticks
      `#{command}`
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-clock-2.0.1 lib/ruby-clock/shell.rb
ruby-clock-2.0.0 lib/ruby-clock/shell.rb
ruby-clock-2.0.0.beta10 lib/ruby-clock/shell.rb
ruby-clock-2.0.0.beta9 lib/ruby-clock/shell.rb
ruby-clock-2.0.0.beta8 lib/ruby-clock/shell.rb
ruby-clock-2.0.0.beta7 lib/ruby-clock/shell.rb