module DockerSync::ConfigSerializer
Public Class Methods
default_deserializer_file(config_path)
click to toggle source
@param [String] config_path path to the yaml configuration to load @return [Object] returns a Yaml hashmap, expaneded by ENV vars
# File lib/docker-sync/config/config_serializer.rb, line 9 def default_deserializer_file(config_path) config_string = File.read(config_path) default_deserializer_string(config_string) end
default_deserializer_string(config_string)
click to toggle source
@param [String] config_string the configuration string inf yaml format @return [Object] a yaml hashmap
# File lib/docker-sync/config/config_serializer.rb, line 16 def default_deserializer_string(config_string) deserialize_config( expand_env_variables(config_string) ) end
Private Class Methods
deserialize_config(config_string)
click to toggle source
deserializes the configuration string, right now as a yaml formatted string @param [String] config_string @return [Object]
# File lib/docker-sync/config/config_serializer.rb, line 39 def deserialize_config(config_string) # noinspection RubyResolve YAML.load(config_string) end
expand_env_variables(config_string)
click to toggle source
Replaces our tokens, in this case all ENV variables we defined. Find those in the string an replace them with then values from our ENV, including the dotenv file @param [String] config_string @return [String]
# File lib/docker-sync/config/config_serializer.rb, line 26 def expand_env_variables(config_string) load_dotenv env_hash = {} ENV.each {|k,v| env_hash[k.to_sym] = v } config_string.gsub!('${', '%{') config_string % env_hash end
load_dotenv()
click to toggle source
Loads the dotenv file but also lets us overide the source not being .env but anything you put into the ENV variable DOCKER_SYNC_ENV_FILE @return [Object]
# File lib/docker-sync/config/config_serializer.rb, line 47 def load_dotenv # TODO: ensure we do this once only env_file = ENV.fetch('DOCKER_SYNC_ENV_FILE', '.env') # noinspection RubyResolve Dotenv.load(env_file) end