diff options
Diffstat (limited to 'lib/config.rb')
-rw-r--r-- | lib/config.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/config.rb b/lib/config.rb new file mode 100644 index 0000000..b22eedf --- /dev/null +++ b/lib/config.rb @@ -0,0 +1,48 @@ +# coding: utf-8 +require 'yaml' + +require 'uri' + +class Config + def self.get + return @config ||= Config::new('config.yaml') + end + def initialize(filename) + @data = YAML::load(File::read(filename)) + end + def url + return @url ||= URI::parse(@data['url']) + end + def html_suffixes + return @data['html_suffixes'] + end + # Licenses + def default_license + return @default_license ||= @data['default_license'] + end + def license_uri(name) + str = @data['license_uris'][name] + if str.nil? + return nil + end + return URI::parse(str) + end + # People + def default_author + return @default_person ||= @data['default_author'] + end + def person_uri(name) + str = @data['person_uris'][name] + if str.nil? + return nil + end + return URI::parse(str) + end + def person_email(name) + return @data['person_emails'][name] + end + # Tags + def tag_name(abbr) + return @data['tag_names'][abbr] + end +end |