Sha256: 8ad41fbfa9041c7efff47a3c377ffb2e9811515a2308d32175a3873a12ccbc93

Contents?: true

Size: 847 Bytes

Versions: 1

Compression:

Stored size: 847 Bytes

Contents

# encoding: utf-8

module Rake
  module Delphi
    class EnvVariable
        attr_reader :name
        attr_accessor :value

        def initialize(name, value)
            @name, @value = name, value
        end
    end

    class EnvVariables < ::Array
        def initialize(regpath, delphidir)
            _dir = delphidir.gsub(/\/$/, '')
            add('DELPHI', _dir)
            add('BDS', _dir)
            expand_vars
        end

        def add(var, value)
            self << EnvVariable.new(var, value)
        end

        def expand(value)
            self.each do |ev|
                value.gsub!("$(#{ev.name})", ev.value)
            end
            value
        end

        def expand_vars
            self.map! do |v|
                v.value = expand(v.value)
                v
            end
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rake-delphi-0.0.4 lib/rake/delphi/envvariables.rb