Class: Deliruby::PublicInfo
- Inherits:
-
Object
- Object
- Deliruby::PublicInfo
- Includes:
- HTTParty, HTTParty::Icebox
- Defined in:
- lib/deliruby.rb
Overview
access the public information that’s not necesarily bookmarks because the information varies, it returns hashes or arrays of hashes instead of a class instance
Class Method Summary collapse
-
.alerts ⇒ Object
- Get a the site alerts Params
url
-
the url to retrieve.
- Get a the site alerts Params
-
.network(user) ⇒ Object
(also: network_for, network_for_user)
- Get a list of the network members for a user Params:
user
-
the user to peruse.
- Get a list of the network members for a user Params:
-
.network_fans(user) ⇒ Object
(also: network_fans_for, network_fans_for_user)
- Get a list of the network fans for a user Params:
user
-
the user to peruse.
- Get a list of the network fans for a user Params:
-
.tags(user, tags = []) ⇒ Object
(also: tags_for_user, tags_for)
- Get the top public tags of a user and how many items are bookmarked with them and also get the related tags if a filtering array of tags is provided Params:
user
-
the user to peruse.
- Get the top public tags of a user and how many items are bookmarked with them and also get the related tags if a filtering array of tags is provided Params:
-
.url(url) ⇒ Object
(also: for_url, urlinfo, url_info)
Return summary information for a given url.
-
.user_info(user) ⇒ Object
(also: for_user, userinfo)
- Get public info for a user: the number of bookmarks, network members and network fans Params
user
-
the user.
- Get public info for a user: the number of bookmarks, network members and network fans Params
Methods included from HTTParty::Icebox
Class Method Details
.alerts ⇒ Object
Get a the site alerts Params
url
-
the url to retrieve
130 131 132 133 134 135 136 137 138 139 |
# File 'lib/deliruby.rb', line 130 def self.alerts res = get("/alerts") raise "Communication error with delicious server: #{res.response['status']}" if res.response['status'] =~ /^[45]/ return [] unless res['rss']['channel'].has_key?('item') alerts = [] res['rss']['channel']['item'].each do |item| alerts.push item rescue next end return alerts end |
.network(user) ⇒ Object Also known as: network_for, network_for_user
Get a list of the network members for a user Params:
user
-
the user to peruse
174 175 176 177 178 179 180 181 182 183 |
# File 'lib/deliruby.rb', line 174 def self.network(user) res = get("/networkmembers/#{user}") raise "Communication error with delicious server: #{res.response['status']}" if res.response['status'] =~ /^[45]/ return [] unless res['rss']['channel'].has_key?('item') members = [] res['rss']['channel']['item'].each do |item| members.push({:user => item['title'], :profile=>item['link']}) rescue next end return members end |
.network_fans(user) ⇒ Object Also known as: network_fans_for, network_fans_for_user
Get a list of the network fans for a user Params:
user
-
the user to peruse
188 189 190 191 192 193 194 195 196 197 |
# File 'lib/deliruby.rb', line 188 def self.network_fans(user) res = get("/networkfans/#{user}") raise "Communication error with delicious server: #{res.response['status']}" if res.response['status'] =~ /^[45]/ return [] unless res['rss']['channel'].has_key?('item') members = [] res['rss']['channel']['item'].each do |item| members.push({:user => item['title'], :profile=>item['link']}) rescue next end return members end |
.tags(user, tags = []) ⇒ Object Also known as: ,
Get the top public tags of a user and how many items are bookmarked with them and also get the related tags if a filtering array of tags is provided Params:
user
-
the user to peruse
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/deliruby.rb', line 160 def self.(user, =[]) res = get("/tags/#{user}/#{.join('+')}") raise "Communication error with delicious server: #{res.response['status']}" if res.response['status'] =~ /^[45]/ return [] unless res['rss']['channel'].has_key?('item') info = [] res['rss']['channel']['item'].each do |item| info.push({item['title']=>item['description']}) rescue next end return info end |
.url(url) ⇒ Object Also known as: for_url, urlinfo, url_info
Return summary information for a given url
200 201 202 203 204 |
# File 'lib/deliruby.rb', line 200 def self.url(url) #for some reason, the cache screws this one up get_without_caching("/urlinfo/#{Digest::MD5.hexdigest(url)}",:format => :json, :base_uri => self.[:base_uri].gsub('xml', 'json')).parsed_response[0] end |
.user_info(user) ⇒ Object Also known as: for_user, userinfo
Get public info for a user: the number of bookmarks, network members and network fans Params
user
-
the user
144 145 146 147 148 149 150 151 152 153 |
# File 'lib/deliruby.rb', line 144 def self.user_info(user) res = get("/userinfo/#{user}") raise "Communication error with delicious server: #{res.response['status']}" if res.response['status'] =~ /^[45]/ return [] unless res['rss']['channel'].has_key?('item') info = {} res['rss']['channel']['item'].each do |item| info[item['title']] = item['description'] rescue next end return info end |