class TouchscreenTaps::Executor

Executes commands from config file

Public Class Methods

new(config) click to toggle source
# File lib/touchscreen_taps/executor.rb, line 6
def initialize(config)
  @config = config
end

Public Instance Methods

run(cmd) click to toggle source
# File lib/touchscreen_taps/executor.rb, line 10
def run(cmd)
  return if cmd.nil?

  command = @config.by_keys(command_to_keys(cmd)).fetch('command')
  execute(command) if command
end

Private Instance Methods

command_to_keys(cmd) click to toggle source
# File lib/touchscreen_taps/executor.rb, line 27
def command_to_keys(cmd)
  [cmd[:name], cmd[:fingers]]
end
execute(command) click to toggle source
# File lib/touchscreen_taps/executor.rb, line 19
def execute(command)
  puts "Executing '#{command}'"
  fork do
    Process.daemon(true)
    exec(command)
  end
end