lib/docman/deployers/deployer.rb in docman-0.0.14 vs lib/docman/deployers/deployer.rb in docman-0.0.15
- old
+ new
@@ -10,11 +10,10 @@
define_hooks :before_push, :after_push, :before_build, :after_build, :before_deploy, :after_deploy
@@deployers = {}
- #todo: prod ssh settings deploy target
#todo: docroot config in separate repos for projects
def self.create(params, context = nil, caller = nil)
c = @@deployers[params['handler']]
if c
@@ -31,18 +30,20 @@
def initialize(params, context = nil, caller = nil, type = nil)
super(params, context, caller, type)
@docroot_config = caller.docroot_config
@builded = []
@build_results = {}
- @environments = Docman::Application.instance.config['envoronments']
+ @versions = {}
end
def config
unless self['name'].nil?
@docroot_config.chain(@docroot_config.info_by(self['name'])).values.each do |info|
add_actions(info, info)
end
+ else
+ # add_actions()
end
path = @docroot_config.root['full_build_path']
if File.directory?(path) and GitUtil.repo?(path)
Dir.chdir path
@@ -119,10 +120,11 @@
def write_version_file(version, path)
to_write = Hash.new
to_write['random'] = version
to_write['config_hash'] = @config_hash
to_write['docroot_config_hash'] = @docroot_config_hash
+ to_write.deep_merge! @versions
File.open(path, 'w') {|f| f.write to_write.to_yaml}
end
def write_config_file(config, path)
File.open(path, 'w') {|f| f.write config}
@@ -136,11 +138,11 @@
end
end
def build_dir_chain(info)
@docroot_config.chain(info).values.each do |item|
- item.state = self['state']
+ item.state_name = self['state']
if item.need_rebuild?
build_recursive(item)
return
elsif
build_dir(item)
@@ -148,15 +150,17 @@
end
end
def build_dir(info)
return if @builded.include? info['name']
- info.state = self['state']
- build_result = Docman::Builders::Builder.create(self['builders'][info['type']], info, self).perform
+ info.state_name = self['state']
+ builder = Docman::Builders::Builder.create(self['builders'][info['type']], info, self)
+ build_result = builder.perform
logger.info '-------------------------------------------------------'
@changed = true if build_result
- @build_results[info['name']] = build_result
+ @build_results[info['name']] = build_result ? build_result : 'Not builded'
+ @versions[info['name']] = builder.version
@builded << info['name']
end
def build_recursive(info = nil)
info = info ? info : @docroot_config.structure
@@ -165,9 +169,10 @@
info['children'].each do |child|
build_recursive(child)
end
end
+ # TODO: need to refactor.
def describe(type = 'short')
properties_info(['handler'])
end
end
\ No newline at end of file