lib/github_metadata.rb in github_metadata-0.2.0 vs lib/github_metadata.rb in github_metadata-0.2.1
- old
+ new
@@ -137,13 +137,13 @@
end
# Returns the average date of recent commits (by default all (max 20), can be modified
# by giving the optional argument)
def average_recent_committed_at(num=100)
- commit_times = recent_commits[0..num].map {|c| c.committed_at.to_f }
+ commit_times = recent_commits[0...num].map {|c| c.committed_at.to_f }
average_time = commit_times.inject(0) {|s, i| s + i} / commit_times.length
- Time.at(average_time)
+ Time.at(average_time).utc
end
private
def document
@@ -151,10 +151,16 @@
rescue OpenURI::HTTPError => err
raise GithubMetadata::RepoNotFound, err.to_s
end
def commits_feed
- @commits_feed ||= Feedzirra::Feed.fetch_and_parse(commits_feed_url)
+ return @commits_feed if @commits_feed
+ response = Feedzirra::Feed.fetch_and_parse(commits_feed_url)
+ if response.kind_of?(Fixnum)
+ return nil
+ else
+ @commits_feed = response
+ end
end
def load_contributors
@contributors = document.css('#repos #watchers.members li').map do |contributor|
line = contributor.text.gsub("\n", '').squeeze(' ').strip.chomp