lib/tika/client.rb in tika-client-0.1.0 vs lib/tika/client.rb in tika-client-0.1.1

- old
+ new

@@ -1,48 +1,45 @@ require_relative "configuration" -require_relative "api" -require_relative "request" -require "forwardable" +require_relative "requests" module Tika class Client - extend Forwardable + include Requests + class << self def config @config ||= Configuration.new end def configure yield config end end - attr_accessor :host, :port, :api - def_delegators :api, :endpoint, :has_endpoint? + attr_reader :host, :port def initialize(opts={}) @host = opts.fetch(:host, config.host) @port = opts.fetch(:port, config.port) - @api = Api.new end - def config - self.class.config + def get_text(opts={}) + GetTextRequest.execute(connection, opts) end - def connection - @connection ||= Net::HTTP.new(host, port) + def get_metadata(opts={}) + GetMetadataRequest.execute(connection, opts) end - def execute(name, opts={}) - request = Request.new(connection, endpoint(name)) - request.execute(opts) + private + + def config + self.class.config end - def method_missing(name, *args) - return execute(name, *args) if has_endpoint?(name) - super + def connection + @connection ||= Net::HTTP.new(host, port) end end end