Class: CruiseStatus
- Inherits:
-
Object
- Object
- CruiseStatus
- Defined in:
- lib/cruisestatus.rb
Overview
Defined Under Namespace
Classes: Command
Instance Attribute Summary collapse
-
#feed_url ⇒ Object
Returns the value of attribute feed_url.
Class Method Summary collapse
-
.check(feed_url) ⇒ Object
Check the given cruise feed and return true if all builds have passed.
Instance Method Summary collapse
-
#check ⇒ Object
Update build status.
- #failure_message ⇒ Object
-
#failures ⇒ Object
A list of failing builds.
-
#initialize(feed_url) ⇒ CruiseStatus
constructor
- feed_url
-
URL pointing to a cruise.rb RSS feed.
-
#pass? ⇒ Boolean
True if all builds described by the feed are passing.
Constructor Details
#initialize(feed_url) ⇒ CruiseStatus
- feed_url
-
URL pointing to a cruise.rb RSS feed. Example: “my.cruise.com/projects.rss” or: “my.cruise.com/projects/myproject.rss”“
23 24 25 26 |
# File 'lib/cruisestatus.rb', line 23 def initialize( feed_url ) self.feed_url = feed_url check end |
Instance Attribute Details
#feed_url ⇒ Object
Returns the value of attribute feed_url.
16 17 18 |
# File 'lib/cruisestatus.rb', line 16 def feed_url @feed_url end |
Class Method Details
.check(feed_url) ⇒ Object
Check the given cruise feed and return true if all builds have passed. False otherwise.
30 31 32 |
# File 'lib/cruisestatus.rb', line 30 def self.check( feed_url ) new( feed_url ).pass? end |
Instance Method Details
#check ⇒ Object
Update build status
36 37 38 39 40 41 42 |
# File 'lib/cruisestatus.rb', line 36 def check project_feed = Kernel.open( feed_url ).read @doc = REXML::Document.new project_feed rescue Exception => e @failures = [e.] @doc = REXML::Document.new "" end |
#failure_message ⇒ Object
60 61 62 |
# File 'lib/cruisestatus.rb', line 60 def self.failures.join ", " end |
#failures ⇒ Object
A list of failing builds. Empty if all builds passed.
52 53 54 55 56 57 58 |
# File 'lib/cruisestatus.rb', line 52 def failures @failures ||= REXML::XPath.match( @doc, "//item/title" ).select { |element| element.text =~ /failed$/ }.map do |element| element.text.gsub( /(.*) build (.+) failed$/, '\1' ) end end |
#pass? ⇒ Boolean
True if all builds described by the feed are passing.
46 47 48 |
# File 'lib/cruisestatus.rb', line 46 def pass? failures.empty? end |