class OpenSourceStats::User
Attributes
login[RW]
Public Class Methods
new(login)
click to toggle source
# File lib/open_source_stats/user.rb, line 6 def initialize(login) @login = login end
Public Instance Methods
events()
click to toggle source
Returns an array of in-scope Events from the user’s public activity feed
# File lib/open_source_stats/user.rb, line 11 def events @events ||= begin if self.class == OpenSourceStats::User events = client.user_public_events login, :per_page => 100 else events = client.organization_public_events name, :per_page => 100 end events.concat client.get client.last_response.rels[:next].href while next_page? events = events.map { |e| Event.new(e) } events.select { |e| e.in_scope? } end end
Private Instance Methods
client()
click to toggle source
Helper method to access the shared Octokit instance
# File lib/open_source_stats/user.rb, line 28 def client OpenSourceStats.client end
next_page?()
click to toggle source
Helper method to improve readability. Asks is there another page to the results? Looks at both pagination and if we’ve gone past our allowed timeframe
# File lib/open_source_stats/user.rb, line 35 def next_page? client.last_response.rels[:next] && client.rate_limit.remaining > 0 && client.last_response.data.last[:created_at] >= OpenSourceStats.start_time end