Sha256: af6dfa62fdc6314ba448cb84e3da41fa158a77ee7a99e635243e1d2eb28f13d0

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 Bytes

Contents

# encoding: utf-8

require 'nokogiri'
module Stars
  class Favstar
    include HTTParty
    base_uri 'favstar.fm'
    proxy_url = URI.parse(ENV['http_proxy']) if ENV['http_proxy']
    http_proxy proxy_url.host,proxy_url.port if proxy_url

    def recent(username)
      self.class.get("/users/#{username}/rss",
                      :format => :xml)['rss']['channel']['item']
    end
    
    def show(url)
      # hardcode 17 to strip favstar domain for now
      html = self.class.get(url[17..200], :format => :html)
      Nokogiri::HTML(html).css('.avatarList img').collect do |img|
        "    ★  #{img.attributes['alt'].value}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stars-0.3.1 lib/stars/favstar.rb