Sha256: 90e62126b5a29fc0e62ee9a044cce5eaa5a18ab2349a001a2eb000648a89abde

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 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}, @context)
      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
        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

7 entries across 7 versions & 1 rubygems

Version Path
docman-0.0.13 lib/docman/builders/builder.rb
docman-0.0.12 lib/docman/builders/builder.rb
docman-0.0.11 lib/docman/builders/builder.rb
docman-0.0.10 lib/docman/builders/builder.rb
docman-0.0.9 lib/docman/builders/builder.rb
docman-0.0.8 lib/docman/builders/builder.rb
docman-0.0.7 lib/docman/builders/builder.rb