Sha256: 5fe4547a5b400bd23dfd4c3887f59f61d6d70783fd40ada232961a8ee9e2cceb

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

module Vx
  module Builder
    class BuildConfiguration
      class Artifacts

        attr_reader :attributes

        def initialize(new_env)
          normalize_attributes(new_env)
        end

        def attributes
          @attributes
        end

        def files
          @files
        end

        def prefix
          @options[:prefix]
        end

        private

          def normalize_attributes(new_env)
            attrs =
              case new_env
              when Array
                new_env
              else
                Array(new_env)
              end

            extract_options_and_normalize_items(attrs)
          end

          def extract_options_and_normalize_items(new_env)
            opts = {}
            @attributes = []
            @files      = []
            env = new_env.inject([]) do |a, e|
              if e.is_a?(Hash)
                opts = e
                @attributes.push e
              else
                a.push e.to_s.gsub(/^\.*(\/)/, '')
                @attributes.push a.last
                @files.push a.last
              end
              a
            end

            if opts && opts["prefix"]
              @options = { prefix: opts["prefix"] }
            else
              @options = {}
            end

            [opts, env]

          end

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
vx-builder-0.2.2 lib/vx/builder/build_configuration/artifacts.rb
vx-builder-0.2.1 lib/vx/builder/build_configuration/artifacts.rb
vx-builder-0.2.0 lib/vx/builder/build_configuration/artifacts.rb
vx-builder-0.1.8 lib/vx/builder/build_configuration/artifacts.rb
vx-builder-0.1.7 lib/vx/builder/build_configuration/artifacts.rb
vx-builder-0.1.6 lib/vx/builder/build_configuration/artifacts.rb
vx-builder-0.1.5 lib/vx/builder/build_configuration/artifacts.rb
vx-builder-0.1.4 lib/vx/builder/build_configuration/artifacts.rb
vx-builder-0.1.3 lib/vx/builder/build_configuration/artifacts.rb
vx-builder-0.1.2 lib/vx/builder/build_configuration/artifacts.rb