From 7edb003cd1c9b53ffdff11ef85532e39f08db16d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 6 Jan 2017 19:50:45 -0500 Subject: wip --- lib/config.rb | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 lib/config.rb (limited to 'lib/config.rb') 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 -- cgit v1.2.3