Class: StreamGrabber::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/stream_grabber/github.rb

Instance Method Summary collapse

Constructor Details

#initialize(user_name, api_key) ⇒ Github

Returns a new instance of Github.



7
8
9
# File 'lib/stream_grabber/github.rb', line 7

def initialize(user_name, api_key)
  @doc = SimpleRSS.parse(open("https://github.com/#{user_name}.private.actor.atom?token=#{api_key}"))
end

Instance Method Details

#last_fiveObject



11
12
13
14
15
16
17
18
# File 'lib/stream_grabber/github.rb', line 11

def last_five
  commits = {}
  @doc.items.first(5).each do |item|
    date = Time.parse(item[:updated].to_s).to_i
    commits[date] = [:github, message_from(item[:link], item[:title])]
  end
  commits
end

#message_from(link, title) ⇒ Object



20
21
22
# File 'lib/stream_grabber/github.rb', line 20

def message_from(link, title)
  %Q{<a href="#{link}">#{title}</a>}
end