Sha256: f26bb6ac973781027cbf8966dcffc6d110c69f497096b2d89ae9a4fe596101e5

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require "json"
require "net/http"
require_relative "request"

module Tika
  module Requests

    PUT = Net::HTTP::Put
    GET = Net::HTTP::Get

    class TextRequest < Request
      def self.headers
        {"Accept" => "text/plain"}
      end
    end

    class JSONRequest < Request
      def self.headers
        {"Accept" => "application/json"}
      end

      def handle_response(response)
        JSON.load(response.body)
      end
    end

    class GetTextRequest < TextRequest
      self.http_method = PUT
      self.path        = "/tika"
    end

    class GetMetadataRequest < JSONRequest
      self.http_method = PUT
      self.path        = "/meta"
    end

    class GetVersionRequest < Request
      self.http_method = GET
      self.path        = "/version"
    end

    class GetMimeTypesRequest < JSONRequest
      self.http_method = GET
      self.path        = "/mime-types"
    end

    class GetParsersRequest < JSONRequest
      self.http_method = GET
      self.path        = "/parsers"
    end

    class GetParsersDetailsRequest < JSONRequest
      self.http_method = GET
      self.path        = "/parsers/details"
    end

    class GetDetectorsRequest < JSONRequest
      self.http_method = GET
      self.path        = "/detectors"
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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