Class: Smoke::Data

Inherits:
Origin show all
Defined in:
lib/smoke/source/data.rb

Overview

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

Instance Attribute Summary collapse

Attributes inherited from Origin

#exposed, #items, #name, #requirements

Instance Method Summary collapse

Methods inherited from Origin

#conceal, #concealed?, #discard, #emit, #expose, #exposed?, #initialize, #insert, #keep, #method_missing, #output, #path, #prepare, #rename, #reverse, #sort, #transform, #truncate

Constructor Details

This class inherits a constructor from Smoke::Origin

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Smoke::Origin

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



21
22
23
# File 'lib/smoke/source/data.rb', line 21

def request
  @request
end

Instance Method Details

#url(source_url, options = {}) ⇒ Object

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


27
28
29
# File 'lib/smoke/source/data.rb', line 27

def url(source_url, options = {})
  @url, @options = source_url, options
end