Class: Debci::HTML
- Inherits:
-
Object
show all
- Includes:
- HTMLHelpers
- Defined in:
- lib/debci/html.rb,
lib/debci/html_cli.rb
Defined Under Namespace
Classes: Autopkgtest, CLI, Feed, JSON, PackageHistory, PackageJSON, Rooted
Constant Summary
Constants included
from HTMLHelpers
Debci::HTMLHelpers::ICONS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#expand_pin_packages, #filesize, #icon, #title_test_trigger_pin
Constructor Details
#initialize(root_directory = Debci.config.html_dir) ⇒ HTML
Returns a new instance of HTML.
239
240
241
242
243
244
245
|
# File 'lib/debci/html.rb', line 239
def initialize(root_directory=Debci.config.html_dir)
@root_directory = root_directory
@package_prefixes = Debci::Package.prefixes
@head = read_config_file('head.html')
@footer = read_config_file('footer.html')
end
|
Instance Attribute Details
#root_directory ⇒ Object
Returns the value of attribute root_directory.
237
238
239
|
# File 'lib/debci/html.rb', line 237
def root_directory
@root_directory
end
|
Class Method Details
.update ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/debci/html.rb', line 22
def update
html = Debci::HTML.new
Debci.config.suite_list.each do |suite|
Debci.config.arch_list.each do |arch|
json = Debci::HTML::JSON.new(suite, arch)
json.status
json.history
json.packages
end
end
html.index('index.html')
html.packages_page('packages/index.html')
html.status('status/index.html')
html.status_alerts('status/alerts/index.html')
html.status_slow('status/slow/index.html')
html.status_pending_jobs('status/pending')
html.status_failing('status/failing')
html.blacklist
html.platform_specific_issues('status/platform-specific-issues')
html.prefixes
end
|
.update_package(package, suite = nil, arch = nil) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/debci/html.rb', line 46
def update_package(package, suite = nil, arch = nil)
html = new
pkgjson = Debci::HTML::PackageJSON.new
autopkgtest = Debci::HTML::Autopkgtest.new
feed = Debci::HTML::Feed.new
suites = suite && [suite] || Debci.config.suite_list
archs = arch && [arch] || Debci.config.arch_list
suites.each do |s|
archs.each do |a|
history = PackageHistory.new(package, s, a)
pkgjson.history(history)
pkgjson.latest(history)
autopkgtest.link_latest(history)
html.history(history)
end
end
feed.package(package)
html.package(package)
end
|
Instance Method Details
#blacklist ⇒ Object
310
311
312
313
314
|
# File 'lib/debci/html.rb', line 310
def blacklist
@status_nav = load_template(:status_nav)
@blacklist = Debci.blacklist
expand_template(:blacklist, 'status/blacklist/index.html')
end
|
#expand_url(url, suite) ⇒ Object
expand { SUITE } macro in URLs
341
342
343
|
# File 'lib/debci/html.rb', line 341
def expand_url(url, suite)
url && url.gsub('{SUITE}', suite)
end
|
#history(hist) ⇒ Object
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
# File 'lib/debci/html.rb', line 345
def history(hist)
package = hist.package
suite = hist.suite
architecture = hist.arch
@package = package
@suite = suite
@architecture = architecture
@packages_dir = 'data/packages'
@package_dir = File.join(suite, architecture, package.prefix, package.name)
@site_url = expand_url(Debci.config.url_base, @suite)
@artifacts_url_base = expand_url(Debci.config.artifacts_url_base, @suite)
@moretitle = "#{package.name}/#{suite}/#{architecture}"
@history = hist.reverse
@package_links = load_template(:package_links)
filename = "packages/#{package.prefix}/#{package.name}/#{suite}/#{architecture}/index.html"
expand_template(:history, filename)
end
|
#index(filename) ⇒ Object
247
248
249
|
# File 'lib/debci/html.rb', line 247
def index(filename)
expand_template(:index, filename)
end
|
#package(package) ⇒ Object
316
317
318
319
320
321
322
323
|
# File 'lib/debci/html.rb', line 316
def package(package)
@package = package
@moretitle = package.name
@package_links = load_template(:package_links)
filename = "packages/#{package.prefix}/#{package.name}/index.html"
expand_template(:package, filename)
end
|
#packages_page(filename) ⇒ Object
336
337
338
|
# File 'lib/debci/html.rb', line 336
def packages_page(filename)
expand_template(:packages, filename)
end
|
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
# File 'lib/debci/html.rb', line 294
def platform_specific_issues(dirname)
@status_nav = load_template(:status_nav)
@filters = {
"#{dirname}": ["All", -1],
"#{dirname}/last_thirty_days": ["Last 30 Days", 30],
"#{dirname}/last_one_eighty_days": ["Last 180 Days", 180],
"#{dirname}/last_year": ["Last Year", 365]
}
issues = Debci::Job.platform_specific_issues
@filters.each do |target, filter|
generate_platform_specific_issues(issues, target, filter)
end
end
|
#prefixes ⇒ Object
325
326
327
328
329
330
331
332
333
334
|
# File 'lib/debci/html.rb', line 325
def prefixes
Debci::Package.order('name').group_by(&:prefix).each do |prefix, packages|
@prefix = prefix
@moretitle = prefix
@packages = packages
@packages.sort_by!(&:name)
filename = "packages/#{prefix}/index.html"
expand_template(:packagelist, filename)
end
end
|
#status(filename) ⇒ Object
251
252
253
254
|
# File 'lib/debci/html.rb', line 251
def status(filename)
@status_nav = load_template(:status_nav)
expand_template(:status, filename)
end
|
#status_alerts(filename) ⇒ Object
256
257
258
259
260
261
|
# File 'lib/debci/html.rb', line 256
def status_alerts(filename)
@tmpfail = Debci::Job.tmpfail.visible
@alert_number = @tmpfail.length
expand_template(:status_alerts, filename)
end
|
#status_failing(dirname) ⇒ Object
281
282
283
284
285
286
287
288
289
290
291
292
|
# File 'lib/debci/html.rb', line 281
def status_failing(dirname)
@status_nav = load_template(:status_nav)
jobs = Debci::Job.fail
@packages_per_page = Debci.config.failing_packages_per_page
generate_status_failing(dirname, jobs)
Debci.config.suite_list.each do |suite|
generate_status_failing(dirname, jobs, suite)
end
end
|
#status_pending_jobs(dirname) ⇒ Object
268
269
270
271
272
273
274
275
276
277
278
279
|
# File 'lib/debci/html.rb', line 268
def status_pending_jobs(dirname)
@status_nav = load_template(:status_nav)
@status_per_page = Debci.config.pending_status_per_page.to_i
@pending_jobs = Debci::Job.pending.count
@suites_jobs = Hash[Debci.config.suite_list.map do |x|
[x, Debci::Job.pending.where(suite: x).count]
end
]
generate_status_pending(dirname, nil) @suites_jobs.each_key { |suite| generate_status_pending(dirname, suite) }
end
|
#status_slow(filename) ⇒ Object
263
264
265
266
|
# File 'lib/debci/html.rb', line 263
def status_slow(filename)
@slow = Debci::Job.slow.sort_by { |j| j.package.name }
expand_template(:status_slow, filename)
end
|