Sha256: bf38d51eb7ee8bb5795e09cd92ab34abd42a6740736bdf502dc6e13a2be05b88

Contents?: true

Size: 472 Bytes

Versions: 1

Compression:

Stored size: 472 Bytes

Contents

require 'open3'

module Grapht
  module Shell
    class Error < StandardError; end

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

    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.9 lib/grapht/shell.rb