Class: Janky::Views::Index

Inherits:
Layout
  • Object
show all
Defined in:
lib/janky/views/index.rb

Instance Method Summary collapse

Methods inherited from Layout

#page_class, #root, #title

Instance Method Details

#css_status_for(build) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/janky/views/index.rb', line 23

def css_status_for(build)
  if build.green?
    "good"
  elsif build.building?
    "building"
  elsif build.pending?
    "pending"
  elsif build.red?
    "janky"
  end
end

#jobsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/janky/views/index.rb', line 5

def jobs
  @builds.collect do |build|
    {
      :console_path    => "/#{build.number}/output",
      :compare_url     => build.compare,
      :repo_path       => "/#{build.repo_name}",
      :branch_path     => "/#{build.repo_name}/#{build.branch_name}",
      :repo_name       => build.repo_name,
      :branch_name     => build.branch_name,
      :status          => css_status_for(build),
      :last_built_text => last_built_text_for(build),
      :message         => build.commit_message,
      :sha1            => build.short_sha1,
      :author          => build.commit_author.split("<").first
    }
  end
end

#last_built_text_for(build) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/janky/views/index.rb', line 35

def last_built_text_for(build)
  if build.building?
    "Build started <span class='relatize'>#{build.started_at}</span>…"
  elsif build.completed?
    "Built in <span>#{build.duration}</span> seconds"
  elsif build.pending?
    "Build queued <span class='relatize'>#{build.queued_at}</span>…"
  end
end