Class: Bwrap::Args::Environment
- Inherits:
-
Hash
- Object
- Hash
- Bwrap::Args::Environment
- Defined in:
- lib/bwrap/args/environment.rb
Overview
Environment variable calculation for bwrap.
Instance Attribute Summary collapse
-
#config ⇒ Object
writeonly
Instance of Config.
Instance Method Summary collapse
-
#add_to_path(elements) ⇒ Object
Adds given paths to PATH environment variable defined in the sandbox.
-
#env_paths ⇒ Array
All environment paths added via Config#add_env_path and other parsing logic.
-
#environment_variables ⇒ Object
Returns used environment variables wrapped as bwrap arguments.
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
Methods included from Output
debug?, debug_output, error_output, handle_output_options, info_output, quiet?, trace?, trace_output, verb_output, verbose?, warn_output
Methods included from Execution
do_execute, last_status, popen2e
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
15 16 17 18 19 |
# File 'lib/bwrap/args/environment.rb', line 15 def initialize super self["PATH"] ||= [] end |
Instance Attribute Details
#config=(value) ⇒ Object (writeonly)
Instance of Config.
13 14 15 |
# File 'lib/bwrap/args/environment.rb', line 13 def config=(value) @config = value end |
Instance Method Details
#add_to_path(elements) ⇒ Object
Adds given paths to PATH environment variable defined in the sandbox.
56 57 58 59 60 61 62 63 |
# File 'lib/bwrap/args/environment.rb', line 56 def add_to_path elements if elements.respond_to? :each self["PATH"] += elements else # Expecting elements to be single path element as a string. self["PATH"] << elements end end |
#env_paths ⇒ Array
Returns All environment paths added via Config#add_env_path and other parsing logic.
43 44 45 46 47 48 49 50 51 |
# File 'lib/bwrap/args/environment.rb', line 43 def env_paths if @config and @config.env_paths.respond_to? :each self["PATH"] |= @config.env_paths end features_env_paths self["PATH"] end |
#environment_variables ⇒ Object
Returns used environment variables wrapped as bwrap arguments.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bwrap/args/environment.rb', line 22 def environment_variables if debug? debug "Passing following environment variables to bwrap:\n" \ "#{self}" end env_paths # If nothing has been added to path, the map would result to empty --setenv. return self if empty? map do |key, value| if key == "PATH" and value.respond_to? :join value = value.join ":" end [ "--setenv", key, value ] end end |