Sha256: 0f82a865411b9180de13dbcc76adb0056897fdcc727e0438d3115c7ed48fa381

Contents?: true

Size: 938 Bytes

Versions: 56

Compression:

Stored size: 938 Bytes

Contents

# encoding: utf-8
module FeduxOrgStdlib
  # Enviroment helpers
  #
  # @deprecated Please use https://github.com/cucumber/aruba instead
  module Environment
    # Set environment variable for code block
    #
    # @param [Hash] new_environment_variables
    #   the variables which should be set for that environment
    #
    # @param [Hash] options
    #   options for environment manipulation
    #
    # @option options [True,False] :clear
    #   Should the environment clear before merge?
    #
    # @yield
    #   the block which should be run which the change environment
    def isolated_environment(new_environment_variables, options = {}, &block)
      old_environment = ENV.to_hash

      ENV.clear if options[:clear] == true
      ENV.update new_environment_variables

      block.call
    ensure
      ENV.clear
      ENV.update old_environment
    end

    alias_method :with_environment, :isolated_environment
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.10.6 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.10.5 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.10.4 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.10.3 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.10.2 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.10.1 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.10.0 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.9.8 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.9.7 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.9.6 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.9.5 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.9.4 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.9.2 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.9.1 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.9.0 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.8.11 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.8.10 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.8.9 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.8.8 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.8.7 lib/fedux_org_stdlib/environment.rb