Class: Integrity::Build

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.pendingObject



17
18
19
# File 'lib/integrity/build.rb', line 17

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

.queue(commit) ⇒ Object



21
22
23
24
25
26
# File 'lib/integrity/build.rb', line 21

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

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

Instance Method Details

#complete!(time = Time.now) ⇒ Object



48
49
50
# File 'lib/integrity/build.rb', line 48

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

#failed?Boolean

Returns:

  • (Boolean)


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

def failed?
  !successful?
end

#pending?Boolean

Returns:

  • (Boolean)


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

def pending?
  started_at.nil?
end

#start!(time = Time.now) ⇒ Object



44
45
46
# File 'lib/integrity/build.rb', line 44

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

#statusObject



36
37
38
39
40
41
42
# File 'lib/integrity/build.rb', line 36

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