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.11.18 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.17 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.16 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.15 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.14 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.12 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.11 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.9 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.8 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.7 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.6 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.5 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.4 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.3 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.2 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.1 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.11.0 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.10.9 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.10.8 lib/fedux_org_stdlib/environment.rb
fedux_org-stdlib-0.10.7 lib/fedux_org_stdlib/environment.rb