Module: Babygitter::GraphOutput

Included in:
ReportGenerator
Defined in:
lib/babygitter/output_helpers/graph_output.rb

Constant Summary collapse

THEME =

Declare a custom theme

{   # Declare a custom theme
  :colors => %w(orange silver yellow pink purple green white red #cccccc), # colors can be described on hex values (#0f0f0f)
  :font_color => 'white',
  :marker_color => 'white', # The horizontal lines color
  :background_colors => %w(black grey) # you can use instead: :background_image => ‘some_image.png’
}
SMALL_SIZE =

you can use instead: :background_image => ‘some_image.png’

"183x184"

Instance Method Summary collapse

Instance Method Details

#create_bar_graph_of_commits_in_the_last_52_weeks(author) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/babygitter/output_helpers/graph_output.rb', line 131

def create_bar_graph_of_commits_in_the_last_52_weeks(author)
  g = Gruff::Bar.new('800x300') # Define a custom size

  g.sort = false  # Do NOT sort data based on values
  #g.y_axis_increment = 1  # Points shown on the Y axis

  g.legend_font_size = 12 # Legend font size
  g.title_font_size = 22 # Title font size

  g.top_margin = 10 # Empty space on the upper part of the chart
  g.bottom_margin = 20  # Empty space on the lower part of the chart

  g.theme = THEME

  g.title = "Commits in the last 52 weeks by #{author.name}"

  g.data("#{author.name}", author.create_bar_data_points)
  g.no_data_message = "No Commits"
  image_path ="babygitter_images/#{author.name.gsub(/ |\/|\\/, "_")}_commits_last_52_weeks.png"
  filepath ="#{Babygitter.report_file_path}/#{image_path}"
  g.write(filepath)
  "<img src ='./#{image_path}' />"
end

#create_folder_graph(branch, level) ⇒ Object



94
95
96
97
98
# File 'lib/babygitter/output_helpers/graph_output.rb', line 94

def create_folder_graph(branch, level)
  small_file_path = create_small_folder_graph(branch, level)
  large_file_path = create_large_folder_graph(branch, level)
  "<a href='#{large_file_path}' rel='#{branch.name.gsub(/\//, "_")}_gallery' class='image_gallery'><img src=#{small_file_path} alt=''/></a>"
end

#create_histograph_of_commits_by_author_for_branch(branch) ⇒ Object



13
14
15
16
17
18
# File 'lib/babygitter/output_helpers/graph_output.rb', line 13

def create_histograph_of_commits_by_author_for_branch(branch)
  large_file_path = create_large_histograph_of_commits_by_author_for_branch(branch)
  small_file_path = create_small_histograph_of_commits_by_author_for_branch(branch)
  "<a href='#{large_file_path}' rel='#{branch.name.gsub(/\//, "_")}_gallery' class='image_gallery'><img src=#{small_file_path} alt=''/></a>"

end

#create_large_folder_graph(branch, level) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/babygitter/output_helpers/graph_output.rb', line 100

def create_large_folder_graph(branch, level)
  g = Gruff::Line.new('800x600') # Define a custom size
  g.title = "Plot of commits #{pluralize(level, 'level')} deep"
  g.legend_font_size = 12 # Legend font size


  branch.plot_folder_points(level).each do |key,value|
    key = "program_folder" if key == ""
    g.data(key, value)
  end
  image_path = "babygitter_images/large_#{branch.name.gsub(/\//, "_")}_level_#{level}_line_graph.png"
  file_path = "#{Babygitter.report_file_path}/#{image_path}"
  g.write(file_path)
  "./#{image_path}"
end

#create_large_histograph_of_commits_by_author_for_branch(branch) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/babygitter/output_helpers/graph_output.rb', line 20

def create_large_histograph_of_commits_by_author_for_branch(branch)
  g = Gruff::Bar.new('800x400') # Define a custom size
  g.sort = false  # Do NOT sort data based on values
  #g.y_axis_increment = 1  # Points shown on the Y axis
  g.legend_font_size = 12 # Legend font size
  g.title_font_size = 22 # Title font size
  g.theme = THEME
  g.title = 'Commits by Author'
  for author in branch.authors
    g.data("#{author.name}", [author.total_committed])
  end
  image_path = "babygitter_images/large_#{branch.name.gsub(/\//, "_")}_commits_by_author.png"
  file_path = "#{Babygitter.report_file_path}/#{image_path}"
  g.write(file_path)
  "./#{image_path}"
end

#create_large_stacked_bar_graph_of_commits_by_author_for_branch(branch) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/babygitter/output_helpers/graph_output.rb', line 60

def create_large_stacked_bar_graph_of_commits_by_author_for_branch(branch)
  g = Gruff::StackedBar.new('800x600') # Define a custom size
  g.sort = true  # Do NOT sort data based on values
  g.y_axis_increment = 10  # Points shown on the Y axis
  g.legend_font_size = 12 # Legend font size
  g.title_font_size = 22 # Title font size
  g.theme = THEME
  g.title = 'Commits for the Last 52 weeks'
  for author in branch.authors
    g.data("#{author.name}", author.create_bar_data_points)
  end
  image_path = "babygitter_images/large_#{branch.name.gsub(/\//, "_")}_stacked_bar_graph_by_author.png"
  file_path = "#{Babygitter.report_file_path}/#{image_path}"
  g.write(file_path)
  "./#{image_path}"
end

#create_small_folder_graph(branch, level) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/babygitter/output_helpers/graph_output.rb', line 116

def create_small_folder_graph(branch, level)
  g = Gruff::Line.new(SMALL_SIZE) # Define a custom size
  g.title = "Plot of commits #{pluralize(level, 'level')} deep"
  g.legend_font_size = 32 # Legend font size
  g.hide_legend = true
  branch.plot_folder_points(level).each do |key,value|
    key = "program_folder" if key == ""
    g.data(key, value)
  end
  image_path = "babygitter_images/small_#{branch.name.gsub(/\//, "_")}_level_#{level}_line_graph.png"
  file_path = "#{Babygitter.report_file_path}/#{image_path}"
  g.write(file_path)
  "./#{image_path}"
end

#create_small_histograph_of_commits_by_author_for_branch(branch) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/babygitter/output_helpers/graph_output.rb', line 37

def create_small_histograph_of_commits_by_author_for_branch(branch)
  g = Gruff::Bar.new(SMALL_SIZE) # Define a custom size
  g.sort = false  # Do NOT sort data based on values
  #g.y_axis_increment = 1  # Points shown on the Y axis
  g.hide_legend = true
  g.title_font_size = 32 # Title font size
  g.theme = THEME
  g.title = 'Commits by Author'
  for author in branch.authors
    g.data("#{author.name}", [author.total_committed])
  end
  image_path = "babygitter_images/small_#{branch.name.gsub(/\//, "_")}_commits_by_author.png"
  file_path ="#{Babygitter.report_file_path}/#{image_path}"
  g.write(file_path)
  "./#{image_path}"
end

#create_small_stacked_bar_graph_of_commits_by_author_for_branch(branch) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/babygitter/output_helpers/graph_output.rb', line 77

def create_small_stacked_bar_graph_of_commits_by_author_for_branch(branch)
  g = Gruff::StackedBar.new(SMALL_SIZE) # Define a custom size
  g.sort = true  # Do NOT sort data based on values
  g.y_axis_increment = 10  # Points shown on the Y axis
  g.hide_legend = true
  g.title_font_size = 32 #
  g.theme = THEME
  g.title = 'Commits for the Last 52 weeks'
  for author in branch.authors
    g.data("#{author.name}", author.create_bar_data_points)
  end
  image_path= "babygitter_images/small_#{branch.name.gsub(/\//, "_")}_stacked_bar_graph_by_author.png"
  file_path = "#{Babygitter.report_file_path}/#{image_path}"
  g.write(file_path)
  "./#{image_path}"
end

#create_stacked_bar_graph_of_commits_by_author_for_branch(branch) ⇒ Object



54
55
56
57
58
# File 'lib/babygitter/output_helpers/graph_output.rb', line 54

def create_stacked_bar_graph_of_commits_by_author_for_branch(branch)
  large_file_path = create_large_stacked_bar_graph_of_commits_by_author_for_branch(branch)
  small_file_path = create_small_stacked_bar_graph_of_commits_by_author_for_branch(branch)
  "<a href='#{large_file_path}' rel='#{branch.name.gsub(/\//, "_")}_gallery' class='image_gallery'><img src=#{small_file_path} alt=''/></a>"
end