Class: Nanoc3::DataSources::Twitter Deprecated
- Inherits:
-
Nanoc3::DataSource
- Object
- Nanoc3::DataSource
- Nanoc3::DataSources::Twitter
- Defined in:
- lib/nanoc3/data_sources/deprecated/twitter.rb
Overview
Deprecated.
Fetch data from online data sources manually instead
Instance Attribute Summary
Attributes inherited from Nanoc3::DataSource
#config, #items_root, #layouts_root
Instance Method Summary collapse
Methods inherited from Nanoc3::DataSource
#create_item, #create_layout, #down, #initialize, #layouts, #loading, #setup, #unuse, #up, #update, #use
Methods included from PluginRegistry::PluginMethods
#identifier, #identifiers, #named, #register
Constructor Details
This class inherits a constructor from Nanoc3::DataSource
Instance Method Details
#items ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nanoc3/data_sources/deprecated/twitter.rb', line 8 def items @item ||= begin require 'json' # Get data @http_client ||= Nanoc3::Extra::CHiCk::Client.new status, headers, data = *@http_client.get("http://twitter.com/statuses/user_timeline/#{self.config[:username]}.json") # Parse as JSON raw_items = JSON.parse(data) # Convert to items raw_items.enum_with_index.map do |raw_item, i| # Get data content = raw_item['text'] attributes = { :created_at => raw_item['created_at'], :source => raw_item['source'] } identifier = "/#{raw_item['id']}/" mtime = Time.parse(raw_item['created_at']) # Build item Nanoc3::Item.new(content, attributes, identifier, mtime) end end end |