Sha256: e8df1c826b8a2707c5c94a65d09603cc0f743b2033559f20e62e19a1419e3283

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

require 'rubygems'
require 'needle'
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
    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.
      # This may take a while, so we do it after the build.
      b.persister.save_diffs(project, changesets)
    end
  end
end
  
module DamageControl

  class App
    def run
      REGISTRY.poller.start.join
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
damagecontrol-0.5.0.1391 lib/damagecontrol/app.rb
damagecontrol-0.5.0.1393 lib/damagecontrol/app.rb
damagecontrol-0.5.0.1392 lib/damagecontrol/app.rb