ddr-models 2.1.3 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1430e93b8963381b076346eff749cbed263f9f46
4
- data.tar.gz: 91512912b2cad1883784935c071de7623e7decf0
3
+ metadata.gz: a90b6b484b6697d1ad016c930eeebcca01553d96
4
+ data.tar.gz: 7f93536de4484e564686f604303e9193a4c70bb4
5
5
  SHA512:
6
- metadata.gz: f52379fe84b0dd8f95b369a679947ee6e5ea77352a6910cb3703d06c79cb8d047d74d35df0648efb61787d4adc22598251cf1e07d71e195e377e55ee33be3692
7
- data.tar.gz: 4a7d41733f36e0d9a7945ed61c8670bec811aa3f58ad7bd93aaabd027c66bbf8b1722188f914fd1e8ae81df2b5b5696ad2f14e37b88bba3f7d75f9171ee69e11
6
+ metadata.gz: 6e227e67b45a32c2102e65c086a1a14fb0871de553338978aa87c19f4ad4119f493402e6dd7f00a87a365627da76de94125350c77db80d71f34330605562b310
7
+ data.tar.gz: a744113b7618d494a07d0e5ba3e12fcb844dca2087388cb9546df6f906ea853a4a43b956a66e639ad3600df067cef833cae10c7ad849097013559d6f61ede171
@@ -1,22 +1,55 @@
1
+ require "nokogiri"
2
+
1
3
  module Ddr::Models
2
4
  class FindingAid
3
5
 
4
6
  attr_reader :ead_id
5
7
 
8
+ EAD_XMLNS = "urn:isbn:1-931666-22-9"
9
+
6
10
  def initialize(ead_id)
7
11
  @ead_id = ead_id
8
12
  end
9
13
 
10
14
  def url
11
- @url ||= doc.css("eadid").attr("url").text
15
+ doc.css("eadid").attr("url").text
12
16
  end
13
17
 
18
+ # The finding aid title
14
19
  def title
15
- @title ||= doc.css("titleproper").children.first.text.strip
20
+ doc.css("titleproper").children.first.text.strip
21
+ end
22
+
23
+ def repository
24
+ collection.xpath('ead:did/ead:repository/ead:corpname', ead: EAD_XMLNS).text
25
+ end
26
+
27
+ def collection_date_span
28
+ collection.xpath('ead:did/ead:unitdate[@type="inclusive"]', ead: EAD_XMLNS).text
29
+ end
30
+
31
+ def collection_number
32
+ collection.xpath('ead:did/ead:unitid', ead: EAD_XMLNS).text
33
+ end
34
+
35
+ def collection_title
36
+ collection.xpath('ead:did/ead:unittitle', ead: EAD_XMLNS).text
37
+ end
38
+
39
+ def extent
40
+ collection.xpath('ead:did/ead:physdesc/ead:extent', ead: EAD_XMLNS).map(&:text).join("; ")
41
+ end
42
+
43
+ def abstract
44
+ collection.xpath('ead:did/ead:abstract', ead: EAD_XMLNS).text
16
45
  end
17
46
 
18
47
  private
19
48
 
49
+ def collection
50
+ doc.xpath('//ead:archdesc[@level="collection"]', ead: EAD_XMLNS)
51
+ end
52
+
20
53
  # @raise [OpenURI::HTTPError] if 404, etc.
21
54
  def doc
22
55
  @doc ||= Nokogiri::XML(open(ead_xml_url))
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "2.1.3"
3
+ VERSION = "2.2.0"
4
4
  end
5
5
  end
@@ -15,15 +15,32 @@ module Ddr::Models
15
15
  findaidstatus="published"
16
16
  langencoding="iso639-2b"
17
17
  repositoryencoding="iso15511">
18
- <eadid url="http://example.com/ead/">ead</eadid>
19
- <filedesc>
20
- <titlestmt>
21
- <titleproper>Guide to the Perplexed
22
- <num>00001</num>
23
- </titleproper>
24
- </titlestmt>
25
- </filedesc>
18
+ <eadid url="http://example.com/ead/">ead</eadid>
19
+ <filedesc>
20
+ <titlestmt>
21
+ <titleproper>Guide to the Perplexed
22
+ <num>00001</num>
23
+ </titleproper>
24
+ </titlestmt>
25
+ </filedesc>
26
26
  </eadheader>
27
+ <archdesc level="collection">
28
+ <did>
29
+ <repository>
30
+ <corpname>Library of the Perplexed</corpname>
31
+ </repository>
32
+ <unittitle>Perplexities</unittitle>
33
+ <unitid>RL.00327</unitid>
34
+ <physdesc altrender="whole">
35
+ <extent altrender="materialtype spaceoccupied">6.5 Linear Feet</extent>
36
+ </physdesc>
37
+ <unitdate normal="1876/1953" type="inclusive">1876-1953</unitdate>
38
+ <abstract>Abstract of Perplexities.</abstract>
39
+ <physdesc id="aspace_foobar">
40
+ <extent>4000 Items</extent>
41
+ </physdesc>
42
+ </did>
43
+ </archdesc>
27
44
  </ead>
28
45
  EOS
29
46
  end
@@ -34,6 +51,12 @@ EOS
34
51
 
35
52
  its(:title) { is_expected.to eq("Guide to the Perplexed") }
36
53
  its(:url) { is_expected.to eq("http://example.com/ead/") }
54
+ its(:repository) { is_expected.to eq("Library of the Perplexed") }
55
+ its(:collection_date_span) { is_expected.to eq("1876-1953") }
56
+ its(:collection_number) { is_expected.to eq("RL.00327") }
57
+ its(:collection_title) { is_expected.to eq("Perplexities") }
58
+ its(:extent) { is_expected.to eq("6.5 Linear Feet; 4000 Items") }
59
+ its(:abstract) { is_expected.to eq("Abstract of Perplexities.") }
37
60
 
38
61
  end
39
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-15 00:00:00.000000000 Z
12
+ date: 2015-10-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails