Module: Processors::Tumblr
- Includes:
- LogAware
- Defined in:
- lib/processors/tumblr.rb
Overview
utilities for handling tumblr
Constant Summary collapse
- GENERATOR =
%{tweetlr - http://tweetlr.5v3n.com}
- API_ENDPOINT_TUMBLR =
'http://www.tumblr.com'
Class Method Summary collapse
- .log ⇒ Object
-
.post(options = {}) ⇒ Object
post a tumblr photo entry.
Methods included from LogAware
Class Method Details
.log ⇒ Object
9 10 11 |
# File 'lib/processors/tumblr.rb', line 9 def self.log LogAware.log #TODO why doesn't the include make the log method accessible? end |
.post(options = {}) ⇒ Object
post a tumblr photo entry.
required arguments are :email, :password, :type, :date, :source, :caption, :state, :source
optional arguments: :api_endpoint_tumblr, :tags, :group
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/processors/tumblr.rb', line 18 def self.post(={}) tries = 3 = [:tags] || '' group = [:group] || '' begin response = Curl::Easy.http_post("#{[:api_endpoint_tumblr] || API_ENDPOINT_TUMBLR}/api/write", Curl::PostField.content('generator', GENERATOR), Curl::PostField.content('email', [:email]), Curl::PostField.content('password', [:password]), Curl::PostField.content('type', [:type]), Curl::PostField.content('date', [:date]), Curl::PostField.content('source', [:source]), Curl::PostField.content('caption', [:caption]), Curl::PostField.content('state', [:state]), Curl::PostField.content('tags', ), Curl::PostField.content('group', group) ) rescue Curl::Err::CurlError => err log.error "Failure in Curl call: #{err}" tries -= 1 sleep 3 if tries > 0 retry else response = nil end end response end |