Sha256: abf68918f17e3a589248348a63240180a61464a71faefdc37e4ae13c3acb5a87

Contents?: true

Size: 1.01 KB

Versions: 14

Compression:

Stored size: 1.01 KB

Contents

require 'pdk'
require 'forwardable'

module PDK
  module Util
    class Env
      class WindowsEnv
        extend Forwardable

        # Note, these delegators may not have case insensitive keys
        def_delegators :env_hash, :fetch, :select, :reject

        def []=(key, value)
          PDK::Util::Windows::Process.set_environment_variable(key, value)
        end

        def key?(key)
          !env_hash.keys.find { |item| key.casecmp(item).zero? }.nil?
        end

        def [](key)
          env_hash.each do |item, value|
            next unless key.casecmp(item).zero?
            return value
          end
          nil
        end

        private

        def env_hash
          PDK::Util::Windows::Process.environment_hash
        end
      end

      class << self
        extend Forwardable

        def_delegators :implementation, :key?, :[], :[]=, :fetch, :select, :reject

        def implementation
          @implementation ||= Gem.win_platform? ? WindowsEnv.new : ENV
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pdk-2.7.1 lib/pdk/util/env.rb
pdk-2.7.0 lib/pdk/util/env.rb
pdk-2.6.1 lib/pdk/util/env.rb
pdk-2.6.0 lib/pdk/util/env.rb
pdk-2.5.0 lib/pdk/util/env.rb
pdk-2.3.0 lib/pdk/util/env.rb
pdk-2.2.0 lib/pdk/util/env.rb
pdk-2.1.1 lib/pdk/util/env.rb
pdk-2.1.0 lib/pdk/util/env.rb
pdk-2.0.0 lib/pdk/util/env.rb
pdk-1.18.1 lib/pdk/util/env.rb
pdk-1.18.0 lib/pdk/util/env.rb
pdk-1.17.0 lib/pdk/util/env.rb
pdk-1.16.0 lib/pdk/util/env.rb