Module: FeduxOrgStdlib::Environment Deprecated

Included in:
Command::RunCommand
Defined in:
lib/fedux_org_stdlib/environment.rb

Overview

Deprecated.

Please use github.com/cucumber/aruba instead

Enviroment helpers

Instance Method Summary collapse

Instance Method Details

#isolated_environment(new_environment_variables, options = {}) { ... } ⇒ Object Also known as: with_environment

Set environment variable for code block

Parameters:

  • new_environment_variables (Hash)

    the variables which should be set for that environment

  • options (Hash) (defaults to: {})

    options for environment manipulation

Options Hash (options):

  • :clear (True, False)

    Should the environment clear before merge?

Yields:

  • the block which should be run which the change environment



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fedux_org_stdlib/environment.rb', line 20

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