hydra-pbcore 3.0.2 → 3.1.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.
- data/Gemfile.lock +1 -1
- data/README.md +17 -0
- data/Rakefile +1 -1
- data/lib/hydra_pbcore/datastream/document.rb +1 -4
- data/lib/hydra_pbcore/templates.rb +9 -0
- data/lib/hydra_pbcore/version.rb +1 -1
- data/spec/document_spec.rb +1 -1
- data/spec/fixtures/document_template.xml +0 -1
- data/spec/templates_spec.rb +15 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -72,6 +72,23 @@ according to the PBCore XML v.2 schema:
|
|
72
72
|
> pbcore.valid_pbcore?
|
73
73
|
=> true
|
74
74
|
|
75
|
+
## New Changes
|
76
|
+
|
77
|
+
### version 3.1
|
78
|
+
|
79
|
+
As of 3.1, the pbcoreIdentifier is not included in the xml template. This is so users may add their own identifier,
|
80
|
+
or multiple identifiers, with an optional annotation. Documents will require at least one pbcoreIdentifier in order to
|
81
|
+
be valid. You may specify this either by simply setting the value:
|
82
|
+
|
83
|
+
doc.pbc_id = "1234"
|
84
|
+
|
85
|
+
Or by inserting a new one via the template:
|
86
|
+
|
87
|
+
doc.insert_identifier("5678")
|
88
|
+
|
89
|
+
All identifiers will include the source attribute, which is required by the PBCore schema, and is given in the config.yml file.
|
90
|
+
An annotation may be added as a second argument to the identifier template.
|
91
|
+
|
75
92
|
## Testing
|
76
93
|
|
77
94
|
To run all the rspec tests, use:
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rspec/core/rake_task'
|
|
5
5
|
# Rake task for getting an irb session
|
6
6
|
desc "Open an irb session preloaded with this library"
|
7
7
|
task :console do
|
8
|
-
sh "
|
8
|
+
sh "pry -rubygems -I lib -e \"require 'hydra-pbcore'\""
|
9
9
|
end
|
10
10
|
|
11
11
|
RSpec::Core::RakeTask.new(:spec)
|
@@ -7,9 +7,7 @@ class Document < ActiveFedora::OmDatastream
|
|
7
7
|
set_terminology do |t|
|
8
8
|
t.root(:path=>"pbcoreDescriptionDocument")
|
9
9
|
|
10
|
-
t.pbc_id(:path=>"pbcoreIdentifier",
|
11
|
-
:attributes=>{ :source=>HydraPbcore.config["institution"], :annotation=>"PID" }
|
12
|
-
)
|
10
|
+
t.pbc_id(:path=>"pbcoreIdentifier", :attributes=>{ :source=>HydraPbcore.config["institution"] })
|
13
11
|
|
14
12
|
t.title(:path=>"pbcoreTitle", :attributes=>{ :titleType=>"Main" }, :index_as => [:searchable, :displayable, :sortable])
|
15
13
|
t.alternative_title(:path=>"pbcoreTitle", :attributes=>{ :titleType=>"Alternative" },
|
@@ -160,7 +158,6 @@ class Document < ActiveFedora::OmDatastream
|
|
160
158
|
xml.pbcoreDescriptionDocument("xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
|
161
159
|
"xsi:schemaLocation"=>"http://www.pbcore.org/PBCore/PBCoreNamespace.html") {
|
162
160
|
|
163
|
-
xml.pbcoreIdentifier(:source=>HydraPbcore.config["institution"], :annotation=>"PID")
|
164
161
|
xml.pbcoreTitle(:titleType=>"Main")
|
165
162
|
xml.pbcoreDescription(:descriptionType=>"Description",
|
166
163
|
:descriptionTypeSource=>"pbcoreDescription/descriptionType",
|
@@ -68,6 +68,11 @@ module HydraPbcore::Templates
|
|
68
68
|
}
|
69
69
|
end
|
70
70
|
|
71
|
+
define_template :identifier do |xml, identifier, source, annotation|
|
72
|
+
attributes = {source: source}
|
73
|
+
attributes[:annotation] = annotation if annotation
|
74
|
+
xml.pbcoreIdentifier(identifier, attributes)
|
75
|
+
end
|
71
76
|
end
|
72
77
|
end
|
73
78
|
|
@@ -109,6 +114,10 @@ module HydraPbcore::Templates
|
|
109
114
|
add_child_node(ng_xml.root, :relation, value, annotation)
|
110
115
|
end
|
111
116
|
|
117
|
+
def insert_identifier(identifier, annotation=nil, source=HydraPbcore.config["institution"])
|
118
|
+
add_child_node(ng_xml.root, :identifier, identifier, source, annotation)
|
119
|
+
end
|
120
|
+
|
112
121
|
def digital_instantiation
|
113
122
|
builder = Nokogiri::XML::Builder.new do |xml|
|
114
123
|
|
data/lib/hydra_pbcore/version.rb
CHANGED
data/spec/document_spec.rb
CHANGED
@@ -122,6 +122,7 @@ describe HydraPbcore::Datastream::Document do
|
|
122
122
|
|
123
123
|
before(:each) do
|
124
124
|
# insert additional nodes
|
125
|
+
@object_ds.insert_identifier("inserted", "PID")
|
125
126
|
@object_ds.insert_publisher("inserted", "inserted")
|
126
127
|
@object_ds.insert_contributor("inserted", "inserted")
|
127
128
|
@object_ds.insert_publisher("inserted")
|
@@ -137,7 +138,6 @@ describe HydraPbcore::Datastream::Document do
|
|
137
138
|
@object_ds.insert_relation("inserted", 'Accession Number')
|
138
139
|
@object_ds.insert_relation("inserted", 'Collection Number')
|
139
140
|
|
140
|
-
@object_ds.pbc_id = "inserted"
|
141
141
|
@object_ds.title = "inserted"
|
142
142
|
@object_ds.alternative_title = "inserted"
|
143
143
|
@object_ds.chapter = "inserted"
|
@@ -1,5 +1,4 @@
|
|
1
1
|
<pbcoreDescriptionDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html">
|
2
|
-
<pbcoreIdentifier source="Rock and Roll Hall of Fame and Museum" annotation="PID"/>
|
3
2
|
<pbcoreTitle titleType="Main"/>
|
4
3
|
<pbcoreDescription descriptionType="Description" descriptionTypeSource="pbcoreDescription/descriptionType" descriptionTypeRef="http://pbcore.org/vocabularies/pbcoreDescription/descriptionType#description" annotation="Summary"/>
|
5
4
|
<pbcoreDescription descriptionType="Table of Contents" descriptionTypeSource="pbcoreDescription/descriptionType" descriptionTypeRef="http://pbcore.org/vocabularies/pbcoreDescription/descriptionType#table-of-contents" annotation="Parts List"/>
|
data/spec/templates_spec.rb
CHANGED
@@ -96,4 +96,19 @@ describe HydraPbcore::Templates do
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
+
describe "#insert_identifier" do
|
100
|
+
it "should take a one arg constructor" do
|
101
|
+
subject.insert_identifier('foo')
|
102
|
+
xml.xpath('//pbcoreIdentifier[@source="Rock and Roll Hall of Fame and Museum"]').text.should == "foo"
|
103
|
+
end
|
104
|
+
it "should take a two arg constructor" do
|
105
|
+
subject.insert_identifier('foo', 'bar')
|
106
|
+
xml.xpath('//pbcoreIdentifier[@source="Rock and Roll Hall of Fame and Museum"][@annotation="bar"]').text.should == "foo"
|
107
|
+
end
|
108
|
+
it "should take a three arg constructor" do
|
109
|
+
subject.insert_identifier('foo', 'bar', 'baz')
|
110
|
+
xml.xpath('//pbcoreIdentifier[@source="baz"][@annotation="bar"]').text.should == "foo"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
99
114
|
end
|
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.0
|
4
|
+
version: 3.1.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-
|
12
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active-fedora
|
@@ -224,7 +224,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
224
224
|
version: '0'
|
225
225
|
segments:
|
226
226
|
- 0
|
227
|
-
hash: -
|
227
|
+
hash: -856777105880337948
|
228
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
229
|
none: false
|
230
230
|
requirements:
|
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
233
|
version: '0'
|
234
234
|
segments:
|
235
235
|
- 0
|
236
|
-
hash: -
|
236
|
+
hash: -856777105880337948
|
237
237
|
requirements: []
|
238
238
|
rubyforge_project:
|
239
239
|
rubygems_version: 1.8.23
|