Class: Ubiquitously::Diigo::Post
- Inherits:
-
Service::Post
- Object
- Base
- Service::Post
- Ubiquitously::Diigo::Post
- Defined in:
- lib/ubiquitously/services/diigo.rb
Instance Attribute Summary
Attributes inherited from Service::Post
#captcha, #categories, #description, #downvotes, #extension, #format, #image, #kind, #must_be_unique, #privacy, #rating, #remote, #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
- #create ⇒ Object
-
#tokenize ⇒ Object
tags are space separated.
Methods inherited from Service::Post
Methods included from Loggable::Post
Methods included from Restful::Post
Methods included from Postable::Post
Methods included from Ownable::Post
Methods inherited from Base
Methods included from SubclassableCallbacks
Constructor Details
This class inherits a constructor from Ubiquitously::Service::Post
Class Method Details
.find(options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ubiquitously/services/diigo.rb', line 41 def find( = {}) records = [] user = [:user] user_url = "http://secure.diigo.com/rss/user/#{user.username_for(self)}" xml = Nokogiri::XML(open(user_url).read) urls = url_permutations([:url]) xml.css("item").each do |node| title = node.css("title").first.text url = node.css("link").first.text description = node.css("description").first.text record = new( :title => title, :url => url, :description => description, :user => user ) return record if urls.include?(record.url) records << record end [:url] ? nil : records end |
Instance Method Details
#create ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ubiquitously/services/diigo.rb', line 26 def create page = agent.get("https://secure.diigo.com/item/new/bookmark") form = page.forms.detect { |form| form.form_node["id"] == "newBookmarkForm" } form["url"] = token[:url] form["title"] = token[:title] form["description"] = token[:description] # tags are space separated. Use " " for tag with multiple words. form["tags"] = token[:tags] unless debug? page = form.submit end end |
#tokenize ⇒ Object
tags are space separated. Use “ ” for tag with multiple words.
22 23 24 |
# File 'lib/ubiquitously/services/diigo.rb', line 22 def tokenize super.merge(:tags => .taggify(" ", " ")) end |