You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
653 B
42 lines
653 B
require "inifile"
|
|
|
|
class IniConfig
|
|
attr :path
|
|
|
|
def initialize(in_path = "config.ini")
|
|
@path = in_path
|
|
@config = {}
|
|
parse_ini
|
|
end
|
|
|
|
def parse_ini()
|
|
return if path.nil?
|
|
return unless File.exist? path
|
|
@config = IniFile.load(path)
|
|
end
|
|
|
|
def get_port()
|
|
unless @config["server"]["port"].nil?
|
|
@config["server"]["port"].to_i
|
|
else
|
|
8080
|
|
end
|
|
end
|
|
|
|
def get_repo()
|
|
unless @config["repo"]["repo"].nil?
|
|
@config["repo"]["repo"].to_s
|
|
else
|
|
"repo"
|
|
end
|
|
end
|
|
|
|
def get_db()
|
|
unless @config["server"]["db"].nil?
|
|
@config["server"]["db"].to_s
|
|
else
|
|
"db"
|
|
end
|
|
end
|
|
end
|