Sha256: b8469372c118ec93b38bd5aea5184bde55e7f2d464d305f6a61f6a9bee9893a8

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'active_record'

class Job < ActiveRecord::Base
  autoload :Configure, 'travis/model/job/configure'
  autoload :Tagging,   'travis/model/job/tagging'
  autoload :Cleanup,   'travis/model/job/cleanup'
  autoload :States,    'travis/model/job/states'
  autoload :Test,      'travis/model/job/test'

  class << self
    def queued
      where(:state => :created)
    end
  end

  include Cleanup

  has_one    :log, :class_name => "Artifact::Log", :conditions => { :type => "Artifact::Log" }
  has_many   :artifacts
  belongs_to :repository
  belongs_to :commit
  belongs_to :owner, :polymorphic => true, :autosave => true

  validates :repository_id, :commit_id, :owner_id, :owner_type, :presence => true

  serialize :config

  after_initialize do
    self.config = {} if config.nil?
  end

  before_create do
    build_log
    self.state = :created if self.state.nil?
  end

  def matrix_config?(config)
    config = config.to_hash.symbolize_keys
    Build.matrix_keys_for(config).map do |key|
      self.config[key.to_sym] == config[key] || commit.branch == config[key]
    end.inject(:&)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
travis-core-0.0.1 lib/travis/model/job.rb