Sha256: 01bf8f497ef590c3c1cde6408fd9586c614aeb177ddf51922234be28e7884c3a
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
module Travis module Surveillance class Job class Config ATTRIBUTES = [:env, :rvm] attr_accessor *ATTRIBUTES def initialize(attrs = {}) self.attributes = attrs end def attributes=(attrs = {}) attrs.each do |key, value| send("#{key}=", value) if ATTRIBUTES.include?(key.to_sym) end end end ATTRIBUTES = [:build, :finished_at, :id, :number, :result, :started_at] attr_accessor *ATTRIBUTES alias_method :status, :result alias_method :status=, :result= def initialize(attrs = {}) self.attributes = attrs populate end def attributes=(attrs = {}) attrs.each do |key, value| next if value.nil? if key == 'config' config.attributes = value else send("#{key}=", (key[/_at$/] ? Time.parse(value) : value)) if ATTRIBUTES.include?(key.to_sym) end end end def config @config ||= Config.new end def duration if started_at && finished_at finished_at - started_at elsif started_at Time.now - started_at else nil end end def failed? !status.nil? && !passed? end def passed? !status.nil? && status.zero? end def running? status.nil? end def state if running? 'running' elsif passed? 'passed' else 'failed' end end private def get_details if Travis::Surveillance.mocking? JSON.parse(IO.read(File.dirname(__FILE__) + "/../../../spec/support/jobs/#{id}.json")) else JSON.parse(open("http://travis-ci.org/jobs/#{id}.json").read) end end def populate self.attributes = get_details end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
travis-surveillance-0.0.1 | lib/travis/surveillance/job.rb |