Sha256: 3a60061b61e7447641a7c7fa022ac616abaacb282a4a27ec051daf73b0c82f50

Contents?: true

Size: 492 Bytes

Versions: 1

Compression:

Stored size: 492 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, binmode: true
        
      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.7 lib/grapht/shell.rb