Sha256: c7ce05b98b57fb4a3f0502f387f196408e6b361919f4a83c2c69638ffe481e20

Contents?: true

Size: 736 Bytes

Versions: 3

Compression:

Stored size: 736 Bytes

Contents

require "open3"

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

3 entries across 3 versions & 1 rubygems

Version Path
tika-app-0.2.1 lib/tika/command.rb
tika-app-0.2.0 lib/tika/command.rb
tika-app-0.1.1 lib/tika/command.rb