Sha256: 02a9740681357b6a481766916e5340fb0b3d0ff6f3765150419a5706eabd84ab

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require "net/http"
require_relative "configuration"
require_relative "requests"

module Tika
  class Client

    include Requests

    class << self
      def config
        @config ||= Configuration.new
      end

      def configure
        yield config
      end
    end

    attr_reader :host, :port

    def initialize(opts={})
      @host = opts.fetch(:host, self.class.config.host)
      @port = opts.fetch(:port, self.class.config.port)
    end

    def get_text(opts={})
      GetTextRequest.execute(connection, opts)
    end

    def get_metadata(opts={})
      GetMetadataRequest.execute(connection, opts)
    end

    def get_version
      GetVersionRequest.execute(connection)
    end

    def get_mime_types
      GetMimeTypesRequest.execute(connection)
    end

    def get_parsers
      GetParsersRequest.execute(connection)
    end

    def get_parsers_details
      GetParsersDetailsRequest.execute(connection)
    end

    def get_detectors
      GetDetectorsRequest.execute(connection)
    end

    private
    
    def connection
      @connection ||= Net::HTTP.new(host, port)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tika-client-0.2.0 lib/tika/client.rb