Sha256: 5d7dc4a21dce5e4b1d8ac57f5b16c5681b910737a0334908d4fe18f040c34828

Contents?: true

Size: 974 Bytes

Versions: 3

Compression:

Stored size: 974 Bytes

Contents

module Smoke
  module Source # :nodoc:    
    # The "Data" source allows you to query
    # datasources that are "complete" urls
    # and rely on the automagic object parsing 
    # that smoke provides.
    #
    # For example, you may use this source
    # to query a complete restful api call
    # unpackage the xml response and get a 
    # clean ruby object.
    #
    # Data can take as many urls as you'd like
    # to throw at it.
    #
    # Usage:
    #   Smoke.data(:ruby) do
    #     url "http://api.flickr.com/services/rest/?user_id=36821533%40N00&tags=benschwarz-site&nojsoncallback=1&method=flickr.photos.search&format=json&api_key=your_api_key_here
    #     path :photos, :photo
    #   end
    class Data < Origin
      attr_reader :request

      def url(source_url)
        @url = source_url
      end
      
      protected
      def dispatch
        @request = Smoke::Request.new(@url)
        self.items = @request.body
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
benschwarz-smoke-0.3.10 lib/smoke/source/data.rb
benschwarz-smoke-0.3.7 lib/smoke/source/data.rb
benschwarz-smoke-0.3.9 lib/smoke/source/data.rb