Sha256: fddfe711649727fe873dd44695a971a92e3773fcd09a9552dcb82984d64e9021

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module Integrity
  class Build
    include DataMapper::Resource

    property :id,           Serial
    property :output,       Text,     :default => "", :lazy => false
    property :successful,   Boolean,  :default => false
    property :commit_id,    Integer,  :nullable => false
    property :started_at,   DateTime
    property :completed_at, DateTime

    timestamps :at

    belongs_to :commit, :class_name => "Integrity::Commit",
                        :child_key => [:commit_id]

    def self.pending
      all(:started_at => nil)
    end

    def self.queue(commit)
      commit.update_attributes(:build => new)

      # Build on foreground (this will move away, I promise)
      ProjectBuilder.build(commit)
    end

    def pending?
      started_at.nil?
    end

    def failed?
      !successful?
    end

    def status
      case
      when pending?    then :pending
      when successful? then :success
      when failed?     then :failed
      end
    end

    def start!(time=Time.now)
      self.started_at = time
    end

    def complete!(time=Time.now)
      self.completed_at = time
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
integrity-0.1.11 lib/integrity/build.rb