Class: Furik::Events

Inherits:
Object
  • Object
show all
Defined in:
lib/furik/events.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Events

Returns a new instance of Events.



3
4
5
6
# File 'lib/furik/events.rb', line 3

def initialize(client)
  @client = client
  @login = client.
end

Instance Method Details

#aggressivesObject



21
22
23
24
25
26
27
28
29
# File 'lib/furik/events.rb', line 21

def aggressives
  %w(
    IssuesEvent
    PullRequestEvent
    PullRequestReviewCommentEvent
    IssueCommentEvent
    CommitCommentEvent
  )
end

#events_with_grouping(from, to, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/furik/events.rb', line 8

def events_with_grouping(from, to, &block)
  @client.user_events(@login).each.with_object({}) { |event, memo|
    if event && aggressives.include?(event.type)
      if from <= event.created_at.localtime.to_date && event.created_at.localtime.to_date <= to
        memo[event.repo.name] ||= []
        memo[event.repo.name] << event
      end
    end
  }.each do |repo, events|
    block.call(repo, events) if block
  end
end