Class: HtmlReportConfig
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#discard_changes_before
#method_missing, #respond_to_missing?
Constructor Details
#initialize(file_config:, block:) ⇒ HtmlReportConfig
Returns a new instance of HtmlReportConfig.
43
44
45
46
47
|
# File 'lib/jirametrics/html_report_config.rb', line 43
def initialize file_config:, block:
@file_config = file_config
@block = block
@sections = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class SelfOrIssueDispatcher
Instance Attribute Details
#file_config ⇒ Object
Returns the value of attribute file_config.
10
11
12
|
# File 'lib/jirametrics/html_report_config.rb', line 10
def file_config
@file_config
end
|
Returns the value of attribute sections.
10
11
12
|
# File 'lib/jirametrics/html_report_config.rb', line 10
def sections
@sections
end
|
Class Method Details
.define_chart(name:, classname:, deprecated_warning: nil, deprecated_date: nil) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/jirametrics/html_report_config.rb', line 12
def self.define_chart name:, classname:, deprecated_warning: nil, deprecated_date: nil
lines = []
lines << "def #{name} &block"
lines << ' block = ->(_) {} unless block'
if deprecated_warning
lines << " deprecated date: #{deprecated_date.inspect}, message: #{deprecated_warning.inspect}"
end
lines << " execute_chart #{classname}.new(block)"
lines << 'end'
module_eval lines.join("\n"), __FILE__, __LINE__
end
|
Instance Method Details
#aging_work_in_progress_chart(board_id: nil, &block) ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/jirametrics/html_report_config.rb', line 111
def aging_work_in_progress_chart board_id: nil, &block
block ||= ->(_) {}
if board_id.nil?
ids = issues.collect { |i| i.board.id }.uniq.sort
else
ids = [board_id]
end
ids.each do |id|
execute_chart(AgingWorkInProgressChart.new(block)) do |chart|
chart.board_id = id
end
end
end
|
#board_id(id = nil) ⇒ Object
102
103
104
105
|
# File 'lib/jirametrics/html_report_config.rb', line 102
def board_id id = nil
@board_id = id unless id.nil?
@board_id
end
|
For use by the user config
202
203
204
|
# File 'lib/jirametrics/html_report_config.rb', line 202
def boards
@file_config.project_config.board_configs.collect(&:id).collect { |id| find_board id }
end
|
#cycletime(label = nil, &block) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/jirametrics/html_report_config.rb', line 49
def cycletime label = nil, &block
@file_config.project_config.all_boards.each_value do |board|
raise 'Multiple cycletimes not supported' if board.cycletime
board.cycletime = CycleTimeConfig.new(parent_config: self, label: label, block: block)
end
end
|
#dependency_chart(&block) ⇒ Object
157
158
159
|
# File 'lib/jirametrics/html_report_config.rb', line 157
def dependency_chart &block
execute_chart DependencyChart.new block
end
|
#discard_changes_before_hook(issues_cutoff_times) ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/jirametrics/html_report_config.rb', line 144
def discard_changes_before_hook issues_cutoff_times
@original_issue_times = {}
issues_cutoff_times.each do |issue, cutoff_time|
started = issue.board.cycletime.started_stopped_times(issue).first
if started && started <= cutoff_time
@original_issue_times[issue] = { cutoff_time: cutoff_time, started_time: started }
end
end
end
|
#execute_chart(chart, &after_init_block) ⇒ Object
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/jirametrics/html_report_config.rb', line 166
def execute_chart chart, &after_init_block
project_config = @file_config.project_config
chart.file_system = file_system
chart.issues = issues
chart.time_range = project_config.time_range
chart.timezone_offset = timezone_offset
chart.settings = settings
chart.all_boards = project_config.all_boards
chart.board_id = find_board_id if chart.respond_to? :board_id=
chart.holiday_dates = project_config.exporter.holiday_dates
time_range = @file_config.project_config.time_range
chart.date_range = time_range.begin.to_date..time_range.end.to_date
chart.aggregated_project = project_config.aggregated_project?
after_init_block&.call chart
html chart.run
end
|
#file_system ⇒ Object
76
77
78
|
# File 'lib/jirametrics/html_report_config.rb', line 76
def file_system
@file_config.project_config.exporter.file_system
end
|
#find_board(id) ⇒ Object
For use by the user config
197
198
199
|
# File 'lib/jirametrics/html_report_config.rb', line 197
def find_board id
@file_config.project_config.all_boards[id]
end
|
#find_board_id ⇒ Object
188
189
190
|
# File 'lib/jirametrics/html_report_config.rb', line 188
def find_board_id
@board_id || @file_config.project_config.guess_board_id
end
|
#html(string, type: :body) ⇒ Object
131
132
133
134
135
136
|
# File 'lib/jirametrics/html_report_config.rb', line 131
def html string, type: :body
allowed_types = %i[body header]
raise "Unexpected type: #{type} allowed_types: #{allowed_types.inspect}" unless allowed_types.include? type
@sections << [string, type]
end
|
#included_projects ⇒ Object
Mostly this is its own method so it can be called from the config
58
59
60
|
# File 'lib/jirametrics/html_report_config.rb', line 58
def included_projects
@file_config.project_config.aggregate_config.included_projects
end
|
192
193
194
|
# File 'lib/jirametrics/html_report_config.rb', line 192
def issues
@file_config.issues
end
|
#load_css(html_directory:) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/jirametrics/html_report_config.rb', line 84
def load_css html_directory:
base_css_filename = File.join(html_directory, 'index.css')
base_css = file_system.load(base_css_filename)
log("Loaded CSS: #{base_css_filename}")
= settings['include_css']
if
if File.exist?()
base_css << "\n\n" << file_system.load()
log("Loaded CSS: #{}")
else
log("Unable to find specified CSS file: #{}")
end
end
base_css
end
|
#log(message) ⇒ Object
80
81
82
|
# File 'lib/jirametrics/html_report_config.rb', line 80
def log message
file_system.log message
end
|
#random_color ⇒ Object
127
128
129
|
# File 'lib/jirametrics/html_report_config.rb', line 127
def random_color
"##{Random.bytes(3).unpack1('H*')}"
end
|
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/jirametrics/html_report_config.rb', line 62
def run
instance_eval(&@block)
execute_chart DataQualityReport.new(@original_issue_times || {})
@sections.rotate!(-1)
html_directory = "#{Pathname.new(File.realpath(__FILE__)).dirname}/html"
css = load_css html_directory: html_directory
erb = ERB.new file_system.load(File.join(html_directory, 'index.erb'))
file_system.save_file content: erb.result(binding), filename: @file_config.output_filename
end
|
have an explicit method here so that index.erb can call ‘settings’ just as any other erb can.
162
163
164
|
# File 'lib/jirametrics/html_report_config.rb', line 162
def settings
@file_config.project_config.settings
end
|
#sprint_burndown(options = :points_and_counts) ⇒ Object
138
139
140
141
142
|
# File 'lib/jirametrics/html_report_config.rb', line 138
def sprint_burndown options = :points_and_counts
execute_chart SprintBurndown.new do |chart|
chart.options = options
end
end
|
#timezone_offset ⇒ Object
107
108
109
|
# File 'lib/jirametrics/html_report_config.rb', line 107
def timezone_offset
@file_config.project_config.exporter.timezone_offset
end
|