lib/damagecontrol/app.rb in damagecontrol-0.5.0 vs lib/damagecontrol/app.rb in damagecontrol-0.5.0.1391
- old
+ new
@@ -1,11 +1,11 @@
-require 'drb'
require 'rubygems'
require 'needle'
-require_gem 'rscm'
+require 'rscm'
require 'damagecontrol/poller'
require 'damagecontrol/standard_persister'
+require 'damagecontrol/publisher/base'
# Wire up the whole DamageControl app with Needle's nice block based DI framework.
# I wonder - is BDI (Block Dependency Injection) a new flavour of DI?
REGISTRY = Needle::Registry.define do |b|
b.persister do
@@ -13,62 +13,33 @@
end
b.poller do
DamageControl::Poller.new do |project, changesets|
b.persister.save_changesets(project, changesets)
- b.persister.save_diffs(project, changesets)
b.persister.save_rss(project)
changeset = changesets.latest
- project.build(changeset.identifier) do |build|
+ project.execute_build(changeset.identifier, "Detected changes by polling #{project.scm.name}") do |build|
+ # TODO: we want to reuse this in other places (Execute publisher)
env = {
'PKG_BUILD' => changeset.identifier.to_s, # Rake standard
- 'DAMAGECONTROL_BUILD_LABEL' => changeset.identifier.to_s # For others
+ 'DAMAGECONTROL_BUILD_LABEL' => changeset.identifier.to_s, # For others
+ 'DAMAGECONTROL_CHANGED_FILES' => changeset.changes.collect{|change| change.path}.join(",")
}
build.execute(project.build_command, env)
+ project.publish(build)
end
+ # TODO: do this in a publisher that can be turned off if an other SCMWeb is used.
+ # This may take a while, so we do it after the build.
+ b.persister.save_diffs(project, changesets)
end
end
-
- b.drb_server do
- DamageControl::DrbServer.new('druby://localhost:9000')
- end
end
module DamageControl
class App
def run
- REGISTRY.poller.start
- REGISTRY.drb_server.start
-
- DRb.thread.join # Block forever
- end
- end
-
- # Drb top-level object that can be accessed by the web app.
- # The webapp should use this for any operations that are
- # lengthy.
- #
- class DrbServer
- def initialize(drb_url)
- @drb_url = drb_url
- end
-
- def start
- DRb.start_service(@drb_url, self)
- Log.info "DamageControl server running on #{@drb_url}"
- end
-
- def save_project(project)
- project.save
- end
-
- def delete_project(project)
- project.delete
- end
-
- def checkout_project(project)
- project.checkout
+ REGISTRY.poller.start.join
end
end
end