Method: Nugrant::Helper::Env::Exporter.autoenv_exporter
- Defined in:
- lib/nugrant/helper/env/exporter.rb
permalink .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.
45 46 47 48 49 50 51 |
# File 'lib/nugrant/helper/env/exporter.rb', line 45 def self.autoenv_exporter(bag, = {}) io = [:io] || (File.open(File.([:autoenv_path] || DEFAULT_AUTOENV_PATH), "w")) terminal_exporter(bag, .merge({:io => io})) ensure io.close() if io end |