Sha256: 9f43428f2289509f1a1bdb257eb0efa82b165f34210bbe9879b44d17eebe2006

Contents?: true

Size: 1.57 KB

Versions: 29

Compression:

Stored size: 1.57 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
        @version = nil
        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

      def version
        @version
      end

      before_execute do
        if @context.need_rebuild?
          @context.build_mode = :rebuild
        else
          if @context.changed? or changed?
            @context.build_mode = :update
            log("Changed")
          else
            log("Not changed")
            @context.build_mode = :none
            raise NoChangesError, 'This version already deployed'
          end
        end

      end

      after_execute do
        if @execute_result
          @execute_result = @context.write_info(@execute_result)
        end
      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

29 entries across 29 versions & 1 rubygems

Version Path
docman-0.0.43 lib/docman/builders/builder.rb
docman-0.0.42 lib/docman/builders/builder.rb
docman-0.0.41 lib/docman/builders/builder.rb
docman-0.0.40 lib/docman/builders/builder.rb
docman-0.0.39 lib/docman/builders/builder.rb
docman-0.0.38 lib/docman/builders/builder.rb
docman-0.0.37 lib/docman/builders/builder.rb
docman-0.0.36 lib/docman/builders/builder.rb
docman-0.0.35 lib/docman/builders/builder.rb
docman-0.0.34 lib/docman/builders/builder.rb
docman-0.0.33 lib/docman/builders/builder.rb
docman-0.0.32 lib/docman/builders/builder.rb
docman-0.0.31 lib/docman/builders/builder.rb
docman-0.0.30 lib/docman/builders/builder.rb
docman-0.0.29 lib/docman/builders/builder.rb
docman-0.0.28 lib/docman/builders/builder.rb
docman-0.0.27 lib/docman/builders/builder.rb
docman-0.0.26 lib/docman/builders/builder.rb
docman-0.0.25 lib/docman/builders/builder.rb
docman-0.0.24 lib/docman/builders/builder.rb