Sha256: da1aeac2c6f15f5404522af842955a165741664c412e8477ccbe9af5371127ef
Contents?: true
Size: 971 Bytes
Versions: 1
Compression:
Stored size: 971 Bytes
Contents
require 'rss' require 'openssl' require 'httpclient' module Gns class GithubAtom def initialize(url, start_time = Time.now) @url = url @last_updated = start_time @client = HTTPClient.new end def recent_items get_atom_items.find_all {|item| item.updated > @last_updated }.tap {|items| @last_updated = items.first.updated if items.first } end def get_atom_items RSS::Parser.parse(get_atom).items.map {|item| GithubItem.new(item) } end def get_atom @client.get_content(@url) end end class GithubItem attr_reader :updated, :title, :url, :body, :repo def initialize(atom_item) @updated = atom_item.updated.content @title = atom_item.title.content @url = atom_item.link.href atom_item.content.content =~ /<p>(.*)<\/p>/ @body = $1 atom_item.content.content =~ /<a.*>(.*)<\/a>/ @repo = $1 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gns-0.0.2 | lib/gns/github_atom.rb |