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.



231
232
233
234
235
236
237
# File 'lib/debci/html.rb', line 231

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.



229
230
231
# File 'lib/debci/html.rb', line 229

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
# 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.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')
end

.update_package(package, suite = nil, arch = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/debci/html.rb', line 45

def update_package(package, suite = nil, arch = nil)
  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)
    end
  end

  feed.package(package)
end

Instance Method Details

#blacklistObject



302
303
304
305
306
# File 'lib/debci/html.rb', line 302

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



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

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

#index(filename) ⇒ Object



239
240
241
# File 'lib/debci/html.rb', line 239

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

#platform_specific_issues(dirname) ⇒ Object



286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/debci/html.rb', line 286

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

#status(filename) ⇒ Object



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

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

#status_alerts(filename) ⇒ Object



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

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



273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/debci/html.rb', line 273

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



260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/debci/html.rb', line 260

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



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

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