hydra-pbcore 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -20,4 +20,5 @@ test/version_tmp
20
20
  tmp/*
21
21
  !tmp/.gitkeep
22
22
  *.sw[opn]
23
- config/*
23
+ config/*
24
+ Gemfile.lock
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # HydraPbcore
2
2
 
3
3
  [![Build Status](https://travis-ci.org/awead/hydra-pbcore.png)](https://travis-ci.org/awead/hydra-pbcore)
4
+ [![Gem Version](https://badge.fury.io/rb/hydra-pbcore.png)](http://badge.fury.io/rb/hydra-pbcore)
4
5
 
5
6
  A Hydra gem that offers PBCore datastream definitions using OM, as well as some other convenience
6
7
  methods such as inserting xml templates into existing documents and reordering your PBCore xml
@@ -74,7 +75,9 @@ according to the PBCore XML v.2 schema:
74
75
 
75
76
  ## New Changes
76
77
 
77
- ### version 3.1
78
+ In 3.2, the `is_part_of` method should be used for inserting pcbcoreRelation nodes instead of `insert_relation`.
79
+ There is also now a `HydraPbcore::Datastream::GenericFile` datastream with will allow you to create PBCore
80
+ xml OM datastreams with Sufia.
78
81
 
79
82
  As of 3.1, the pbcoreIdentifier is not included in the xml template. This is so users may add their own identifier,
80
83
  or multiple identifiers, with an optional annotation. Documents will require at least one pbcoreIdentifier in order to
@@ -2,4 +2,5 @@ module HydraPbcore::Datastream
2
2
  extend ActiveSupport::Autoload
3
3
  autoload :Document
4
4
  autoload :Instantiation
5
+ autoload :GenericFile
5
6
  end
@@ -100,9 +100,11 @@ class Document < ActiveFedora::OmDatastream
100
100
  t.arch_ser(:path=>"pbcoreRelationIdentifier", :attributes=>{ :annotation=>"Archival Series" })
101
101
  t.coll_num(:path=>"pbcoreRelationIdentifier", :attributes=>{ :annotation=>"Collection Number" })
102
102
  t.acc_num(:path=>"pbcoreRelationIdentifier", :attributes=>{ :annotation=>"Accession Number" })
103
+ t.addl_coll(:path=>"pbcoreRelationIdentifier", :attributes=>{ :annotation=>"Additional Collection" })
103
104
  end
104
105
  t.series(:ref=>[:pbcoreRelation, :event_series], :index_as => [:searchable, :displayable, :facetable])
105
106
  t.collection(:ref=>[:pbcoreRelation, :arch_coll], :index_as => [:searchable, :displayable, :facetable])
107
+ t.additional_collection(:ref=>[:pbcoreRelation, :addl_coll], :index_as => [:searchable, :displayable, :facetable])
106
108
  t.archival_series(:ref=>[:pbcoreRelation, :arch_ser], :index_as => [:searchable, :displayable])
107
109
  t.collection_number(:ref=>[:pbcoreRelation, :coll_num], :index_as => [:searchable, :displayable])
108
110
  t.accession_number(:ref=>[:pbcoreRelation, :acc_num], :index_as => [:searchable, :displayable])
@@ -0,0 +1,23 @@
1
+ module HydraPbcore::Datastream
2
+ class GenericFile < HydraPbcore::Datastream::Document
3
+
4
+ # Use our existing HydraPbcore::Datastream::Document terminology
5
+ use_terminology HydraPbcore::Datastream::Document
6
+
7
+ # Add in the extra bits required for Sufia
8
+ extend_terminology do |t|
9
+ t.resource_type(:proxy=>[:asset_type])
10
+ t.description(:proxy=>[:summary])
11
+ t.date_created(:proxy=>[:asset_date])
12
+ t.tag(:proxy=>[:rh_subject])
13
+ t.rights(:proxy=>[:rights_summary])
14
+ t.identifier(:proxy=>[:pbc_id])
15
+
16
+ t.related_url(:path=>"pbcoreAnnotation", :atttributes=>{ :annotationType=>"Related Url" }, :index_as => [:displayable])
17
+ t.based_near(:path=>"pbcoreAnnotation", :atttributes=>{ :annotationType=>"Based Near" }, :index_as => [:displayable])
18
+ t.part_of(:path=>"pbcoreAnnotation", :atttributes=>{ :annotationType=>"Part Of" }, :index_as => [:displayable])
19
+ t.language(:path=>"pbcoreAnnotation", :atttributes=>{ :annotationType=>"Language" }, :index_as => [:displayable])
20
+ end
21
+
22
+ end
23
+ end
@@ -68,6 +68,13 @@ module HydraPbcore::Templates
68
68
  }
69
69
  end
70
70
 
71
+ define_template :is_part_of do |xml, value, opts={}|
72
+ xml.pbcoreRelation {
73
+ xml.pbcoreRelationType("Is Part Of", :source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of")
74
+ xml.pbcoreRelationIdentifier(value, opts)
75
+ }
76
+ end
77
+
71
78
  define_template :identifier do |xml, identifier, source, annotation|
72
79
  attributes = {source: source}
73
80
  attributes[:annotation] = annotation if annotation
@@ -110,10 +117,16 @@ module HydraPbcore::Templates
110
117
  add_child_node(ng_xml.root, :event_date, date, *type)
111
118
  end
112
119
 
120
+ # deprecated
113
121
  def insert_relation(value, annotation)
122
+ puts "insert_relation is deprecated. Use is_part_of instead."
114
123
  add_child_node(ng_xml.root, :relation, value, annotation)
115
124
  end
116
125
 
126
+ def is_part_of(value, opts={})
127
+ add_child_node(ng_xml.root, :is_part_of, value, opts)
128
+ end
129
+
117
130
  def insert_identifier(identifier, annotation=nil, source=HydraPbcore.config["institution"])
118
131
  add_child_node(ng_xml.root, :identifier, identifier, source, annotation)
119
132
  end
@@ -1,3 +1,3 @@
1
1
  module HydraPbcore
2
- VERSION = "3.1.0"
2
+ VERSION = "3.2.0"
3
3
  end
@@ -47,6 +47,7 @@ describe HydraPbcore::Datastream::Document do
47
47
  [:asset_type],
48
48
  [:rights_summary],
49
49
  [:collection],
50
+ [:additional_collection],
50
51
  [:archival_series],
51
52
  [:collection_number],
52
53
  [:accession_number],
@@ -77,19 +78,28 @@ describe HydraPbcore::Datastream::Document do
77
78
  end
78
79
  end
79
80
 
80
- it "should have insert_relation" do
81
- @object_ds = HydraPbcore::Datastream::Document.new(nil, nil)
82
- @object_ds.insert_relation("My Collection", 'Archival Collection')
83
- @object_ds.collection.should == ['My Collection']
84
-
85
- @object_ds.insert_relation("My event", 'Event Series')
86
- @object_ds.series.should == ['My event']
87
-
88
- @object_ds.insert_relation("My series", 'Archival Series')
89
- @object_ds.archival_series.should == ['My series']
90
-
91
- @object_ds.insert_relation("My Acces Num", 'Accession Number')
92
- @object_ds.accession_number.should == ['My Acces Num']
81
+ describe "#is_part_of" do
82
+ it "includes archival colletions" do
83
+ @object_ds = HydraPbcore::Datastream::Document.new(nil, nil)
84
+ @object_ds.is_part_of("My Collection", {:annotation => 'Archival Collection'})
85
+ @object_ds.collection.should == ['My Collection']
86
+ end
87
+ it "includes event series" do
88
+ @object_ds.is_part_of("My event", {:annotation => 'Event Series'})
89
+ @object_ds.series.should == ['My event']
90
+ end
91
+ it "includes archival series" do
92
+ @object_ds.is_part_of("My series", {:annotation => 'Archival Series'})
93
+ @object_ds.archival_series.should == ['My series']
94
+ end
95
+ it "includes accession numbers" do
96
+ @object_ds.is_part_of("My Acces Num", {:annotation => 'Accession Number'})
97
+ @object_ds.accession_number.should == ['My Acces Num']
98
+ end
99
+ it "includes additional colletions" do
100
+ @object_ds.is_part_of("Some other collection", {:annotation => 'Additional Collection'})
101
+ @object_ds.additional_collection.should == ['Some other collection']
102
+ end
93
103
  end
94
104
 
95
105
 
@@ -132,11 +142,12 @@ describe HydraPbcore::Datastream::Document do
132
142
  @object_ds.insert_date("2012-11-11")
133
143
  @object_ds.insert_date("2012-11-12")
134
144
 
135
- @object_ds.insert_relation("inserted", 'Archival Collection')
136
- @object_ds.insert_relation("inserted", 'Event Series')
137
- @object_ds.insert_relation("inserted", 'Archival Series')
138
- @object_ds.insert_relation("inserted", 'Accession Number')
139
- @object_ds.insert_relation("inserted", 'Collection Number')
145
+ @object_ds.is_part_of("inserted", {:annotation => 'Archival Collection'})
146
+ @object_ds.is_part_of("inserted", {:annotation => 'Event Series'})
147
+ @object_ds.is_part_of("inserted", {:annotation => 'Archival Series'})
148
+ @object_ds.is_part_of("inserted", {:annotation => 'Accession Number'})
149
+ @object_ds.is_part_of("inserted", {:annotation => 'Collection Number'})
150
+ @object_ds.is_part_of("inserted", {:annotation => 'Additional Collection'})
140
151
 
141
152
  @object_ds.title = "inserted"
142
153
  @object_ds.alternative_title = "inserted"
@@ -59,6 +59,10 @@
59
59
  <pbcoreRelationType source="PBCore relationType" ref="http://pbcore.org/vocabularies/relationType#is-part-of">Is Part Of</pbcoreRelationType>
60
60
  <pbcoreRelationIdentifier annotation="Collection Number">inserted</pbcoreRelationIdentifier>
61
61
  </pbcoreRelation>
62
+ <pbcoreRelation>
63
+ <pbcoreRelationType source="PBCore relationType" ref="http://pbcore.org/vocabularies/relationType#is-part-of">Is Part Of</pbcoreRelationType>
64
+ <pbcoreRelationIdentifier annotation="Additional Collection">inserted</pbcoreRelationIdentifier>
65
+ </pbcoreRelation>
62
66
  <pbcoreTitle titleType="Alternative">inserted</pbcoreTitle>
63
67
  <pbcoreTitle titleType="Chapter">inserted</pbcoreTitle>
64
68
  <pbcoreTitle titleType="Episode">inserted</pbcoreTitle>
@@ -400,6 +400,15 @@
400
400
  <collection-sim type="array">
401
401
  <collection-sim>inserted</collection-sim>
402
402
  </collection-sim>
403
+ <additional-collection-teim type="array">
404
+ <additional-collection-teim>inserted</additional-collection-teim>
405
+ </additional-collection-teim>
406
+ <additional-collection-ssm type="array">
407
+ <additional-collection-ssm>inserted</additional-collection-ssm>
408
+ </additional-collection-ssm>
409
+ <additional-collection-sim type="array">
410
+ <additional-collection-sim>inserted</additional-collection-sim>
411
+ </additional-collection-sim>
403
412
  <archival-series-teim type="array">
404
413
  <archival-series-teim>inserted</archival-series-teim>
405
414
  </archival-series-teim>
@@ -0,0 +1,120 @@
1
+ require 'spec_helper'
2
+
3
+ describe HydraPbcore::Datastream::GenericFile do
4
+
5
+ before :each do
6
+ @object_ds = HydraPbcore::Datastream::GenericFile.new nil, nil
7
+ end
8
+
9
+ describe "extending Sufia::GenericFile field" do
10
+
11
+ describe "#related_url" do
12
+ it "should have getter and setters" do
13
+ @object_ds.related_url.should == [""]
14
+ @object_ds.related_url = "a related url"
15
+ @object_ds.related_url.should == ["a related url"]
16
+ end
17
+ end
18
+
19
+ describe "#based_near" do
20
+ it "should have getter and setters" do
21
+ @object_ds.based_near.should == [""]
22
+ @object_ds.based_near = "a related url"
23
+ @object_ds.based_near.should == ["a related url"]
24
+ end
25
+ end
26
+
27
+ describe "#part_of" do
28
+ it "should have getter and setters" do
29
+ @object_ds.part_of.should == [""]
30
+ @object_ds.part_of = "part of annotation"
31
+ @object_ds.part_of.should == ["part of annotation"]
32
+ end
33
+ end
34
+
35
+ describe "#language" do
36
+ it "should have getter and setters" do
37
+ @object_ds.language.should == [""]
38
+ @object_ds.language = "language"
39
+ @object_ds.language.should == ["language"]
40
+ end
41
+ end
42
+
43
+ describe "#tag" do
44
+ before :each do
45
+ @object_ds.tag = "a tag"
46
+ end
47
+ it "should have getter and setters" do
48
+ @object_ds.tag.should == ["a tag"]
49
+ end
50
+ it "should be a kind of subject" do
51
+ @object_ds.subject.should == ["a tag"]
52
+ end
53
+ it "should be the same as rh_subject" do
54
+ @object_ds.rh_subject.should == ["a tag"]
55
+ end
56
+ end
57
+
58
+ describe "#description" do
59
+ before :each do
60
+ @object_ds.description = "foo"
61
+ end
62
+ it "should have getter and setters" do
63
+ @object_ds.description.should == ["foo"]
64
+ end
65
+ it "should be the same as #summary" do
66
+ @object_ds.summary.should == ["foo"]
67
+ end
68
+ end
69
+
70
+ describe "#rights" do
71
+ before :each do
72
+ @object_ds.rights = "rights statement"
73
+ end
74
+ it "should have getters and setters" do
75
+ @object_ds.rights.should == ["rights statement"]
76
+ end
77
+ it "should be the same as #rights_summary" do
78
+ @object_ds.rights_summary.should == ["rights statement"]
79
+ end
80
+ end
81
+
82
+ describe "#date_created" do
83
+ before :each do
84
+ @object_ds.date_created = "2001-11-13"
85
+ end
86
+ it "should have getters and setters" do
87
+ @object_ds.date_created.should == ["2001-11-13"]
88
+ end
89
+ it "should be the same as #asset_date" do
90
+ @object_ds.date_created.should == ["2001-11-13"]
91
+ end
92
+ end
93
+
94
+ describe "#resource_type" do
95
+ before :each do
96
+ @object_ds.resource_type = "a resource type"
97
+ end
98
+ it "should be a term" do
99
+ @object_ds.resource_type.should == ["a resource type"]
100
+ end
101
+ it "should be the same as #asset_type" do
102
+ @object_ds.asset_type.should == ["a resource type"]
103
+ end
104
+ end
105
+
106
+ describe "#identifier" do
107
+ before :each do
108
+ @object_ds.identifier = "a Sufia identifier"
109
+ end
110
+ it "should have getters and setters" do
111
+ @object_ds.identifier.should == ["a Sufia identifier"]
112
+ end
113
+ it "should be the same as #pbc_id" do
114
+ @object_ds.pbc_id.should == ["a Sufia identifier"]
115
+ end
116
+ end
117
+
118
+ end
119
+
120
+ end
@@ -16,7 +16,7 @@ describe HydraPbcore::Methods do
16
16
  end
17
17
 
18
18
  it "should delete nodes all with their parents" do
19
- @object.insert_relation("foo", "Archival Collection")
19
+ @object.is_part_of("foo", {:annotation => "Archival Collection"})
20
20
  @object.collection.first.should == "foo"
21
21
  @object.remove_node :collection, 0, {:include_parent? => TRUE}
22
22
  @object.find_by_terms(:pbcoreRelation).should be_empty
@@ -43,6 +43,21 @@ describe HydraPbcore::Templates do
43
43
  end
44
44
  end
45
45
 
46
+ describe "#is_part_of" do
47
+ it "should default with only a value" do
48
+ subject.add_child_node(subject.ng_xml.root, :is_part_of, 'foo')
49
+ xml.xpath('//pbcoreRelation/pbcoreRelationIdentifier').text.should == "foo"
50
+ xml.xpath('//pbcoreRelation/pbcoreRelationIdentifier/@annotation').text.should be_empty
51
+ end
52
+ it "should take a hash of options" do
53
+ subject.add_child_node(subject.ng_xml.root, :is_part_of, 'foo', {:annotation => "bar", :source => "source", :ref => "reference"})
54
+ xml.xpath('//pbcoreRelation/pbcoreRelationIdentifier').text.should == "foo"
55
+ xml.xpath('//pbcoreRelation/pbcoreRelationIdentifier[@annotation="bar"]').text.should == "foo"
56
+ xml.xpath('//pbcoreRelation/pbcoreRelationIdentifier/@source').text.should == "source"
57
+ xml.xpath('//pbcoreRelation/pbcoreRelationIdentifier/@ref').text.should == "reference"
58
+ end
59
+ end
60
+
46
61
  describe "#event_place" do
47
62
  it "should take a one arg constructor" do
48
63
  subject.add_child_node(subject.ng_xml.root, :event_place, 'foo')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-pbcore
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-20 00:00:00.000000000 Z
12
+ date: 2013-10-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active-fedora
@@ -181,7 +181,6 @@ files:
181
181
  - .gitignore
182
182
  - .travis.yml
183
183
  - Gemfile
184
- - Gemfile.lock
185
184
  - LICENSE
186
185
  - README.md
187
186
  - Rakefile
@@ -190,6 +189,7 @@ files:
190
189
  - lib/hydra_pbcore/behaviors.rb
191
190
  - lib/hydra_pbcore/datastream.rb
192
191
  - lib/hydra_pbcore/datastream/document.rb
192
+ - lib/hydra_pbcore/datastream/generic_file.rb
193
193
  - lib/hydra_pbcore/datastream/instantiation.rb
194
194
  - lib/hydra_pbcore/methods.rb
195
195
  - lib/hydra_pbcore/templates.rb
@@ -205,6 +205,7 @@ files:
205
205
  - spec/fixtures/physical_instantiation.xml
206
206
  - spec/fixtures/physical_instantiation_solr.xml
207
207
  - spec/fixtures/physical_instantiation_template.xml
208
+ - spec/generic_file_spec.rb
208
209
  - spec/instantiation_spec.rb
209
210
  - spec/methods_spec.rb
210
211
  - spec/spec_helper.rb
@@ -222,18 +223,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
223
  - - ! '>='
223
224
  - !ruby/object:Gem::Version
224
225
  version: '0'
225
- segments:
226
- - 0
227
- hash: -856777105880337948
228
226
  required_rubygems_version: !ruby/object:Gem::Requirement
229
227
  none: false
230
228
  requirements:
231
229
  - - ! '>='
232
230
  - !ruby/object:Gem::Version
233
231
  version: '0'
234
- segments:
235
- - 0
236
- hash: -856777105880337948
237
232
  requirements: []
238
233
  rubyforge_project:
239
234
  rubygems_version: 1.8.23
@@ -252,6 +247,7 @@ test_files:
252
247
  - spec/fixtures/physical_instantiation.xml
253
248
  - spec/fixtures/physical_instantiation_solr.xml
254
249
  - spec/fixtures/physical_instantiation_template.xml
250
+ - spec/generic_file_spec.rb
255
251
  - spec/instantiation_spec.rb
256
252
  - spec/methods_spec.rb
257
253
  - spec/spec_helper.rb
@@ -1,135 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- hydra-pbcore (3.1.0)
5
- active-fedora
6
- solrizer
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- active-fedora (6.4.5)
12
- activesupport (>= 3.0.0)
13
- deprecation
14
- mediashelf-loggable
15
- nom-xml (>= 0.5.1)
16
- om (~> 3.0.0)
17
- rdf
18
- rdf-rdfxml (= 1.0.1)
19
- rsolr
20
- rubydora (~> 1.6, >= 1.6.5)
21
- activemodel (4.0.0)
22
- activesupport (= 4.0.0)
23
- builder (~> 3.1.0)
24
- activesupport (4.0.0)
25
- i18n (~> 0.6, >= 0.6.4)
26
- minitest (~> 4.2)
27
- multi_json (~> 1.3)
28
- thread_safe (~> 0.1)
29
- tzinfo (~> 0.3.37)
30
- addressable (2.3.5)
31
- atomic (1.1.13)
32
- builder (3.1.4)
33
- coderay (1.0.9)
34
- columnize (0.3.6)
35
- daemons (1.1.9)
36
- debugger (1.6.1)
37
- columnize (>= 0.3.1)
38
- debugger-linecache (~> 1.2.0)
39
- debugger-ruby_core_source (~> 1.2.3)
40
- debugger-linecache (1.2.0)
41
- debugger-ruby_core_source (1.2.3)
42
- deprecation (0.0.5)
43
- activesupport
44
- diff-lcs (1.2.4)
45
- equivalent-xml (0.3.0)
46
- nokogiri (>= 1.4.3)
47
- fastercsv (1.5.5)
48
- hooks (0.3.1)
49
- i18n (0.6.5)
50
- json (1.8.0)
51
- mediashelf-loggable (0.4.9)
52
- method_source (0.8.2)
53
- mime-types (1.24)
54
- mini_portile (0.5.1)
55
- minitest (4.7.5)
56
- multi_json (1.7.9)
57
- nokogiri (1.6.0)
58
- mini_portile (~> 0.5.0)
59
- nom-xml (0.5.1)
60
- activesupport
61
- i18n
62
- nokogiri
63
- om (3.0.3)
64
- activemodel
65
- activesupport
66
- deprecation
67
- mediashelf-loggable
68
- nokogiri (>= 1.4.2)
69
- solrizer (~> 3.1.0)
70
- pry (0.9.12.2)
71
- coderay (~> 1.0.5)
72
- method_source (~> 0.8)
73
- slop (~> 3.4)
74
- rake (10.1.0)
75
- rdf (1.0.7)
76
- addressable (>= 2.2)
77
- rdf-rdfxml (1.0.1)
78
- rdf (>= 1.0)
79
- rdf-xsd (>= 1.0)
80
- rdf-xsd (1.0.2.1)
81
- nokogiri (>= 1.5.0)
82
- rdf (>= 0.3.4)
83
- rdoc (4.0.1)
84
- json (~> 1.4)
85
- redcarpet (3.0.0)
86
- rest-client (1.6.7)
87
- mime-types (>= 1.16)
88
- rsolr (1.0.9)
89
- builder (>= 2.1.2)
90
- rspec (2.14.1)
91
- rspec-core (~> 2.14.0)
92
- rspec-expectations (~> 2.14.0)
93
- rspec-mocks (~> 2.14.0)
94
- rspec-core (2.14.5)
95
- rspec-expectations (2.14.2)
96
- diff-lcs (>= 1.1.3, < 2.0)
97
- rspec-mocks (2.14.3)
98
- rubydora (1.6.5)
99
- activemodel
100
- activesupport
101
- deprecation
102
- equivalent-xml
103
- fastercsv
104
- hooks (~> 0.3.0)
105
- mime-types
106
- nokogiri
107
- rest-client
108
- slop (3.4.6)
109
- solrizer (3.1.1)
110
- activesupport
111
- daemons
112
- mediashelf-loggable (~> 0.4.7)
113
- nokogiri
114
- stomp
115
- xml-simple
116
- stomp (1.2.12)
117
- thread_safe (0.1.2)
118
- atomic
119
- tzinfo (0.3.37)
120
- xml-simple (1.1.2)
121
- yard (0.8.7)
122
-
123
- PLATFORMS
124
- ruby
125
-
126
- DEPENDENCIES
127
- debugger
128
- equivalent-xml
129
- hydra-pbcore!
130
- pry
131
- rake
132
- rdoc
133
- redcarpet
134
- rspec
135
- yard