Method: Nugrant::Helper::Env::Exporter.export_command

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

.export_command(key, value, options = {}) ⇒ Object

Returns a string representation of the command that needs to be used on the current platform to export an environment variable.

Options:

* :escape_value (true) => If true, escape the value to export.

Parameters:

  • key

    The key of the environment variable to export. It cannot be nil.

  • value

    The value of the environment variable to export

Returns:

  • The export command, as a string

[View source]

170
171
172
173
174
175
176
# File 'lib/nugrant/helper/env/exporter.rb', line 170

def self.export_command(key, value, options = {})
  value = value.to_s()
  value = Shellwords.escape(value) if options[:escape_value] == nil || options[:escape_value]

  # TODO: Handle platform differently
  "export #{key}=#{value}"
end