Sha256: 6056f81a7d00056a6bd4ee9523fea96d1f919464f0079c7feb86b2c002f70f3b

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

require "open3"
require "tempfile"
require_relative "result"

module Tika
  class Command

    class << self
      attr_accessor :options, :result_class

      def execute(app, *args)
        new(app, *args).execute
      end
    end

    attr_reader :app, :file, :options

    def initialize(app, *args)
      @app = app
      @file = args.shift
      @options = args.pop || {}
    end

    def result_class
      self.class.result_class
    end

    def command_line
      cmd = app.command_line + self.class.options
      if options[:password]
        cmd << "-p#{options[:password]}"
      end
      if file
        cmd << file
      end
      cmd
    end

    def execute
      raw_result = Open3.capture3(*command_line)
      result_class.new(*raw_result)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tika-app-0.1.0 lib/tika/command.rb