Class: Integrity::Commit

Inherits:
Object show all
Includes:
DataMapper::Resource
Defined in:
lib/integrity/commit.rb

Instance Method Summary collapse

Instance Method Details

#authorObject Also known as: commit_author



20
21
22
# File 'lib/integrity/commit.rb', line 20

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

#failed?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/integrity/commit.rb', line 36

def failed?
  status == :failed
end

#human_readable_statusObject



44
45
46
47
48
49
50
# File 'lib/integrity/commit.rb', line 44

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

#messageObject Also known as: commit_message



16
17
18
# File 'lib/integrity/commit.rb', line 16

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

#outputObject



52
53
54
# File 'lib/integrity/commit.rb', line 52

def output
  build && build.output
end

#pending?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/integrity/commit.rb', line 40

def pending?
  status == :pending
end

#queue_buildObject



56
57
58
59
60
61
62
# File 'lib/integrity/commit.rb', line 56

def queue_build
  self.build = Build.create(:commit_id => id)
  self.save

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

#short_identifierObject Also known as: short_commit_identifier



24
25
26
# File 'lib/integrity/commit.rb', line 24

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

#statusObject



28
29
30
# File 'lib/integrity/commit.rb', line 28

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

#successful?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/integrity/commit.rb', line 32

def successful?
  status == :success
end