Class: Miniflow::TTYCommand

Inherits:
TTY::Command
  • Object
show all
Defined in:
lib/miniflow/tty_command.rb

Overview

Miniflow uses tty-command to execute the command. Please see the following website for more information. ttytoolkit.org/

Defined Under Namespace

Classes: CustomPretty

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ TTYCommand

Returns a new instance of TTYCommand.



36
37
38
39
# File 'lib/miniflow/tty_command.rb', line 36

def initialize(*args)
  # Do not output uuid
  super(*args, printer: CustomPretty, uuid: true)
end

Instance Method Details

#include_meta_character?(str) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
55
# File 'lib/miniflow/tty_command.rb', line 52

def include_meta_character?(str)
  ['*', '?', '{', '}', '[', ']', '<', '>', '(', ')', '~', '&', '|', '\\',
   '$', ';', "'", '`', '"', "\n"].any? { |i| str.include?(i) }
end

#run2(*args) ⇒ Object

run2 can execute the command in which the UNIX pipeline is used.



42
43
44
45
46
47
48
49
50
# File 'lib/miniflow/tty_command.rb', line 42

def run2(*args)
  args.map!(&:to_s)
  command = args.join(' ')
  if include_meta_character?(command)
    run(command)
  else
    run(*args)
  end
end