Class: Hubkit::EventPaginator

Inherits:
Paginator show all
Includes:
Enumerable
Defined in:
lib/hubkit/event_paginator.rb

Overview

Returns all events for a GitHub issues– for example, labeling, unlabeling, closing, etc– and handle pagination for you

Instance Method Summary collapse

Methods inherited from Paginator

#each

Constructor Details

#initialize(org:, repo:, issue_number: nil) ⇒ EventPaginator

Initialize a new paginator for events from the API

Parameters:

  • org (String)

    the github organization which contains the repo for which we'll gather events

  • repo (String)

    the github repo name for which we'll gather events

  • issue_number (optional Fixnum)

    if present, the number of the issue for which we'll sfind events


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hubkit/event_paginator.rb', line 13

def initialize(org:, repo:, issue_number: nil)
  @org = org
  @repo = repo
  @issue_number = issue_number

  opts =
    if issue_number.present?
      { issue_number: issue_number }
    else
      {}
    end

  super() do |i|
    Cooldowner.with_cooldown do
      Hubkit.client.issues.events.list(
        @org,
        @repo,
        opts.merge(page: i),
      )
    end
  end
end