Top Level Namespace

Defined Under Namespace

Modules: Sinatra Classes: Asset, SRAS, Version

Instance Method Summary collapse

Instance Method Details

#load_config_file(config_file = nil) ⇒ Object

load config file



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sras/helpers/config.rb', line 5

def load_config_file(config_file=nil)
    if config_file.nil?
        if File.exists?("#{ROOT}/config/config.yml")
            config_file = "#{ROOT}/config/config.yml"
        elsif File.exists?(File.expand_path('~/.srasrc'))
            config_file = File.expand_path('~/.srasrc')
        elsif File.exists('/etc/sras/sras.conf')
            config_file = '/etc/sras/sras.conf'
        else
            warn "Couldn't find SRAS config file.  Exiting."
            exit 1
        end
    end

    begin
        return YAML.load_file(config_file) 
    rescue
        abort "Oops.  Couldn't open config file #{config_file} ...  Aborting."
    end
end