Sha256: 5ee2233fe08b592e032f2eb7dbabc9d99ae70fcf2efa5e62760d27cc53d06b6e

Contents?: true

Size: 469 Bytes

Versions: 1

Compression:

Stored size: 469 Bytes

Contents

require 'open3'

module Grapht
  module Shell
    class Error < StandardError; end

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

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grapht-0.1.8 lib/grapht/shell.rb