Sha256: 9b439b64ccffb6bf9c8d5933bd3fff5e6dcf93f1e3bf1bd5bae7a4a82e203f55

Contents?: true

Size: 1.24 KB

Versions: 23

Compression:

Stored size: 1.24 KB

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
      
      # The URL that you'd like smoke to source its data from
      # You can also set the type for silly servers that don't set a correct content-type (Flickr!)
      # Example:
      #   url "http://site.com/resource.json", :type => :json
      def url(source_url, options = {})
        @url, @options = source_url, options
      end
      
      protected
      def dispatch          
        @request = Smoke::Request.new(@url, @options)
        self.items = @request.body
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
benschwarz-smoke-0.3.11 lib/smoke/source/data.rb
benschwarz-smoke-0.4.0 lib/smoke/source/data.rb
benschwarz-smoke-0.4.1 lib/smoke/source/data.rb
benschwarz-smoke-0.4.2 lib/smoke/source/data.rb
benschwarz-smoke-0.5.0 lib/smoke/source/data.rb
benschwarz-smoke-0.5.1 lib/smoke/source/data.rb
benschwarz-smoke-0.5.10 lib/smoke/source/data.rb
benschwarz-smoke-0.5.13 lib/smoke/source/data.rb
benschwarz-smoke-0.5.2 lib/smoke/source/data.rb
benschwarz-smoke-0.5.3 lib/smoke/source/data.rb
benschwarz-smoke-0.5.4 lib/smoke/source/data.rb
benschwarz-smoke-0.5.5 lib/smoke/source/data.rb
benschwarz-smoke-0.5.6 lib/smoke/source/data.rb
benschwarz-smoke-0.5.7 lib/smoke/source/data.rb
benschwarz-smoke-0.5.8 lib/smoke/source/data.rb
smoke-0.5.16 lib/smoke/source/data.rb
smoke-0.5.15 lib/smoke/source/data.rb
smoke-0.5.14 lib/smoke/source/data.rb
smoke-0.5.13 lib/smoke/source/data.rb
smoke-0.5.12 lib/smoke/source/data.rb