Sha256: 4c4741c58764a7c8f08e5a5d69b492dabca3628aace8268880208f8ce9ecaa07

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

module Vx
  module Builder
    class DeployBuilder

      BLACK_LIST = %w{
        image
        before_script
        after_success
        script
      }

      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,
              "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.0 lib/vx/builder/deploy_builder.rb