blob: 944acc3b4596438937d0050570a21d7d9f2c0839 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# 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)
return URI::parse(@data['license_uris'][name])
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
# Categories
def category_name(abbr)
@categories ||= (@data['categories'] || {}).map{|k,v|[k.downcase,v]}.to_h
return @categories[abbr.downcase]
end
end
|