ddr-core 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 065474e311bb6fd9a3e68160663e2ff260e4a54bb776ca99b48aa495c661f640
4
- data.tar.gz: c7feea4281623cece301fc5737b345a813e4209093653e434815e98dd7497925
3
+ metadata.gz: 7f1841e5ee3adc06edb3fd81c96df0e290ee3745950a87f444f068dc5c48aff4
4
+ data.tar.gz: 2f8eae3c291037d51c8053328aa860518252bbff522adc75e928149c971ff585
5
5
  SHA512:
6
- metadata.gz: 1da3b51a355114e10ef605f394eabc2e9da4fbaaf559dd4bb339f5267c309ecd8c78b11f1cedf7a64e71db03f28f1f6722855b9925b89c5cccc0e2974a52ddb9
7
- data.tar.gz: 00f40e7bb02b46faa8acb4f6da8789d224591f0f5ef98431c764c7be2cd8d4af3c4f9b9669579507c82dfd52015508f0f79f2ab1f279d90f05603f9c5866c12d
6
+ metadata.gz: b595d3c404aae7945c7b7cca2f3bf3a5abfecd0c4bb764d6f80aee27a16a0fad86329e653a9479c8dbd41c58f5e1881b35d9b0a71b351835bb1a4b3c8a6d70fd
7
+ data.tar.gz: e2a64a032a93c1730db2a5bcbce45bfb970f008d9d74b4ee26e89e5d5c456316cc042b88dd5781f54fc26e46ca49a383b75a5c0c9cb6990766e9235cca4e9727
@@ -1,19 +1,29 @@
1
1
  module Ddr
2
- class AdminSet < AuxiliaryResource
2
+ AdminSet = Struct.new(:code, :title, keyword_init: true) do
3
+
4
+ def self.config
5
+ @config ||= YAML.load_file(::File.expand_path('../../../config/aux/admin_set.yml', __dir__))
6
+ end
7
+
8
+ def self.keystore
9
+ @keystore ||= Hash[config.map { |entry| [entry['code'], new(entry).freeze] }].freeze
10
+ end
3
11
 
4
12
  def self.call(obj)
5
13
  find_by_code(obj.admin_set)
6
- rescue ActiveResource::ResourceNotFound => e
7
- raise Ddr::NotFoundError, e
8
14
  end
9
15
 
10
16
  def self.find_by_code(code)
11
17
  return unless code
12
- fetch(code) { new get(:find, code: code) }
18
+
19
+ keystore.fetch(code)
20
+
21
+ rescue KeyError => _
22
+ raise Ddr::NotFoundError, "AdminSet code '#{code}' not found."
13
23
  end
14
24
 
15
25
  def self.keys
16
- fetch("codes") { all.map(&:code) }
26
+ keystore.keys
17
27
  end
18
28
 
19
29
  def to_s
@@ -1,14 +1,23 @@
1
1
  module Ddr
2
- class Contact < AuxiliaryResource
2
+ Contact = Struct.new(:slug, :name, :short_name, :url, :phone, :email, :ask, keyword_init: true) do
3
+
4
+ def self.config
5
+ @config ||= YAML.load_file(::File.expand_path('../../../config/aux/contact.yml', __dir__))
6
+ end
7
+
8
+ def self.keystore
9
+ @keystore ||= Hash[config.map { |entry| [entry['slug'], new(entry).freeze] }].freeze
10
+ end
3
11
 
4
12
  def self.call(slug)
5
- new get(:find, slug: slug)
6
- rescue ActiveResource::ResourceNotFound => e
7
- raise Ddr::NotFoundError, e
13
+ keystore.fetch(slug)
14
+
15
+ rescue KeyError => _
16
+ raise Ddr::NotFoundError, "Contact slug '#{slug}' not found."
8
17
  end
9
18
 
10
19
  def self.keys
11
- all.map(&:slug)
20
+ keystore.keys
12
21
  end
13
22
 
14
23
  def to_s
@@ -1,21 +1,28 @@
1
1
  module Ddr
2
- class Language < AuxiliaryResource
2
+ Language = Struct.new(:code, :label, keyword_init: true) do
3
+
4
+ def self.config
5
+ @config ||= YAML.load_file(::File.expand_path('../../../config/aux/language.yml', __dir__))
6
+ end
7
+
8
+ def self.keystore
9
+ @keystore ||= Hash[config.map { |entry| [entry['code'], new(entry).freeze] }].freeze
10
+ end
3
11
 
4
12
  def self.call(obj)
5
- obj.language.map do |lang|
6
- find_by_code(lang)
7
- end
8
- rescue ActiveResource::ResourceNotFound => e
9
- raise Ddr::NotFoundError, e
13
+ obj.language.map { |lang| find_by_code(lang) }
10
14
  end
11
15
 
12
16
  def self.find_by_code(code)
13
17
  return unless code
14
- new get(:find, code: code)
18
+
19
+ keystore.fetch(code)
20
+ rescue KeyError => _
21
+ raise Ddr::NotFoundError, "Language code '#{code}' not found."
15
22
  end
16
23
 
17
24
  def self.codes
18
- all.map(&:code)
25
+ keystore.keys
19
26
  end
20
27
 
21
28
  def to_s
@@ -1,16 +1,25 @@
1
1
  module Ddr
2
- class RightsStatement < AuxiliaryResource
2
+ RightsStatement = Struct.new(:title, :url, :short_title, :feature, :reuse_text, keyword_init: true) do
3
+
4
+ def self.config
5
+ @config ||= YAML.load_file(::File.expand_path('../../../config/aux/rights_statement.yml', __dir__))
6
+ end
7
+
8
+ def self.keystore
9
+ @keystore ||= Hash[config.map { |entry| [entry['url'], new(entry).freeze] }].freeze
10
+ end
3
11
 
4
12
  def self.call(obj)
5
- if obj.rights.present?
6
- new get(:find, url: obj.rights.first)
7
- end
8
- rescue ActiveResource::ResourceNotFound => e
9
- raise Ddr::NotFoundError, e
13
+ return if obj.rights.empty?
14
+
15
+ keystore.fetch(obj.rights.first)
16
+
17
+ rescue KeyError => _
18
+ raise Ddr::NotFoundError, "Rights statement '#{obj.rights.first}' not found."
10
19
  end
11
20
 
12
21
  def self.keys
13
- all.map(&:url)
22
+ keystore.keys
14
23
  end
15
24
 
16
25
  def to_s
@@ -0,0 +1,26 @@
1
+ - code: dul_collections
2
+ title: DUL Collections
3
+
4
+ - code: duson
5
+ title: Duke University School of Nursing Digital Archive
6
+
7
+ - code: ebooks
8
+ title: Electronic Books
9
+
10
+ - code: nescent
11
+ title: 'NESCent: National Evolutionary Synthesis Center'
12
+
13
+ - code: dc
14
+ title: Digital Collections
15
+
16
+ - code: dvs
17
+ title: Data and Visualization Services
18
+
19
+ - code: rubenstein
20
+ title: Rubenstein Library
21
+
22
+ - code: duke_scholarship
23
+ title: Duke Scholarship
24
+
25
+ - code: researchdata
26
+ title: Duke Research Data
@@ -0,0 +1,87 @@
1
+ - slug: dvs
2
+ name: Data and Visualization Services
3
+ short_name: null
4
+ url: http://library.duke.edu/data/
5
+ phone: 919-660-5880
6
+ email: askdata@duke.edu
7
+ ask: null
8
+
9
+ - slug: libraries
10
+ name: Duke University Libraries
11
+ short_name: null
12
+ url: http://library.duke.edu
13
+ phone: 919-660-5880
14
+ email: askref@duke.edu
15
+ ask: http://library.duke.edu/research/ask
16
+
17
+ - slug: divinity
18
+ name: Divinity School Library
19
+ short_name: null
20
+ url: http://library.divinity.duke.edu/
21
+ phone: 919-660-3453
22
+ email: divlib@duke.edu
23
+ ask: http://library.divinity.duke.edu/ask-us
24
+
25
+ - slug: uarchives
26
+ name: Duke University Archives
27
+ short_name: University Archives
28
+ url: http://library.duke.edu/rubenstein/uarchives/
29
+ phone: 919-660-5822
30
+ email: uarchives@duke.edu
31
+ ask: http://library.duke.edu/rubenstein/uarchives/ask
32
+
33
+ - slug: humanrights
34
+ name: Human Rights Archive
35
+ short_name: null
36
+ url: http://library.duke.edu/rubenstein/human-rights/
37
+ phone: 919-660-5822
38
+ email: special-collections@duke.edu
39
+ ask: http://library.duke.edu/rubenstein/ask
40
+
41
+ - slug: hom
42
+ name: History of Medicine Collections
43
+ short_name: null
44
+ url: http://library.duke.edu/rubenstein/history-of-medicine/
45
+ phone: 919-684-8549
46
+ email: special-collections@duke.edu
47
+ ask: http://library.duke.edu/rubenstein/ask
48
+
49
+ - slug: franklin
50
+ name: John Hope Franklin Research Center
51
+ short_name: Franklin Research Center
52
+ url: http://library.duke.edu/rubenstein/franklin/
53
+ phone: 919-660-5922
54
+ email: franklin-collection@duke.edu
55
+ ask: http://library.duke.edu/rubenstein/ask
56
+
57
+ - slug: docarts
58
+ name: Archive of Documentary Arts
59
+ short_name: null
60
+ url: http://library.duke.edu/rubenstein/documentaryarts/
61
+ phone: 919-660-5822
62
+ email: special-collections@duke.edu
63
+ ask: http://library.duke.edu/rubenstein/ask
64
+
65
+ - slug: bingham
66
+ name: Sallie Bingham Center for Women's History & Culture
67
+ short_name: Bingham Center
68
+ url: http://library.duke.edu/rubenstein/bingham/
69
+ phone: 919-660-5967
70
+ email: cwhc@duke.edu
71
+ ask: http://library.duke.edu/rubenstein/ask
72
+
73
+ - slug: hartman
74
+ name: John W. Hartman Center for Sales, Advertising & Marketing History
75
+ short_name: Hartman Center
76
+ url: http://library.duke.edu/rubenstein/hartman/
77
+ phone: 919-660-5827
78
+ email: hartman-center@duke.edu
79
+ ask: http://library.duke.edu/rubenstein/hartman/ask
80
+
81
+ - slug: rubenstein
82
+ name: David M. Rubenstein Rare Book & Manuscript Library
83
+ short_name: Rubenstein Library
84
+ url: http://library.duke.edu/rubenstein/
85
+ phone: 919-660-5822
86
+ email: special-collections@duke.edu
87
+ ask: http://library.duke.edu/rubenstein/ask