Class: GithubAPIAdapter

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

Constant Summary collapse

@@ISSUE_STATES =
%w{open closed}

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ GithubAPIAdapter

Returns a new instance of GithubAPIAdapter.



82
83
84
# File 'lib/backup-github.rb', line 82

def initialize(client)
  @client = client
end

Instance Method Details

#has_issues?(reponame) ⇒ Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/backup-github.rb', line 86

def has_issues?(reponame)
  @client.repository(reponame).has_issues
end

#on_issues(reponame, &block) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/backup-github.rb', line 90

def on_issues(reponame, &block)
  @@ISSUE_STATES.each do |status|
    page = 0

    begin
        issues = @client.list_issues( reponame, :page => page, :state => status )
        issues.each do |issue|
          yield Issue.new(issue.number, @client.issue(reponame, issue.number))
        end
        page += 1
    end until issues.length != 10
  end
end

#repositories(orgname) ⇒ Object



104
105
106
# File 'lib/backup-github.rb', line 104

def repositories(orgname)
  @client.repositories(orgname)
end