Sha256: f0e47538993f63c0db4763fabff93ce5690f4a22e1668e555224270c8c362417

Contents?: true

Size: 1.42 KB

Versions: 7

Compression:

Stored size: 1.42 KB

Contents

module Integrity
  class Commit
    include DataMapper::Resource

    property :id,           Integer,  :serial => true
    property :identifier,   String,   :nullable => false
    property :message,      String,   :length => 255
    property :author,       Author,   :length => 255
    property :committed_at, DateTime
    property :created_at,   DateTime
    property :updated_at,   DateTime

    has 1,     :build,   :class_name => "Integrity::Build",
                         :order => [:created_at.desc]

    belongs_to :project, :class_name => "Integrity::Project",
                         :child_key => [:project_id]

    def message
      attribute_get(:message) || "<Commit message not loaded>"
    end

    def author
      attribute_get(:author) ||
        Author.load('<Commit author not loaded> <<Commit author not loaded>>', :author)
    end

    def short_identifier
      identifier.to_s[0..6]
    end

    def status
      build.nil? ? :pending : build.status
    end

    def successful?
      status == :success
    end

    def failed?
      status == :failed
    end

    def pending?
      status == :pending
    end

    def human_readable_status
      case status
      when :success; "Built #{short_identifier} successfully"
      when :failed;  "Built #{short_identifier} and failed"
      when :pending; "#{short_identifier} hasn't been built yet"
      end
    end

    def output
      build && build.output
    end
  end
end

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
foca-integrity-0.1.9.3 lib/integrity/commit.rb
gforces-integrity-0.1.9.3 lib/integrity/commit.rb
gforces-integrity-0.1.9.4 lib/integrity/commit.rb
integrity-integrity-0.1.10 lib/integrity/commit.rb
integrity-integrity-0.1.9.3 lib/integrity/commit.rb
integrity-0.1.10 lib/integrity/commit.rb
integrity-0.1.9.3 lib/integrity/commit.rb