class Metasploit::Yard::Aruba::RvmEnv::Prepend
Recognizes `export`s that are actually prepending values to the pre-existing value as is the case with `PATH`.
Constants
- REGEXP
Matches line with format `export <name>=<quote><value>$<name><quote>`. `<value>` will contain trailing `File::PATH_SEPARATOR`, so it can be directly prepended to the current value of `<name>` to get the value to set the environment variable.
Public Instance Methods
change(options={})
click to toggle source
Replaces {Metasploit::Yard::Aruba::RvmEnv::Export#value `:from` value} with {Metasploit::Yard::Aruba::RvmEnv::Export#value this variable's value}.
@param options [Hash{Symbol => Object}] @option options [Metasploit::Yard::Aruba::RvmEnv::Unset] :from the old state of this variable. @option options [Object] :world the cucumber world instance for the current scenario
# File lib/metasploit/yard/aruba/rvm_env/prepend.rb, line 18 def change(options={}) options.assert_valid_keys(:from, :world) from = options.fetch(:from) world = options.fetch(:world) from_directories = from.value.split(File::PATH_SEPARATOR) to_directories = value.split(File::PATH_SEPARATOR) path = ENV[name] to_directories.zip(from_directories) do |to_directory, from_directory| path = path.gsub(from_directory, to_directory) end world.set_env(name, path) end