class Dip::RunVars
Attributes
env[RW]
argv[R]
env[R]
Public Class Methods
call(*args)
click to toggle source
# File lib/dip/run_vars.rb, line 10 def call(*args) new(*args).call end
new(argv, env = ENV)
click to toggle source
# File lib/dip/run_vars.rb, line 17 def initialize(argv, env = ENV) @argv = argv @env = env end
Public Instance Methods
call()
click to toggle source
# File lib/dip/run_vars.rb, line 22 def call populate_env_vars parse_argv end
Private Instance Methods
early_envs()
click to toggle source
# File lib/dip/run_vars.rb, line 53 def early_envs @early_envs ||= env["DIP_EARLY_ENVS"].to_s.split(",") end
ignore_var?(key)
click to toggle source
# File lib/dip/run_vars.rb, line 57 def ignore_var?(key) key.start_with?("DIP_", "_") end
parse_argv()
click to toggle source
# File lib/dip/run_vars.rb, line 39 def parse_argv stop_parse = false argv.each_with_object([]) do |arg, memo| if !stop_parse && arg.include?("=") key, val = arg.split("=", 2) self.class.env[key] = val else memo << arg stop_parse ||= true end end end
populate_env_vars()
click to toggle source
# File lib/dip/run_vars.rb, line 29 def populate_env_vars return if early_envs.empty? (env.keys - early_envs).each do |key| next if ignore_var?(key) self.class.env[key] = env[key] end end