Class: Babygitter::ReportGenerator

Inherits:
RepoAnalyzer show all
Includes:
GraphOutput, HtmlOutput
Defined in:
lib/babygitter/report_generator.rb,
lib/babygitter/report_generator/options.rb,
lib/babygitter/report_generator/application.rb

Overview

Subclass of RepoAnalyzer, used for generating reports.

Defined Under Namespace

Classes: Application, Options

Constant Summary

Constants included from GraphOutput

GraphOutput::SMALL_SIZE, GraphOutput::THEME

Instance Attribute Summary collapse

Attributes inherited from RepoAnalyzer

#master_branch, #project_name

Instance Method Summary collapse

Methods included from GraphOutput

#create_bar_graph_of_commits_in_the_last_52_weeks, #create_folder_graph, #create_histograph_of_commits_by_author_for_branch, #create_large_folder_graph, #create_large_histograph_of_commits_by_author_for_branch, #create_large_stacked_bar_graph_of_commits_by_author_for_branch, #create_small_folder_graph, #create_small_histograph_of_commits_by_author_for_branch, #create_small_stacked_bar_graph_of_commits_by_author_for_branch, #create_stacked_bar_graph_of_commits_by_author_for_branch

Methods inherited from RepoAnalyzer

#analyze_branches, #create_branches, #find_branch, #find_unique_commits_per_branch, #first_committed_commit, #get_all_commits_in_repo, #get_authors, #get_branch_names, #get_master_branch, #get_project_name, #get_remote_url, #get_total_uniq_commits_in_repo, #go_down_branch_from_head, #in_which_branches, #inspect, #last_commited_commit, #set_master_branch, #submodule_codes

Constructor Details

#initialize(path = ".", options = {}, master = nil) ⇒ ReportGenerator

Returns a new instance of ReportGenerator.



11
12
13
14
# File 'lib/babygitter/report_generator.rb', line 11

def initialize(path=".", options = {}, master=nil)
  super
  raise "Could not find stylesheet #{Babygitter.stylesheet}" unless File.exist?(Babygitter.stylesheet)
end

Instance Attribute Details

#authors_namesObject

Returns the value of attribute authors_names.



9
10
11
# File 'lib/babygitter/report_generator.rb', line 9

def authors_names
  @authors_names
end

#beganObject

Returns the value of attribute began.



9
10
11
# File 'lib/babygitter/report_generator.rb', line 9

def began
  @began
end

#branch_namesObject

Returns the value of attribute branch_names.



9
10
11
# File 'lib/babygitter/report_generator.rb', line 9

def branch_names
  @branch_names
end

#branchesObject

Returns the value of attribute branches.



9
10
11
# File 'lib/babygitter/report_generator.rb', line 9

def branches
  @branches
end

#lastest_commitObject

Returns the value of attribute lastest_commit.



9
10
11
# File 'lib/babygitter/report_generator.rb', line 9

def lastest_commit
  @lastest_commit
end

#remote_urlObject

Returns the value of attribute remote_url.



9
10
11
# File 'lib/babygitter/report_generator.rb', line 9

def remote_url
  @remote_url
end

#submodule_listObject

Returns the value of attribute submodule_list.



9
10
11
# File 'lib/babygitter/report_generator.rb', line 9

def submodule_list
  @submodule_list
end

#total_commitsObject

Returns the value of attribute total_commits.



9
10
11
# File 'lib/babygitter/report_generator.rb', line 9

def total_commits
  @total_commits
end

Instance Method Details

#templated_reportObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/babygitter/report_generator.rb', line 24

def templated_report
  require 'erb'
 
  stylesheet, additional_links, instructions, jquery = '', '', '', ''
  File.open(Babygitter.stylesheet, 'r') { |f| stylesheet = f.read }
  File.open(Babygitter.additional_links, 'r') { |f| additional_links = f.read }
  File.open(Babygitter.jquery, 'r') { |f| jquery = f.read }
  template = File.read(Babygitter.template)
  result = ERB.new(template).result(binding)

end

#write_reportObject

Writes report to the directory specified by Babygitter.report_file_path



17
18
19
20
21
22
# File 'lib/babygitter/report_generator.rb', line 17

def write_report
  r = File.open("#{Babygitter.report_file_path}/babygitter_report.html", 'w+')
  r.write templated_report
  r.close
  "Report written to #{Babygitter.report_file_path}/babygitter_report.html"
end