Class: Hubtime::Repo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_name, username, start_time, end_time) ⇒ Repo

Returns a new instance of Repo.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hubtime/repo.rb', line 9

def initialize(repo_name, username, start_time, end_time)
  @repo_name = repo_name
  @username = username
  @cacher = Cacher.new("#{repo_name}")
  @mutex = Mutex.new
  @thread_count = HubConfig.threads
  
  if end_time < start_time
    @start_time = end_time
    @end_time = start_time
  else
    @start_time = start_time
    @end_time = end_time
  end
end

Instance Attribute Details

#cacherObject (readonly)

Returns the value of attribute cacher.



7
8
9
# File 'lib/hubtime/repo.rb', line 7

def cacher
  @cacher
end

#end_timeObject (readonly)

Returns the value of attribute end_time.



8
9
10
# File 'lib/hubtime/repo.rb', line 8

def end_time
  @end_time
end

#mutexObject (readonly)

Returns the value of attribute mutex.



7
8
9
# File 'lib/hubtime/repo.rb', line 7

def mutex
  @mutex
end

#repo_nameObject (readonly)

Returns the value of attribute repo_name.



8
9
10
# File 'lib/hubtime/repo.rb', line 8

def repo_name
  @repo_name
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



8
9
10
# File 'lib/hubtime/repo.rb', line 8

def start_time
  @start_time
end

#thread_countObject (readonly)

Returns the value of attribute thread_count.



7
8
9
# File 'lib/hubtime/repo.rb', line 7

def thread_count
  @thread_count
end

#usernameObject (readonly)

Returns the value of attribute username.



8
9
10
# File 'lib/hubtime/repo.rb', line 8

def username
  @username
end

Instance Method Details

#auto_clientObject



25
26
27
# File 'lib/hubtime/repo.rb', line 25

def auto_client
  @auto_client ||= Octokit::Client.new(:login => HubConfig.user, :password => HubConfig.password, :auto_traversal => true)
end

#commits(&block) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/hubtime/repo.rb', line 33

def commits(&block)
  queue = self.sha_list.dup

  if self.thread_count == 1
    work_sha_queue(queue, block)
  else
    self.thread_count.times.map {
      Thread.new do
        work_sha_queue(queue, block)
      end
    }.each(&:join)
  end

end

#single_clientObject



29
30
31
# File 'lib/hubtime/repo.rb', line 29

def single_client
  @single_client ||= Octokit::Client.new(:login => HubConfig.user, :password => HubConfig.password)
end