Top Level Namespace

Defined Under Namespace

Modules: ActionView, AdminHelper, ApplicationHelper, BuildHelper, DamageControl, ObjectTemplate, ProjectHelper Classes: AdminController, ApplicationController, Array, BuildController, FilesController, ProjectController, ScmController, String

Constant Summary collapse

REGISTRY =

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?

Needle::Registry.define do |b|
  b.persister do
    DamageControl::StandardPersister.new
  end 

  b.poller do 
    DamageControl::Poller.new do |project, changesets|
      b.persister.save_changesets(project, changesets)
      b.persister.save_rss(project)
      changeset = changesets.latest
      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_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.
      # Disable by default if other SCMWeb is specified.
      # This may take a while, so we do it after the build.
      b.persister.save_diffs(project, changesets)
    end
  end
end