ddr-models 2.1.0.rc1 → 2.1.0.rc2

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
  SHA1:
3
- metadata.gz: cb4f77d35e8d4b3d23267f2f32b6176f935d547d
4
- data.tar.gz: 15ac1cebb4342dde18d4e8bfab92749c69805add
3
+ metadata.gz: 60a46f8934fb0e5f4ffdf51e407c3a06f55ef8c7
4
+ data.tar.gz: 6f55b69df1b4a3339ebbe852df239efeda75c905
5
5
  SHA512:
6
- metadata.gz: 706dafc8320ac5bf5ae153fc963368c143b2a7ad0dbac3a1155751102b3398016a575dc4449c46753bdc45a568ff6872fe5d3526e21323cc0d15c7207af504f5
7
- data.tar.gz: 0309ef94db398e32ec350c0671108e5d5cca3406ad65ab71325da2eddc0581e3d7e788dee29767381b875859c204d5b5a705cee8b73ebee907f4789a36ce7462
6
+ metadata.gz: 6a3dc6282c61f4eeaa20a960a83ad28f4063938173820e914363af58b477c40f6d7a5ca8c3e0ddd6811d74f7de084ce363e5c94abee94c60edbced1211f6df74
7
+ data.tar.gz: bd639d6c6ca73ce6e760c7917c6c29878de3a06dd4e134e4e5bd346a112530412cab2db1174c2b15afb6ef360b555a364098dbd7986dc9739eb0aa0c28a945a7
data/ddr-models.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
30
30
  s.add_dependency "rdf-vocab", "~> 0.8"
31
31
  s.add_dependency "net-ldap", "~> 0.11"
32
32
  s.add_dependency "cancancan", "~> 1.12"
33
- s.add_dependency "ddr-aux-client", "~> 1.1"
33
+ s.add_dependency "ddr-aux-client", "~> 1.2", ">= 1.2.1"
34
34
  s.add_dependency "ddr-antivirus", "2.0.0"
35
35
 
36
36
  s.add_development_dependency "bundler", "~> 1.7"
@@ -43,6 +43,9 @@ module Ddr
43
43
  property :license,
44
44
  predicate: RDF::DC.license
45
45
 
46
+ property :ead_id,
47
+ predicate: Ddr::Vocab::Asset.eadId
48
+
46
49
  end
47
50
  end
48
51
  end
@@ -7,6 +7,12 @@ module Ddr::Index
7
7
  const_get(name.to_s.upcase, false)
8
8
  end
9
9
 
10
+ def self.techmd
11
+ constants(false)
12
+ .select { |c| c =~ /\ATECHMD_/ }
13
+ .map { |c| const_get(c) }
14
+ end
15
+
10
16
  ID = UniqueKeyField.instance
11
17
  PID = UniqueKeyField.instance
12
18
 
@@ -26,6 +32,7 @@ module Ddr::Index
26
32
  DEPOSITOR = Field.new :depositor, :stored_sortable
27
33
  DISPLAY_FORMAT = Field.new :display_format, :stored_sortable
28
34
  DOI = Field.new :doi, :symbol
35
+ EAD_ID = Field.new :ead_id, :stored_sortable
29
36
  EXTRACTED_TEXT = Field.new :extracted_text, :searchable, type: :text
30
37
  HAS_MODEL = Field.new :has_model, :symbol
31
38
  IDENTIFIER_ALL = Field.new :identifier_all, :symbol
@@ -11,7 +11,6 @@ module Ddr::Managers
11
11
  :image_width, :image_height, :color_space,
12
12
  to: :fits
13
13
 
14
- alias_method :file_size, :extent
15
14
  alias_method :last_modified, :modified
16
15
 
17
16
  def fits?
data/lib/ddr/models.rb CHANGED
@@ -31,6 +31,7 @@ module Ddr
31
31
  extend ActiveSupport::Autoload
32
32
 
33
33
  autoload :AccessControllable
34
+ autoload :AdminSet
34
35
  autoload :Base
35
36
  autoload :ChecksumInvalid, 'ddr/models/error'
36
37
  autoload :ContentModelError, 'ddr/models/error'
@@ -40,6 +41,7 @@ module Ddr
40
41
  autoload :Error
41
42
  autoload :EventLoggable
42
43
  autoload :FileManagement
44
+ autoload :FindingAid
43
45
  autoload :FixityCheckable
44
46
  autoload :Governable
45
47
  autoload :HasAdminMetadata
@@ -87,6 +89,10 @@ module Ddr
87
89
  alias :characterize_files? :characterize_files
88
90
  end
89
91
 
92
+ mattr_accessor :ead_xml_base_url do
93
+ "http://library.duke.edu/rubenstein/findingaids/"
94
+ end
95
+
90
96
  # Yields an object with module configuration accessors
91
97
  def self.configure
92
98
  yield self
@@ -0,0 +1,17 @@
1
+ require "ddr_aux/client"
2
+
3
+ module Ddr::Models
4
+ class AdminSet < DdrAux::Client::AdminSet
5
+
6
+ def self.call(obj)
7
+ if obj.admin_set
8
+ find(code: obj.admin_set)
9
+ end
10
+ end
11
+
12
+ def to_s
13
+ title
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ module Ddr::Models
2
+ class FindingAid
3
+
4
+ attr_reader :ead_id
5
+
6
+ def initialize(ead_id)
7
+ @ead_id = ead_id
8
+ end
9
+
10
+ def url
11
+ @url ||= doc.css("eadid").attr("url").text
12
+ end
13
+
14
+ def title
15
+ @title ||= doc.css("titleproper").children.first.text.strip
16
+ end
17
+
18
+ private
19
+
20
+ # @raise [OpenURI::HTTPError] if 404, etc.
21
+ def doc
22
+ @doc ||= Nokogiri::XML(open(ead_xml_url))
23
+ end
24
+
25
+ def ead_xml_url
26
+ Ddr::Models.ead_xml_base_url + ead_id + ".xml"
27
+ end
28
+
29
+ end
30
+ end
@@ -19,6 +19,7 @@ module Ddr::Models
19
19
  :permanent_url,
20
20
  :research_help_contact,
21
21
  :workflow_state,
22
+ :ead_id,
22
23
  datastream: "adminMetadata",
23
24
  multiple: false
24
25
 
@@ -74,6 +75,12 @@ module Ddr::Models
74
75
  InheritedLicense.call(self)
75
76
  end
76
77
 
78
+ def finding_aid
79
+ if ead_id
80
+ FindingAid.new(ead_id)
81
+ end
82
+ end
83
+
77
84
  private
78
85
 
79
86
  def update_permanent_id_on_destroy
@@ -20,6 +20,7 @@ module Ddr
20
20
  DEPOSITOR => depositor,
21
21
  DISPLAY_FORMAT => display_format,
22
22
  DOI => adminMetadata.doi,
23
+ EAD_ID => ead_id,
23
24
  IDENTIFIER_ALL => all_identifiers,
24
25
  INTERNAL_URI => internal_uri,
25
26
  LICENSE => license,
@@ -1,37 +1,20 @@
1
- require "ostruct"
2
1
  require "ddr_aux/client"
3
2
 
4
3
  module Ddr::Models
5
- class License < SimpleDelegator
4
+ class License < DdrAux::Client::License
6
5
 
7
- class << self
8
- def get(url)
9
- new DdrAux::Client.find_license(url: url)
10
- end
11
-
12
- def all
13
- DdrAux::Client.licenses.map { |l| new(l) }
14
- end
6
+ attr_accessor :pid
15
7
 
16
- def call(obj)
17
- if obj.license
18
- l = get obj.license
19
- l[:licensed] = obj.pid
20
- l
21
- end
8
+ def self.call(obj)
9
+ if obj.license
10
+ license = find(url: obj.license)
11
+ license.pid = obj.pid
12
+ license
22
13
  end
23
14
  end
24
15
 
25
- def initialize(args={})
26
- super OpenStruct.new(args)
27
- end
28
-
29
- def to_json
30
- to_h.to_json
31
- end
32
-
33
- def ==(other)
34
- other.is_a?(self.class) && other.__getobj__ == __getobj__
16
+ def to_s
17
+ title
35
18
  end
36
19
 
37
20
  end
@@ -209,6 +209,13 @@ module Ddr::Models
209
209
  struct_map_docs(type).map { |doc| doc.multires_image_file_path }.compact
210
210
  end
211
211
 
212
+ # DRY HasAdminMetadata
213
+ def finding_aid
214
+ if ead_id
215
+ FindingAid.new(ead_id)
216
+ end
217
+ end
218
+
212
219
  private
213
220
 
214
221
  def targets_query
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "2.1.0.rc1"
3
+ VERSION = "2.1.0.rc2"
4
4
  end
5
5
  end
@@ -15,6 +15,9 @@
15
15
  label: "Administrative Set",
16
16
  comment: "A name under which objects (principally collections) are grouped for administrative purposes."
17
17
 
18
+ property "eadId",
19
+ label: "EAD ID"
20
+
18
21
  end
19
22
  end
20
23
  end
@@ -0,0 +1,25 @@
1
+ module Ddr::Models
2
+ RSpec.describe AdminSet do
3
+
4
+ describe ".call" do
5
+ subject { described_class.call(obj) }
6
+
7
+ describe "when the object has an admin set" do
8
+ let(:obj) { double(admin_set: "dvs") }
9
+ before do
10
+ allow(described_class).to receive(:find).with(code: "dvs") do
11
+ described_class.new("id"=>1, "code"=>"dvs", "title"=>"Data and Visualization Services", "created_at"=>"2015-09-15T16:15:58.514Z", "updated_at"=>"2015-09-15T16:15:58.514Z")
12
+ end
13
+ end
14
+
15
+ its(:to_s) { is_expected.to eq("Data and Visualization Services") }
16
+ end
17
+
18
+ describe "when the object does not have an admin set" do
19
+ let(:obj) { double(admin_set: nil) }
20
+ it { is_expected.to be_nil }
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -7,10 +7,11 @@ module Ddr::Models
7
7
  let(:obj) { mock.new }
8
8
 
9
9
  let(:url) { "https://creativecommons.org/licenses/by-nc-nd/4.0/" }
10
+
10
11
  let(:license) { License.new(url: url) }
11
- before { allow(License).to receive(:get).with(url) { license } }
12
+ before { allow(License).to receive(:find).with(url: url) { license } }
12
13
 
13
- describe "when the object has a licence" do
14
+ describe "when the object has a license" do
14
15
  before { obj.license = url }
15
16
  it { is_expected.to eq(license) }
16
17
  end
@@ -0,0 +1,39 @@
1
+ module Ddr::Models
2
+ RSpec.describe FindingAid do
3
+
4
+ subject { described_class.new("ead") }
5
+
6
+ let(:ead_xml) do
7
+ <<-EOS
8
+ <?xml version="1.0" encoding="UTF-8"?>
9
+ <ead xmlns="urn:isbn:1-931666-22-9"
10
+ xmlns:xlink="http://www.w3.org/1999/xlink"
11
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
12
+ xsi:schemaLocation="urn:isbn:1-931666-22-9 http://www.loc.gov/ead/ead.xsd">
13
+ <eadheader countryencoding="iso3166-1"
14
+ dateencoding="iso8601"
15
+ findaidstatus="published"
16
+ langencoding="iso639-2b"
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>
26
+ </eadheader>
27
+ </ead>
28
+ EOS
29
+ end
30
+
31
+ before do
32
+ allow(subject).to receive(:doc) { Nokogiri::XML(ead_xml) }
33
+ end
34
+
35
+ its(:title) { is_expected.to eq("Guide to the Perplexed") }
36
+ its(:url) { is_expected.to eq("http://example.com/ead/") }
37
+
38
+ end
39
+ end
@@ -0,0 +1,24 @@
1
+ module Ddr::Models
2
+ RSpec.describe License do
3
+
4
+ describe ".call" do
5
+ subject { described_class.call(obj) }
6
+
7
+ describe "when the object has a license URL" do
8
+ let(:url) { "http://example.com" }
9
+ let(:obj) { double(pid: "test:1", license: url) }
10
+ before do
11
+ allow(described_class).to receive(:find).with(url: url) { described_class.new(url: url, title: "A License") }
12
+ end
13
+ its(:pid) { is_expected.to eq("test:1") }
14
+ its(:to_s) { is_expected.to eq("A License") }
15
+ end
16
+
17
+ describe "when the object does not have a license" do
18
+ let(:obj) { double(pid: "test:1", license: nil) }
19
+ it { is_expected.to be_nil }
20
+ end
21
+ end
22
+
23
+ end
24
+ 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.0.rc1
4
+ version: 2.1.0.rc2
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-09-17 00:00:00.000000000 Z
12
+ date: 2015-09-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -191,14 +191,20 @@ dependencies:
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '1.1'
194
+ version: '1.2'
195
+ - - ">="
196
+ - !ruby/object:Gem::Version
197
+ version: 1.2.1
195
198
  type: :runtime
196
199
  prerelease: false
197
200
  version_requirements: !ruby/object:Gem::Requirement
198
201
  requirements:
199
202
  - - "~>"
200
203
  - !ruby/object:Gem::Version
201
- version: '1.1'
204
+ version: '1.2'
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: 1.2.1
202
208
  - !ruby/object:Gem::Dependency
203
209
  name: ddr-antivirus
204
210
  requirement: !ruby/object:Gem::Requirement
@@ -477,6 +483,7 @@ files:
477
483
  - lib/ddr/metadata/premis_event.rb
478
484
  - lib/ddr/models.rb
479
485
  - lib/ddr/models/access_controllable.rb
486
+ - lib/ddr/models/admin_set.rb
480
487
  - lib/ddr/models/base.rb
481
488
  - lib/ddr/models/describable.rb
482
489
  - lib/ddr/models/effective_license.rb
@@ -484,6 +491,7 @@ files:
484
491
  - lib/ddr/models/error.rb
485
492
  - lib/ddr/models/event_loggable.rb
486
493
  - lib/ddr/models/file_management.rb
494
+ - lib/ddr/models/finding_aid.rb
487
495
  - lib/ddr/models/fixity_checkable.rb
488
496
  - lib/ddr/models/governable.rb
489
497
  - lib/ddr/models/has_admin_metadata.rb
@@ -614,6 +622,7 @@ files:
614
622
  - spec/managers/technical_metadata_manager_spec.rb
615
623
  - spec/models/active_fedora_base_spec.rb
616
624
  - spec/models/active_fedora_datastream_spec.rb
625
+ - spec/models/admin_set_spec.rb
617
626
  - spec/models/attachment_spec.rb
618
627
  - spec/models/collection_spec.rb
619
628
  - spec/models/component_spec.rb
@@ -621,11 +630,13 @@ files:
621
630
  - spec/models/effective_license_spec.rb
622
631
  - spec/models/events_spec.rb
623
632
  - spec/models/file_management_spec.rb
633
+ - spec/models/finding_aid_spec.rb
624
634
  - spec/models/has_admin_metadata_spec.rb
625
635
  - spec/models/has_children_spec.rb
626
636
  - spec/models/has_struct_metadata_spec.rb
627
637
  - spec/models/indexing_spec.rb
628
638
  - spec/models/item_spec.rb
639
+ - spec/models/license_spec.rb
629
640
  - spec/models/solr_document_spec.rb
630
641
  - spec/models/struct_div_spec.rb
631
642
  - spec/models/structure_spec.rb
@@ -775,6 +786,7 @@ test_files:
775
786
  - spec/managers/technical_metadata_manager_spec.rb
776
787
  - spec/models/active_fedora_base_spec.rb
777
788
  - spec/models/active_fedora_datastream_spec.rb
789
+ - spec/models/admin_set_spec.rb
778
790
  - spec/models/attachment_spec.rb
779
791
  - spec/models/collection_spec.rb
780
792
  - spec/models/component_spec.rb
@@ -782,11 +794,13 @@ test_files:
782
794
  - spec/models/effective_license_spec.rb
783
795
  - spec/models/events_spec.rb
784
796
  - spec/models/file_management_spec.rb
797
+ - spec/models/finding_aid_spec.rb
785
798
  - spec/models/has_admin_metadata_spec.rb
786
799
  - spec/models/has_children_spec.rb
787
800
  - spec/models/has_struct_metadata_spec.rb
788
801
  - spec/models/indexing_spec.rb
789
802
  - spec/models/item_spec.rb
803
+ - spec/models/license_spec.rb
790
804
  - spec/models/solr_document_spec.rb
791
805
  - spec/models/struct_div_spec.rb
792
806
  - spec/models/structure_spec.rb