Module: RubyClock::Shell

Included in:
RubyClock
Defined in:
lib/ruby-clock/shell.rb

Instance Method Summary collapse

Instance Method Details

#shell(command) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/ruby-clock/shell.rb', line 28

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

#shell_runnerObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ruby-clock/shell.rb', line 2

def shell_runner
  @shell_runner ||= begin
    require 'terrapin'
    unless Terrapin::CommandLine.runner.class == Terrapin::CommandLine::ProcessRunner
      puts "\n        \u{1F937} terrapin is installed, but for some reason terrapin is\n          using backticks as its runner.\n\n      MESSAGE\n    end\n\n    puts '\u{1F406} Using terrapin for shell commands.'\n    :terrapin\n  rescue LoadError\n    puts <<~MESSAGE\n\n      \u{1F9A5} Using ruby backticks for shell commands.\n         For better performance, install the terrapin gem.\n         See README.md for more info.\n\n    MESSAGE\n    :backticks\n  end\nend\n"