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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/jirametrics/html_report_config.rb', line 113
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
105
106
107
|
# File 'lib/jirametrics/html_report_config.rb', line 105
def board_id id
@board_id = id
end
|
#boards ⇒ Object
For use by the user config
193
194
195
|
# File 'lib/jirametrics/html_report_config.rb', line 193
def boards
@file_config.project_config.board_configs.collect(&:id).collect { |id| find_board id }
end
|
197
198
199
200
201
202
203
204
205
206
207
|
# File 'lib/jirametrics/html_report_config.rb', line 197
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
|
# 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)
end
end
|
#dependency_chart(&block) ⇒ Object
146
147
148
|
# File 'lib/jirametrics/html_report_config.rb', line 146
def dependency_chart &block
execute_chart DependencyChart.new block
end
|
#discard_changes_before(status_becomes: nil, &block) ⇒ Object
209
210
211
212
213
214
215
|
# File 'lib/jirametrics/html_report_config.rb', line 209
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
# File 'lib/jirametrics/html_report_config.rb', line 155
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.users = project_config.users
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
79
80
81
|
# File 'lib/jirametrics/html_report_config.rb', line 79
def file_system
@file_config.project_config.exporter.file_system
end
|
#find_board(id) ⇒ Object
For use by the user config
188
189
190
|
# File 'lib/jirametrics/html_report_config.rb', line 188
def find_board id
@file_config.project_config.all_boards[id]
end
|
#find_board_id ⇒ Object
179
180
181
|
# File 'lib/jirametrics/html_report_config.rb', line 179
def find_board_id
@board_id || @file_config.project_config.guess_board_id
end
|
#html(string, type: :body) ⇒ Object
133
134
135
136
137
138
|
# File 'lib/jirametrics/html_report_config.rb', line 133
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
59
60
61
|
# File 'lib/jirametrics/html_report_config.rb', line 59
def included_projects
@file_config.project_config.aggregate_config.included_projects
end
|
#issues ⇒ Object
183
184
185
|
# File 'lib/jirametrics/html_report_config.rb', line 183
def issues
@file_config.issues
end
|
#load_css(html_directory:) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/jirametrics/html_report_config.rb', line 87
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
83
84
85
|
# File 'lib/jirametrics/html_report_config.rb', line 83
def log message
file_system.log message
end
|
#random_color ⇒ Object
129
130
131
|
# File 'lib/jirametrics/html_report_config.rb', line 129
def random_color
"##{Random.bytes(3).unpack1('H*')}"
end
|
#run ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/jirametrics/html_report_config.rb', line 63
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
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.
151
152
153
|
# File 'lib/jirametrics/html_report_config.rb', line 151
def settings
@file_config.project_config.settings
end
|
#sprint_burndown(options = :points_and_counts) ⇒ Object
140
141
142
143
144
|
# File 'lib/jirametrics/html_report_config.rb', line 140
def sprint_burndown options = :points_and_counts
execute_chart SprintBurndown.new do |chart|
chart.options = options
end
end
|
#timezone_offset ⇒ Object
109
110
111
|
# File 'lib/jirametrics/html_report_config.rb', line 109
def timezone_offset
@file_config.project_config.exporter.timezone_offset
end
|