Sha256: b42eb618af7f27d009bb33fc3e4097562a8a4d4c1b30f22979de6ef98fb2d8bc

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require 'itrigga/config/configuration'

raise ArgumentError.new("you must define ITRIGGA_APP_NAME if you're going to use itrigga/config/environment") unless defined?(ITRIGGA_APP_NAME)
puts "initialising itrigga-config for '#{ITRIGGA_APP_NAME}' app"

app_name_upper = ITRIGGA_APP_NAME.upcase
app_name_lower = ITRIGGA_APP_NAME.downcase
config_file_env_var_name = "#{app_name_upper}_CONFIG_FILE"

param = ARGV.find{|a| a.match(/--#{app_name_lower}-config-file=(.*)/)}
given_file = param ? param.gsub(/--#{app_name_lower}-config-file=(.*)/, '\1') : nil

ITRIGGA_CONFIG = Itrigga::Config::Configuration.instance()
[ given_file, ENV["#{app_name_upper}_CONFIG_FILE"], "/etc/#{app_name_lower}_config_file" ].compact.each { |f|
  puts "looking for file #{f}" if f
  if File.exists?(f)
    true_path = (File.symlink?(f) ? File.readlink(f) : f)
    puts "loading #{app_name_lower} config file #{true_path}"
    ITRIGGA_CONFIG.from_file(true_path) 
    break
  else 
    puts "#{f} doesn't exist"
  end 
}

# silence warnings, before we load the convenient Rails silence_warnings method:
old_verbose = $VERBOSE
$VERBOSE = false
begin
  ITRIGGA_CONFIG.constants.each { |k,v|  eval("#{k}='#{v}'") }
ensure
  $VERBOSE = old_verbose
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
itrigga-config-0.0.8 lib/itrigga/config/environment.rb
itrigga-config-0.0.7 lib/itrigga/config/environment.rb
itrigga-config-0.0.6 lib/itrigga/config/environment.rb
itrigga-config-0.0.5 lib/itrigga/config/environment.rb