Class: Promotion::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/promotion/application.rb

Overview

The Promotion::Application coordinates the activity of the components:

  • Enforcer

  • Generator

  • Evolver

Instance Method Summary collapse

Constructor Details

#initialize(appname) ⇒ Application

Creates a new Promotion::Application instance for a specific app to be promoted. A global $log logger is also created.



19
20
21
22
23
24
25
26
# File 'lib/promotion/application.rb', line 19

def initialize(appname)
	@appname = appname
	$log = Logger.new(Files::Log, 0) # rotate log file at 1M limit
	$log.formatter = proc { |severity, datetime, progname, message|
     "#{datetime.iso8601()} #{severity} #{message}\n"
   }
	$log.level = Logger::INFO
end

Instance Method Details

#devolve(target = nil) ⇒ Object

Devolve a database back to an earlier version



44
45
46
47
# File 'lib/promotion/application.rb', line 44

def devolve(target=nil)
	evolver = Promotion::Evolver.new(@appname, false, target)
	evolver.start()
end

#evolve(target = nil) ⇒ Object

Evolves the database to a target version, or as far as possible, by executing database migration scripts in the evolve folder



38
39
40
41
# File 'lib/promotion/application.rb', line 38

def evolve(target=nil)
	evolver = Promotion::Evolver.new(@appname, true, target)
	evolver.start()
end

#promoteObject

Promotes an application into production.



29
30
31
32
33
34
# File 'lib/promotion/application.rb', line 29

def promote()
	enforcer = Promotion::Enforcer.new(@appname)
	enforcer.start()
	Generator::start()
	$log.info("Application #{@appname} successfully promoted.")
end