Initial commit
This commit is contained in:
41
classes/config.rb
Normal file
41
classes/config.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
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
|
||||
Reference in New Issue
Block a user