Sha256: 56133338e6eae0a22303de7f95fe851bff2f1f01b949a1f426b25168c8fece06

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

module Vx
  module Builder
    class BuildConfiguration
      class Deploy

        class Provider

          attr_reader :name, :options, :on

          def initialize(new_attributes)
            normalize new_attributes.dup
          end

          def branch?(branch)
            return true if on.empty?
            on.include?(branch)
          end

          def to_hash
            options.merge(
              "provider" => @name,
              "branch"   => on
            )
          end

          def shell?
            @name == 'shell'
          end

          def command
            Array(options["command"])
          end

          private

            def normalize(new_attributes)
              @name    = new_attributes.delete("provider")
              @on      = new_attributes.delete("branch")
              @options = new_attributes

              @on =
                case @on
                when String
                  [@on]
                when Array
                  @on.map(&:to_s)
                else
                  []
                end

            end

        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vx-builder-0.2.2 lib/vx/builder/build_configuration/deploy/provider.rb
vx-builder-0.2.1 lib/vx/builder/build_configuration/deploy/provider.rb
vx-builder-0.2.0 lib/vx/builder/build_configuration/deploy/provider.rb