-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathloc_subauthority.rb
105 lines (95 loc) · 2.84 KB
/
loc_subauthority.rb
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
module Qa::Authorities::LocSubauthority
# @todo Rename to reflect that this is a URI encoded url fragement used only for searching.
def get_url_for_authority(authority)
if authorities.include?(authority) then authority_base_url
elsif vocabularies.include?(authority) then vocab_base_url
elsif datatypes.include?(authority) then datatype_base_url
elsif preservation.include?(authority) then vocab_preservation_base_url
end
end
# @note The returned value is the root directory of the URL. The graphicMaterials sub-authority
# has a "type" of vocabulary. https://id.loc.gov/vocabulary/graphicMaterials/tgm008083.html
# In some cases, this is plural and in others this is singular.
#
# @param authority [String] the LOC authority that matches one of the types
# @return [String]
#
# @note there is a relationship between the returned value and the encoded URLs returned by
# {#get_url_for_authority}.
def root_fetch_slug_for(authority)
validate_subauthority!(authority)
return "authorities" if authorities.include?(authority)
return "vocabulary" if vocabularies.include?(authority)
return "datatype" if datatypes.include?(authority)
return "vocabulary/preservation" if preservation.include?(authority)
end
def authorities
[
"subjects",
"names",
"classification",
"childrensSubjects",
"genreForms",
"performanceMediums"
]
end
def vocabularies # rubocop:disable Metrics/MethodLength
[
"graphicMaterials",
"organizations",
"relators",
"countries",
"ethnographicTerms",
"geographicAreas",
"languages",
"iso639-1",
"iso639-2",
"iso639-5",
"preservation",
"actionsGranted",
"agentType"
]
end
def datatypes
["edtf"]
end
def preservation # rubocop:disable Metrics/MethodLength
[
"contentLocationType",
"copyrightStatus",
"cryptographicHashFunctions",
"environmentCharacteristic",
"environmentPurpose",
"eventRelatedAgentRole",
"eventRelatedObjectRole",
"eventType",
"formatRegistryRole",
"hardwareType",
"inhibitorTarget",
"inhibitorType",
"objectCategory",
"preservationLevelRole",
"relationshipSubType",
"relationshipType",
"rightsBasis",
"rightsRelatedAgentRole",
"signatureEncoding",
"signatureMethod",
"softwareType",
"storageMedium"
]
end
private
def vocab_base_url
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2F"
end
def authority_base_url
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2F"
end
def datatype_base_url
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fdatatypes%2F"
end
def vocab_preservation_base_url
"cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F"
end
end