summaryrefslogtreecommitdiff
path: root/lib/config.rb
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-01-06 19:50:45 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-01-06 19:50:45 -0500
commit7edb003cd1c9b53ffdff11ef85532e39f08db16d (patch)
tree180db82a4af7720508ae2732393401bf4d27cadf /lib/config.rb
parent7d875df65221d4da91953cf129a03e76fe8e5d29 (diff)
wip
Diffstat (limited to 'lib/config.rb')
-rw-r--r--lib/config.rb48
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