Module: Webhookdb::Envfixer
- Defined in:
- lib/webhookdb/envfixer.rb
Class Method Summary collapse
-
.merge_heroku_env(env) ⇒ Object
If MERGE_HEROKU_ENV, merge all of its environment vars into the current env.
-
.replace_localhost_for_docker(env) ⇒ Object
If DOCKER_DEV is set, replace ‘localhost’ urls with ‘host.docker.internal’.
Class Method Details
.merge_heroku_env(env) ⇒ Object
If MERGE_HEROKU_ENV, merge all of its environment vars into the current env
20 21 22 23 24 25 26 27 |
# File 'lib/webhookdb/envfixer.rb', line 20 def self.merge_heroku_env(env) return unless (heroku_app = env.fetch("MERGE_HEROKU_ENV", nil)) text = `heroku config -j --app=#{heroku_app}` json = Oj.load(text) json.each do |k, v| env[k] = v end end |
.replace_localhost_for_docker(env) ⇒ Object
If DOCKER_DEV is set, replace ‘localhost’ urls with ‘host.docker.internal’.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/webhookdb/envfixer.rb', line 6 def self.replace_localhost_for_docker(env) return unless env["DOCKER_DEV"] env.each do |k, v| begin localhost = URI(v).host == "localhost" rescue StandardError next end next unless localhost env[k] = v.gsub("localhost", "host.docker.internal") end end |