Sha256: deecc5a4539039995d056d8bcdef1e20f94d3e3398e1013171ccaffb50702499

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'docman/commands/command'

module Docman
  module Builders
    class Builder < Docman::Command
      @@builders = {}
      @@build_results = {}


      def self.create(params = nil, context = nil, caller = nil)
        c = @@builders[params['handler']]
        if c
          c.new(params, context, caller, 'builder')
        else
          raise "Bad builder type: #{type}"
        end
      end

      def self.register_builder(name)
        @@builders[name] = self
      end

      def config
        super
        add_action('before_execute', {'type' => :clean_changed})
      end

      def validate_command
        raise "Please provide 'context'" if @context.nil?
        raise "Context should be of type 'Info'" unless @context.is_a? Docman::Info
      end

      before_execute do
        #TODO: rebuld if config changed.
        if @context.need_rebuild?
          log("Need rebuild")
        else
          log("Rebuild not needed")
          raise NoChangesError, 'This version already deployed' unless changed?
        end

      end

      after_execute do
        @execute_result = @context.write_info(@execute_result)
      end

      def changed?
        false
      end

      def describe
        "Build: #{properties_info}"
      end

      def prefix
        "#{@context['name']} - #{self.class.name}"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
docman-0.0.6 lib/docman/builders/builder.rb