Module: Grapht::Shell

Defined in:
lib/grapht/shell.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

CMD =
File.join(Grapht::ROOT, 'bin/grapht')
ALLOWED_OPTIONS =
%w(-f)

Class Method Summary collapse

Class Method Details

.exec(type, json_data, options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/grapht/shell.rb', line 10

def self.exec(type, json_data, options={})
  options = *options.select { |k,v| ALLOWED_OPTIONS.include? k }.flatten

  out, err, status =
    Open3.capture3 CMD, type, *options, stdin_data: json_data

  raise Grapht::Shell::Error, err unless status.success?
  out
end