Sha256: 3136ba7dbdfc6e585be4398a0822e21b2f71d07f043b0713cc9677d470f17b67

Contents?: true

Size: 479 Bytes

Versions: 1

Compression:

Stored size: 479 Bytes

Contents

class Zemanta
  class Fetcher
    def initialize(opts = {})
      @opts = opts
    end

    def post
      @response = cache.fetch || web.fetch
      cache.save(@response)
      parse(@response)
    end

    private

    def cache
      @cache ||= Cache.new(@opts)
    end

    def web
      Web.new(request_opts)
    end

    def parse(data)
      JSON.parse(data)
    end

    def request_opts
      @request_opts ||= Zemanta.config.request_opts.merge(@opts)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zemanta_client-0.0.2 lib/zemanta/fetcher.rb