Sha256: 32e6e936605974e4e9e26730a4a90b7adab72d2e552e44654821f52da26725f3

Contents?: true

Size: 940 Bytes

Versions: 1

Compression:

Stored size: 940 Bytes

Contents

require "open-uri"
require "nokogiri"

module CiStatus
  # Parses the CC format (also used by CCMenu, CCTray etc.)
  class CruiseControl
    attr_accessor :url

    def initialize(url)
      self.url = url
    end

    def projects
      @projects ||= document.xpath("/Projects/Project").map do |project|
        Project.new do |p|
          p.name   = project["name"]
          p.url    = project["webUrl"]
          p.time   = project["lastBuildTime"]
          p.status = project["lastBuildStatus"]
        end
      end
    end

    private

    def document
      @document ||= Nokogiri::XML(data)
    end

    def data
      @data ||= open(url).read
    end

    class Project
      attr_accessor :name, :url, :time, :status

      def initialize(&block)
        yield self if block_given?
      end

      def success?
        status == "Success"
      end

      def failure?
        status == "Failure"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ci_status-0.1.0 lib/ci_status/cruise_control.rb