6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/filmrolls/metadata.rb', line 6
def self.load(io)
doc = YAML.load(io)
raise 'YAML input missing `author` key' unless doc.key?('author')
raise 'YAML input missing `author.name` key' unless doc['author'].key?('name')
raise "YAML input has invalid license `#{doc['license']}`" unless is_valid_license(doc['license'])
{
author: doc['author']['name'],
copyright: get_copyright(doc['author']['name'], doc['license']),
author_url: doc['license'].nil? ? nil : doc['author']['url'],
license_url: get_license_url(doc['license']),
marked: !is_public_domain(doc['license']),
usage_terms: get_usage_terms(doc['author']['name'], doc['license'])
}.delete_if { |k, v| v.nil? }
end
|