Class: Ubiquitously::Delicious::Post

Inherits:
Service::Post show all
Includes:
HTTParty
Defined in:
lib/ubiquitously/services/delicious.rb

Instance Attribute Summary

Attributes inherited from Service::Post

#captcha, #categories, #description, #downvotes, #extension, #format, #image, #kind, #must_be_unique, #privacy, #rating, #service_id, #service_url, #slug, #source, #source_url, #state, #status, #tags, #title, #token, #upvotes, #url, #user, #vote

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Service::Post

#access_token, #initialize

Methods included from Loggable::Post

included

Methods included from Restful::Post

included

Methods included from Postable::Post

included

Methods included from Ownable::Post

included

Methods inherited from Base

#apply, #debug?

Methods included from SubclassableCallbacks

included, override

Constructor Details

This class inherits a constructor from Ubiquitously::Service::Post

Class Method Details

.find(options = {}) ⇒ Object



46
47
48
49
50
# File 'lib/ubiquitously/services/delicious.rb', line 46

def find(options = {})
  options[:result] = options.delete(:count) unless options[:count].nil?
  raise "enter ':basic_auth => {:username => x, :password => y}'" unless options[:basic_auth]
  self.get('/posts/get', options)
end

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ubiquitously/services/delicious.rb', line 18

def create
  puts "CREATE #{@auth.inspect}"
  res = self.class.get(
    "/posts/add",
    :query => {
      :url => url,
      :description => title,
      :extended => description,
      :tags => tags.map { |tag| tag.downcase.gsub(/[^a-z0-9]/, "-").squeeze("-") }.join(" ")
    },
    :basic_auth => @auth
  )
  puts "RESPONSE: #{res.inspect}"
  true
end

#remote(options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/ubiquitously/services/delicious.rb', line 34

def remote(options = {})
  return nil
  raise "what url to do want" if self.url.nil?
  @remote ||= self.class.find(options.merge(
    :query => {
      :url => CGI.escape(self.url)
    },
    :basic_auth => @auth
  ))
end

#tokenizeObject



14
15
16
# File 'lib/ubiquitously/services/delicious.rb', line 14

def tokenize
  super.merge(:tags => tags.taggify("-", " "))
end