Class: BuildLights::Hudson

Inherits:
Object
  • Object
show all
Defined in:
lib/buildlights/hudson.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, parser = FeedParser) ⇒ Hudson

Returns a new instance of Hudson.



6
7
8
9
# File 'lib/buildlights/hudson.rb', line 6

def initialize(uri, parser = FeedParser)
  puts "Hudson url: #{uri}" if $verbose
  @feed = parser.parse uri
end

Instance Method Details

#failed_jobsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/buildlights/hudson.rb', line 11

def failed_jobs
  jobs = {}

  @feed.entries.each do |entry|
    match = /(.*) #\d+ (.*)/.match(entry.title)
    raise "Invalid rss title #{entry.title}" unless match
    name = match[1]
    status = match[2]

    unless jobs[name]
      jobs[name] = status
      puts "#{name} -> #{status}" if $verbose
    end
  end

  jobs.map do |name, status|
    name if /FAIL|BROKE/i.match(status)
  end.compact
end