Allow dynamic accessory files to reference declared ENVs
This commit is contained in:
@@ -74,12 +74,19 @@ class Mrsk::Configuration::Assessory
|
||||
|
||||
def expand_local_file(local_file)
|
||||
if local_file.end_with?("erb")
|
||||
read_dynamic_file(local_file)
|
||||
with_clear_env_loaded { read_dynamic_file(local_file) }
|
||||
else
|
||||
Pathname.new(File.expand_path(local_file)).to_s
|
||||
end
|
||||
end
|
||||
|
||||
def with_clear_env_loaded
|
||||
(env["clear"] || env).each { |k, v| ENV[k] = v }
|
||||
yield
|
||||
ensure
|
||||
(env["clear"] || env).each { |k, v| ENV.delete(k) }
|
||||
end
|
||||
|
||||
def read_dynamic_file(local_file)
|
||||
StringIO.new(ERB.new(IO.read(local_file)).result)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user