Sha256: 8c688688e9dda00f24287e78e330e12966007a39b96ccf25e13f11f61d3b8931

Contents?: true

Size: 633 Bytes

Versions: 28

Compression:

Stored size: 633 Bytes

Contents

module FeduxOrg
  module Stdlib
    module Environment

      # Set environment variable for code block
      #
      # @param [Hash] variables
      #   the variables which should be set for that environment
      #
      # @yield
      #   the block which should be run which the change environment
      def isolated_environment(variables, &block)
        #backup
        old_env = ENV.to_hash
        #change env
        ENV.update variables

        block_result = block.call

        #cleanup
        ENV.clear 
        #install backuped information
        ENV.update old_env

        block_result
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.0.33 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.32 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.31 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.30 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.29 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.28 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.26 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.25 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.24 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.23 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.22 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.21 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.20 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.19 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.17 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.16 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.14 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.13 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.12 lib/fedux_org/stdlib/environment.rb
fedux_org-stdlib-0.0.11 lib/fedux_org/stdlib/environment.rb