Class: Debci::HTML

Inherits:
Object
  • 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

Methods included from HTMLHelpers

#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.



237
238
239
240
241
242
243
# File 'lib/debci/html.rb', line 237

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_directoryObject (readonly)

Returns the value of attribute root_directory.



235
236
237
# File 'lib/debci/html.rb', line 235

def root_directory
  @root_directory
end

Class Method Details

.updateObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/debci/html.rb', line 23

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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/debci/html.rb', line 47

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

#blacklistObject



308
309
310
311
312
# File 'lib/debci/html.rb', line 308

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



339
340
341
# File 'lib/debci/html.rb', line 339

def expand_url(url, suite)
  url && url.gsub('{SUITE}', suite)
end

#history(hist) ⇒ Object



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/debci/html.rb', line 343

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



245
246
247
# File 'lib/debci/html.rb', line 245

def index(filename)
  expand_template(:index, filename)
end

#package(package) ⇒ Object



314
315
316
317
318
319
320
321
# File 'lib/debci/html.rb', line 314

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



334
335
336
# File 'lib/debci/html.rb', line 334

def packages_page(filename)
  expand_template(:packages, filename)
end

#platform_specific_issues(dirname) ⇒ Object



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/debci/html.rb', line 292

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

#prefixesObject



323
324
325
326
327
328
329
330
331
332
# File 'lib/debci/html.rb', line 323

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



249
250
251
252
# File 'lib/debci/html.rb', line 249

def status(filename)
  @status_nav = load_template(:status_nav)
  expand_template(:status, filename)
end

#status_alerts(filename) ⇒ Object



254
255
256
257
258
259
# File 'lib/debci/html.rb', line 254

def status_alerts(filename)
  # Packages with atleast one visible tmpfail status
  @tmpfail = Debci::Job.tmpfail.visible
  @alert_number = @tmpfail.length
  expand_template(:status_alerts, filename)
end

#status_failing(dirname) ⇒ Object



279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/debci/html.rb', line 279

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



266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/debci/html.rb', line 266

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) # For 'All suites'
  @suites_jobs.each_key { |suite| generate_status_pending(dirname, suite) }
end

#status_slow(filename) ⇒ Object



261
262
263
264
# File 'lib/debci/html.rb', line 261

def status_slow(filename)
  @slow = Debci::Job.slow.sort_by { |j| j.package.name }
  expand_template(:status_slow, filename)
end