Module: Integrity::Integritray::Helpers

Includes:
Helpers
Defined in:
lib/integrity/integritray.rb

Instance Method Summary collapse

Instance Method Details

#activity(status) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/integrity/integritray.rb', line 25

def activity(status)
  case status
    when :success, :failed then
      'Sleeping'
    when :pending, :building then
      'Building'
    else
      'Sleeping'
  end
end

#authorize(user, password) ⇒ Object



47
48
49
50
# File 'lib/integrity/integritray.rb', line 47

def authorize(user, password)
  return true unless protect?
  Integrity.app.user == user && Integrity.app.pass == password
end

#build_status(status) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/integrity/integritray.rb', line 36

def build_status(status)
  case status
    when :success, :pending then
      'Success'
    when :failed then
      'Failure'
    else
      'Unknown'
  end
end

#protect?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/integrity/integritray.rb', line 52

def protect?
 Integrity.app.respond_to?(:user) && Integrity.app.respond_to?(:pass)
end

#xml_opts_for_project(project) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/integrity/integritray.rb', line 11

def xml_opts_for_project(project)
  opts = {}
  opts['name']     = project.name
  opts['category'] = project.branch
  opts['activity'] = activity(project.last_build.status) if project.last_build
  opts['webUrl']   = project_url(project).to_s.gsub(request.script_name, '')
  if project.last_build
    opts['lastBuildStatus'] = build_status(project.last_build.status)
    opts['lastBuildLabel']  = project.last_build.commit.short_identifier
    opts['lastBuildTime']   = project.last_build.completed_at
  end
  opts
end