Method: Nugrant::Helper::Env::Exporter.script_exporter
- Defined in:
- lib/nugrant/helper/env/exporter.rb
permalink .script_exporter(bag, options = {}) ⇒ side-effect
Creates a bash script containing the commands that are required to export or unset a bunch of environment variables taken from the bag.
Options:
* :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 script 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.
* :script_path => The path where to write the script, defaults to `./nugrant2env.sh`.
* :type => The type of command, default to :export.
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/nugrant/helper/env/exporter.rb', line 72 def self.script_exporter(bag, = {}) io = [:io] || (File.open(File.([:script_path] || DEFAULT_SCRIPT_PATH), "w")) io.puts("#!/bin/env sh") io.puts() terminal_exporter(bag, .merge({:io => io})) ensure io.close() if io end |