Sha256: 391315d8be118d5e3f02ce384990eea90033cc4f5775ecd4f8cb0489b65ca1c9

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

module Vx
  module Builder
    class DeployBuilder

      BLACK_LIST = %w{
        image
        before_script
        after_success
        script
        deploy_modules
      }

      attr_reader :base_build_configuration, :matrix_build_configuration, :branch

      def initialize(matrix_builder, options = {})
        @base_build_configuration    = matrix_builder.build_configuration
        @matrix_build_configuration  = matrix_builder.build.first
        @branch                      = options[:branch]
      end

      def build
        @build ||= begin
          return false unless valid?

          hash = matrix_build_configuration.to_hash

          BLACK_LIST.each do |key|
            hash.delete key
          end

          hash["env"]["matrix"] = []

          BuildConfiguration.new(
            hash.merge(
              "deploy_modules" => deploy_modules.map(&:to_hash),
              "deploy"         => nil
            )
          )
        end
      end

      def valid?
        deploy? and deploy_modules.any?
      end

      def deploy_modules
        @deploy_modules ||= deploy.find_modules(branch)
      end

      def deploy
        base_build_configuration.deploy
      end

      def deploy?
        deploy.attributes.any?
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vx-builder-0.3.1 lib/vx/builder/deploy_builder.rb