Class: Hubtime::GithubService

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGithubService

Returns a new instance of GithubService.



11
12
13
14
# File 'lib/hubtime/github.rb', line 11

def initialize
  @client = Octokit::Client.new(:login => HubConfig.user, :password => HubConfig.password, :auto_traversal => true)
  # puts @client.ratelimit_remaining
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/hubtime/github.rb', line 10

def client
  @client
end

Class Method Details

.ownerObject



6
7
8
# File 'lib/hubtime/github.rb', line 6

def self.owner
  @owner ||= self.new
end

Instance Method Details

#commits(username, start_time, end_time, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/hubtime/github.rb', line 16

def commits(username, start_time, end_time, &block)
  self.repositories(username).each do |repo_name|
    puts "#{repo_name}"
    repo = Repo.new(repo_name, username, start_time, end_time)
    repo.commits do |commit|
      block.call commit
    end
  end
end

#repositories(username) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/hubtime/github.rb', line 26

def repositories(username)
  repos = []

  client.repositories.each do |hash|
    repos << hash.full_name
  end

  unless username == client.
    client.repositories(username).each do |hash|
      repos << hash.full_name
    end
  end

  self.organizations(username).each do |org_name|
    client.organization_repositories(org_name).each do |hash|
      repos << hash.full_name
    end
  end

  # return these, ignoring requested ones
  repos.compact.uniq - HubConfig.ignore
end