Sha256: e4243102ee9b161b57a2b02dac35b9453e7dac3923ba4a982222fcff96a0b663

Contents?: true

Size: 460 Bytes

Versions: 2

Compression:

Stored size: 460 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

2 entries across 2 versions & 1 rubygems

Version Path
grapht-0.1.6 lib/grapht/shell.rb
grapht-0.1.5 lib/grapht/shell.rb