Method: Nugrant::Helper::Env::Exporter.autoenv_exporter

Defined in:
lib/nugrant/helper/env/exporter.rb

.autoenv_exporter(bag, options = {}) ⇒ side-effect

Creates an autoenv script containing the commands that are required to export or unset a bunch of environment variables taken from the bag.

Options:

* :autoenv_path => The path where to write the script, defaults to `./.env`.
* :escape_value => If true, escape the value to export (or unset), default to true.
* :io => The io where the command should be written, default to nil which create the autoenv on disk.
* :namer => The namer used to transform bag segments into variable name, default to Namer::default().
* :override => If true, variable a exported even when the override an existing env key, default to true.
* :type => The type of command, default to :export.

Parameters:

  • bag

    The bag to create the script for.

Returns:

  • (side-effect)

    Creates a script file containing commands to export or unset environment variables for bag.

[View source]

45
46
47
48
49
50
51
# File 'lib/nugrant/helper/env/exporter.rb', line 45

def self.autoenv_exporter(bag, options = {})
  io = options[:io] || (File.open(File.expand_path(options[:autoenv_path] || DEFAULT_AUTOENV_PATH), "w"))

  terminal_exporter(bag, options.merge({:io => io}))
ensure
  io.close() if io
end