lib/docman/builders/builder.rb in docman-0.0.3 vs lib/docman/builders/builder.rb in docman-0.0.4
- old
+ new
@@ -3,27 +3,26 @@
module Docman
module Builders
class Builder
@@subclasses = {}
- def self.create(type, root, build_type, state, info)
+ def self.create(type, root, build_type, info)
c = @@subclasses[type]
if c
- c.new(root, build_type, state, info)
+ c.new(root, build_type, info)
else
raise "Bad builder type: #{type}"
end
end
def self.register_builder(name)
@@subclasses[name] = self
end
- def initialize(root, build_type, state, info)
+ def initialize(root, build_type, info)
@root = root
@build_type = build_type
- @state = state
@info = info
@before_build_actions = @build_type['before_build_actions'].nil? ? [] : @build_type['before_build_actions']
@after_build_actions = @build_type['after_build_actions'].nil? ? [] : @build_type['after_build_actions']
@before_build_actions << 'clean_if_changed'
end
@@ -35,30 +34,14 @@
end
def do
perform(@before_build_actions, 'before_build_action')
# Dispatch to corresponding method.
- write_info self.send("#{@build_type['type']}")
+ @info.write_info(self.send("#{@build_type['type']}"))
perform(@after_build_actions, 'after_build_action')
end
- def write_info(result)
- to_save = {}
- # to_save = @info.clone
- to_save['state'] = @state
- to_save['version_type'] = @info.version_type(@state) unless @info.version_type(@state).nil?
- to_save['version'] = @info.version(@state) unless @info.version(@state).nil?
- to_save['ref'] = result
- to_save['build_type'] = @build_type['type']
- # to_save.delete('full_build_path')
- # to_save.delete('full_path')
- # to_save.delete('temp_path')
- # to_save.delete('repo')
- # to_save.delete('states')
- File.open("#{@info['full_build_path']}/info.yaml", 'w') {|f| f.write to_save.to_yaml}
- end
-
def perform(actions, method_prefix)
unless actions.nil?
actions.each do |action|
method = "#{method_prefix}_#{action}"
self.send(method)
@@ -69,10 +52,10 @@
def repo?(path)
File.directory? File.join(path, '.git')
end
def after_build_action_git_commit
- message = "name: #{@info['name']} updated, state: #{@state}"
+ message = "name: #{@info['name']} updated, state: #{@info['state']}"
GitUtil.commit(@root['full_build_path'], @info['full_build_path'], message)
end
end
end
end