lib/sinatra/envconf.rb
# Method that will be exported to the Sinatra app. It creates a setting
# for every key found in the YAML file plus config_env_var and config_location
# as explained above.
#
# @param env_var [String] the environment variable name
# return [NilClass] nothing
# @raise [Exception] any exception when reading or processing the yaml
#   file
Method that will be exported to the Sinatra app. It creates a setting
for every key found in the YAML file plus config_env_var and config_location
as explained above.
Method that will be exported to the Sinatra app . It creates a setting for every key found in the YAML file plus config_env_var and config_location as explained above .
def config_env_var(env_var)
      set :config_env_var, env_var
      cfg_location = config_file_location(env_var)
      set :config_location, cfg_location
      YAML.load_file(cfg_location).each do |k,v|
        opt = k.to_sym
        opt_val = v
        set opt, opt_val
      end
      nil
    rescue StandardError => e
      $stderr.puts "error when accessing config file #{e.message}" if logging?
      raise e
    end
def config_env_var ( env_var ) set :config_env_var , env_var cfg_location = config_file_location ( env_var ) set :config_location , cfg_location YAML . load_file ( cfg_location ) . each do | k , v | opt = k . to_sym opt_val = v set opt , opt_val end nil rescue StandardError => e $stderr . puts "error when accessing config file #{e.message}" if logging? raise e end
Method that will be exported to the Sinatra app.
Method that will be exported to the Sinatra app .
[Exception] any exception when reading or processing the yaml file
[ Exception ] any exception when reading or processing the yaml file
env_var
the environment variable name return [NilClass] nothing
the environment variable name return [ NilClass ] nothing