Class: HtmlReportConfig
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#method_missing, #respond_to_missing?
Constructor Details
#initialize(file_config:, block:) ⇒ HtmlReportConfig
Returns a new instance of HtmlReportConfig.
43
44
45
46
47
48
|
# File 'lib/jirametrics/html_report_config.rb', line 43
def initialize file_config:, block:
@file_config = file_config
@block = block
@sections = [] @charts = [] end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class SelfOrIssueDispatcher
Instance Attribute Details
#charts ⇒ Object
Returns the value of attribute charts.
9
10
11
|
# File 'lib/jirametrics/html_report_config.rb', line 9
def charts
@charts
end
|
#file_config ⇒ Object
Returns the value of attribute file_config.
9
10
11
|
# File 'lib/jirametrics/html_report_config.rb', line 9
def file_config
@file_config
end
|
#sections ⇒ Object
Returns the value of attribute sections.
9
10
11
|
# File 'lib/jirametrics/html_report_config.rb', line 9
def sections
@sections
end
|
Class Method Details
.define_chart(name:, classname:, deprecated_warning: nil, deprecated_date: nil) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/jirametrics/html_report_config.rb', line 11
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 << " file_system.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/jirametrics/html_report_config.rb', line 115
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) ⇒ Object
107
108
109
|
# File 'lib/jirametrics/html_report_config.rb', line 107
def board_id id
@board_id = id
end
|
#boards ⇒ Object
For use by the user config
195
196
197
|
# File 'lib/jirametrics/html_report_config.rb', line 195
def boards
@file_config.project_config.board_configs.collect(&:id).collect { |id| find_board id }
end
|
199
200
201
202
203
204
205
206
207
208
209
|
# File 'lib/jirametrics/html_report_config.rb', line 199
def now: DateTime.now
now = now.new_offset(timezone_offset)
version = Gem.loaded_specs['jirametrics']&.version || 'Next'
<<~HTML
<section id="footer">
Report generated on <b>#{now.strftime('%Y-%b-%d')}</b> at <b>#{now.strftime('%I:%M:%S%P %Z')}</b>
with <a href="https://jirametrics.org">JiraMetrics</a> <b>v#{version}</b>
</section>
HTML
end
|
#cycletime(label = nil, &block) ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/jirametrics/html_report_config.rb', line 50
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, file_system: file_system, settings: settings
)
end
end
|
#dependency_chart(&block) ⇒ Object
148
149
150
|
# File 'lib/jirametrics/html_report_config.rb', line 148
def dependency_chart &block
execute_chart DependencyChart.new block
end
|
#discard_changes_before(status_becomes: nil, &block) ⇒ Object
211
212
213
214
215
216
217
|
# File 'lib/jirametrics/html_report_config.rb', line 211
def discard_changes_before status_becomes: nil, &block
file_system.deprecated(
date: '2025-01-09',
message: 'discard_changes_before is now only supported at the project level'
)
file_config.project_config.discard_changes_before status_becomes: status_becomes, &block
end
|
#execute_chart(chart, &after_init_block) ⇒ Object
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
# File 'lib/jirametrics/html_report_config.rb', line 157
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.atlassian_document_format = project_config.atlassian_document_format
chart.all_boards = project_config.all_boards
chart.board_id = find_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
@charts << chart
html chart.run
end
|
#file_system ⇒ Object
82
83
84
|
# File 'lib/jirametrics/html_report_config.rb', line 82
def file_system
@file_config.project_config.exporter.file_system
end
|
#find_board(id) ⇒ Object
For use by the user config
190
191
192
|
# File 'lib/jirametrics/html_report_config.rb', line 190
def find_board id
@file_config.project_config.all_boards[id]
end
|
#find_board_id ⇒ Object
181
182
183
|
# File 'lib/jirametrics/html_report_config.rb', line 181
def find_board_id
@board_id || @file_config.project_config.guess_board_id
end
|
#html(string, type: :body) ⇒ Object
135
136
137
138
139
140
|
# File 'lib/jirametrics/html_report_config.rb', line 135
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
61
62
63
|
# File 'lib/jirametrics/html_report_config.rb', line 61
def included_projects
@file_config.project_config.aggregate_config.included_projects
end
|
#issues ⇒ Object
185
186
187
|
# File 'lib/jirametrics/html_report_config.rb', line 185
def issues
@file_config.issues
end
|
#load_css(html_directory:) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/jirametrics/html_report_config.rb', line 90
def load_css html_directory:
base_css_filename = File.join(html_directory, 'index.css')
base_css = file_system.load(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
86
87
88
|
# File 'lib/jirametrics/html_report_config.rb', line 86
def log message
file_system.log message
end
|
#random_color ⇒ Object
131
132
133
|
# File 'lib/jirametrics/html_report_config.rb', line 131
def random_color
"##{Random.bytes(3).unpack1('H*')}"
end
|
#run ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/jirametrics/html_report_config.rb', line 65
def run
instance_eval(&@block)
execute_chart DataQualityReport.new(file_config.project_config.discarded_changes_data)
@sections.rotate!(-1)
html
html_directory = "#{Pathname.new(File.realpath(__FILE__)).dirname}/html"
css = load_css html_directory: html_directory
javascript = file_system.load(File.join(html_directory, 'index.js'))
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
|
#settings ⇒ Object
have an explicit method here so that index.erb can call ‘settings’ just as any other erb can.
153
154
155
|
# File 'lib/jirametrics/html_report_config.rb', line 153
def settings
@file_config.project_config.settings
end
|
#sprint_burndown(options = :points_and_counts) ⇒ Object
142
143
144
145
146
|
# File 'lib/jirametrics/html_report_config.rb', line 142
def sprint_burndown options = :points_and_counts
execute_chart SprintBurndown.new do |chart|
chart.options = options
end
end
|
#timezone_offset ⇒ Object
111
112
113
|
# File 'lib/jirametrics/html_report_config.rb', line 111
def timezone_offset
@file_config.project_config.exporter.timezone_offset
end
|