Class: Relevant::Hudson::Build

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

Constant Summary collapse

TitleRegexp =
/^(.*) #(\d+) \((.*)\)$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rss_entry) ⇒ Build

Returns a new instance of Build.



111
112
113
# File 'lib/relevant/hudson.rb', line 111

def initialize(rss_entry)
  @rss_entry = rss_entry
end

Instance Attribute Details

#rss_entryObject (readonly)

Returns the value of attribute rss_entry.



109
110
111
# File 'lib/relevant/hudson.rb', line 109

def rss_entry
  @rss_entry
end

Instance Method Details

#<=>(other_build) ⇒ Object



149
150
151
152
153
154
# File 'lib/relevant/hudson.rb', line 149

def <=>(other_build)
  order  = ['failing','building','passing']
  result = order.index(self.label) <=> order.index(other_build.label)
  result = self.project <=> other_build.project if result.zero?
  result
end

#building?Boolean

Returns:

  • (Boolean)


123
124
125
# File 'lib/relevant/hudson.rb', line 123

def building?
  status.match(/^\?$/)
end

#failing?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/relevant/hudson.rb', line 119

def failing?
  status.match(/broken/)
end

#labelObject



139
140
141
142
143
144
145
146
147
# File 'lib/relevant/hudson.rb', line 139

def label
  if passing?
    'passing'
  elsif failing?
    'failing'
  elsif building?
    'building'
  end
end

#numberObject



131
132
133
# File 'lib/relevant/hudson.rb', line 131

def number
  rss_entry.title.match(TitleRegexp)[2]
end

#passing?Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/relevant/hudson.rb', line 115

def passing?
  status.match(/(stable|back to normal)/i)
end

#projectObject



127
128
129
# File 'lib/relevant/hudson.rb', line 127

def project
  rss_entry.title.match(TitleRegexp)[1]
end

#statusObject



135
136
137
# File 'lib/relevant/hudson.rb', line 135

def status
  rss_entry.title.match(TitleRegexp)[3]
end