Class: Rubilicious
- Inherits:
-
Object
- Object
- Rubilicious
- Defined in:
- lib/graphiclious/delicious2yaml.rb,
lib/graphiclious/delicious2yaml.rb,
lib/graphiclious/delicious2yaml.rb
Overview
#all() and #recent() shoult return the same format therefore I changed ‘tag’ into ‘tags’
Instance Method Summary collapse
- #all(tag = nil) ⇒ Object
-
#http_get(url) ⇒ Object
del.icio.us-API change 08/2006!.
-
#https_get(url) ⇒ Object
Low-level HTTPS GET.
Instance Method Details
#all(tag = nil) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/graphiclious/delicious2yaml.rb', line 9 def all(tag = nil) args = [(tag ? "tag=#{tag.uri_escape}" : nil)] get('posts/all?' << args.compact.join('&'), 'post').map do |e| e['time'] = Time::from_iso8601(e['time']) e['tags'] = e['tag'].split(/\s/) # wrong in 1.5 e # missing in 1.5 end end |
#http_get(url) ⇒ Object
del.icio.us-API change 08/2006!
73 74 75 |
# File 'lib/graphiclious/delicious2yaml.rb', line 73 def http_get(url) https_get(url) end |
#https_get(url) ⇒ Object
Low-level HTTPS GET. SDo used the tip at ruby.about.com/od/tutorials/ss/delicious_tags_4.htm to get Rubilicious code working
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/graphiclious/delicious2yaml.rb', line 42 def https_get(url) # get proxy info proxy_host, proxy_port = find_http_proxy # $stderr.puts "DEBUG: proxy: host = #{proxy_host}, port = #{proxy_port}" # get host, port, and base URI for API queries uri = URI::parse(@base_uri) base = uri.request_uri # prepend base to url url = "#{base}/#{url}" # connect to delicious http = Net::HTTP.Proxy(proxy_host, proxy_port).new(uri.host, uri.port) http.use_ssl = true http.start # get URL, check for error resp = http.get(url, @headers) unless resp.code =~ /2\d{2}/ puts base puts url raise "HTTP #{resp.code}: #{resp.}" end # close HTTP connection, return response http.finish resp.body end |