Class: Reporter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(work_dir, translations) ⇒ Reporter

Returns a new instance of Reporter.



9
10
11
12
13
14
15
16
17
18
# File 'lib/reporter.rb', line 9

def initialize(work_dir, translations)
  @work_dir = work_dir
  @repositories = Hash.new
  @repository_stats = Hash.new
  @commiter_stats = Hash.new
  @repository_summaries = Hash.new
  @translations = translations
  discover_repositories
  initialize_repositories
end

Instance Attribute Details

#commiter_statsObject

Returns the value of attribute commiter_stats.



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

def commiter_stats
  @commiter_stats
end

#repositoriesObject (readonly)

Returns the value of attribute repositories.



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

def repositories
  @repositories
end

#repository_statsObject

Returns the value of attribute repository_stats.



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

def repository_stats
  @repository_stats
end

#repository_summariesObject

Returns the value of attribute repository_summaries.



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

def repository_summaries
  @repository_summaries
end

#work_dirObject

Returns the value of attribute work_dir.



5
6
7
# File 'lib/reporter.rb', line 5

def work_dir
  @work_dir
end

Instance Method Details

#extract_all_stats(from = Date.new, to = Date.new) ⇒ Object



33
34
35
36
37
38
# File 'lib/reporter.rb', line 33

def extract_all_stats(from = Date.new, to = Date.new)
  for repository in @repositories.values
    yield repository.name if block_given?
    extract_stats(repository.name, from, to)
  end
end

#extract_stats(repository_name, from = Date.new, to = Date.new) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/reporter.rb', line 20

def extract_stats(repository_name, from = Date.new, to = Date.new)
  @repository_stats[repository_name] = Hash.new
  repository = @repositories[repository_name]
  repository.pull
  repository.calculate_stats(from, to)
  repository.generate_summary(from, to)
  @repository_summaries[repository_name] = repository.summary
  for commiter in repository.commiters.keys
    @repository_stats[repository_name][commiter] = repository.commiters[commiter]
  end
  extract_stats_for_commiters(repository_name)
end