Sha256: 6b06a0bcf4764df38204ad2c7362d4a8196eea4fdeb5b9b9c2cea8ef211b8a05

Contents?: true

Size: 1.04 KB

Versions: 31

Compression:

Stored size: 1.04 KB

Contents

module Vx
  module Builder
    class BuildConfiguration
      class Env

        attr_reader :attributes

        def initialize(new_env)
          normalize_attributes(new_env)
        end

        def matrix
          @attributes["matrix"]
        end

        def global
          @attributes["global"]
        end

        private

          def normalize_attributes(new_env)

            @attributes =
              case new_env
              when String
                {
                  "matrix" => [],
                  "global" => Array(new_env)
                }
              when Hash
                {
                  "matrix" => Array(new_env['matrix']),
                  "global" => Array(new_env['global'])
                }
              else
                env = Array(new_env).flatten.map(&:to_s)
                if env.size == 1
                  { "matrix" => [], "global" => env }
                else
                  { "matrix" => env, "global" => [] }
                end
              end

          end

      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
vx-builder-0.3.10 lib/vx/builder/build_configuration/env.rb
vx-builder-0.3.9 lib/vx/builder/build_configuration/env.rb
vx-builder-0.3.8 lib/vx/builder/build_configuration/env.rb
vx-builder-0.3.7 lib/vx/builder/build_configuration/env.rb
vx-builder-0.3.6 lib/vx/builder/build_configuration/env.rb
vx-builder-0.3.5 lib/vx/builder/build_configuration/env.rb
vx-builder-0.3.4 lib/vx/builder/build_configuration/env.rb
vx-builder-0.3.3 lib/vx/builder/build_configuration/env.rb
vx-builder-0.3.2 lib/vx/builder/build_configuration/env.rb
vx-builder-0.3.1 lib/vx/builder/build_configuration/env.rb
vx-builder-0.3.0 lib/vx/builder/build_configuration/env.rb