Sha256: 8783931dd83a5063a5cded3bd9b0557cdea570a507d37896d12db32fbfcc6388

Contents?: true

Size: 751 Bytes

Versions: 2

Compression:

Stored size: 751 Bytes

Contents

require 'open3'

module Propaganda    
  module Fop
    class Shell
      def initialize(verbose=false)
        @verbose = verbose
      end
      
      def invoke(*args)
        command = "java -Djava.awt.headless=true -jar #{jarpath} #{args.join(' ')}"
        if @verbose
          `#{command}`
        else
          stdin, stdout, stderr = Open3.popen3(command)
          @errors = stderr.read
          @output = stdout.read
          raise "Could not invoke: #{@errors}" unless @errors.blank?
          @output
        end  
      end

      private 
      
      def self.jarpath
        path = File.join(File.dirname(__FILE__), '..', '..', '..', 'java')
        File.expand_path(File.join(path, 'fop.jar'))
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
propaganda-0.3.0 lib/propaganda/fop/shell.rb
propaganda-0.2.0 lib/propaganda/fop/shell.rb