d598e4fd93
Enables frozen for the following: * lib/*.rb * lib/banzai/**/*.rb * lib/bitbucket/**/*.rb * lib/constraints/**/*.rb * lib/container_registry/**/*.rb * lib/declarative_policy/**/*.rb Partially addresses #47424.
19 lines
448 B
Ruby
19 lines
448 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ExpandVariables
|
|
class << self
|
|
def expand(value, variables)
|
|
# Convert hash array to variables
|
|
if variables.is_a?(Array)
|
|
variables = variables.reduce({}) do |hash, variable|
|
|
hash[variable[:key]] = variable[:value]
|
|
hash
|
|
end
|
|
end
|
|
|
|
value.gsub(/\$([a-zA-Z_][a-zA-Z0-9_]*)|\${\g<1>}|%\g<1>%/) do
|
|
variables[$1 || $2]
|
|
end
|
|
end
|
|
end
|
|
end
|