lib/bait/build.rb in bait-0.5.6 vs lib/bait/build.rb in bait-0.5.9
- old
+ new
@@ -1,12 +1,13 @@
require 'bait/object'
-require 'bait/tester'
+require 'bait/integrator'
require 'bait/build_helper'
require 'bait/simplecov_support'
require 'bait/pubsub'
require 'bait/phase'
require 'json'
+require 'yaml'
module Bait
class Build < Bait::Object
include Bait::BuildHelper
include Bait::SimpleCovSupport
@@ -33,39 +34,43 @@
after_destroy do
self.broadcast(:remove)
self.cleanup!
end
- def test_later
- self.status = "queued"
- self.output = ""
- self.save
- Bait::Tester.new.async.perform(self.id) unless Bait.env == "test"
- self
+ def phases
+ YAML.load_file(File.join(self.bait_dir, "bire.yml"))
end
- def test!
- Bait::Phase.new(self.script("test")).on(:init) do
- self.status = 'testing'
- self.save
- self.broadcast(:status, self.status)
+ def enter_phase name
+ Bait::Phase.new(self.script(name)).on(:init) do
+ self.broadcast(:status, "phase: #{name}")
end.on(:output) do |line|
self.output << line
self.broadcast(:output, line)
end.on(:missing) do |message|
self.output << message
- self.status = "script missing"
+ self.broadcast(:status, "missing: #{name}")
self.save
end.on(:done) do |zerostatus|
- if zerostatus
- self.status = "passed"
- else
- self.status = "failed"
+ unless self.status == "failed"
+ if zerostatus
+ self.status = "passed"
+ else
+ self.status = "failed"
+ end
+ self.save
+ check_for_simplecov
end
- self.save
self.broadcast(:status, self.status)
- check_for_simplecov
end.run!
+ end
+
+ def integrate_later
+ self.status = "queued"
+ self.output = ""
+ self.save
+ Bait::Integrator.new.async.perform(self.id) unless Bait.env == "test"
+ self
end
def clone!
return if cloned?
unless Dir.exists?(sandbox_directory)