hydra-pbcore 1.1.3 → 2.0.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/.gitignore +4 -1
- data/README.md +9 -0
- data/hydra-pbcore.gemspec +1 -1
- data/lib/hydra-pbcore.rb +8 -11
- data/lib/{hydra-pbcore → hydra_pbcore}/behaviors.rb +5 -4
- data/lib/{hydra-pbcore → hydra_pbcore}/conversions.rb +0 -0
- data/lib/hydra_pbcore/datastream.rb +6 -0
- data/lib/hydra_pbcore/datastream/deprecated.rb +6 -0
- data/lib/{hydra-pbcore → hydra_pbcore}/datastream/deprecated/digital_document.rb +0 -0
- data/lib/{hydra-pbcore → hydra_pbcore}/datastream/deprecated/document.rb +0 -0
- data/lib/{hydra-pbcore → hydra_pbcore}/datastream/deprecated/instantiation.rb +0 -0
- data/lib/{hydra-pbcore → hydra_pbcore}/datastream/document.rb +13 -32
- data/lib/{hydra-pbcore → hydra_pbcore}/datastream/instantiation.rb +1 -1
- data/lib/{hydra-pbcore → hydra_pbcore}/mapper.rb +0 -0
- data/lib/{hydra-pbcore → hydra_pbcore}/methods.rb +0 -0
- data/lib/{hydra-pbcore → hydra_pbcore}/templates.rb +23 -1
- data/lib/hydra_pbcore/version.rb +3 -0
- data/spec/document_spec.rb +31 -8
- data/spec/fixtures/document_template.xml +1 -21
- data/spec/instantiation_spec.rb +5 -5
- data/spec/integration/conversions_spec.rb +6 -6
- data/spec/spec_helper.rb +5 -8
- data/spec/templates_spec.rb +3 -3
- data/tmp/.gitkeep +0 -0
- metadata +16 -15
- data/.rvmrc +0 -48
- data/lib/hydra-pbcore/version.rb +0 -3
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -46,6 +46,15 @@ validate against the PBCore XML v.2 schema. Additionally, there are several tem
|
|
46
46
|
to insert additional terms into your xml documents, such as contributors, publishers, as well as next and previous
|
47
47
|
fields that specify which files come before and after one another in a multi-part born-digital video.
|
48
48
|
|
49
|
+
## Testing
|
50
|
+
|
51
|
+
To run all the rspec tests, use:
|
52
|
+
|
53
|
+
rspec spec
|
54
|
+
|
55
|
+
Sample xml documents are copied to tmp so you can see what the xml looks like that hydra-pbcore is generating.
|
56
|
+
These xml samples are compared to examples in spec/fixtures.
|
57
|
+
|
49
58
|
## Contributing
|
50
59
|
|
51
60
|
1. Fork it
|
data/hydra-pbcore.gemspec
CHANGED
data/lib/hydra-pbcore.rb
CHANGED
@@ -5,6 +5,7 @@ require "om"
|
|
5
5
|
require "active-fedora"
|
6
6
|
|
7
7
|
module HydraPbcore
|
8
|
+
extend ActiveSupport::Autoload
|
8
9
|
|
9
10
|
DocumentNodes = [
|
10
11
|
"pbcoreAssetType",
|
@@ -64,15 +65,11 @@ module HydraPbcore
|
|
64
65
|
xml = '<?xml version="1.0"?><pbcoreDescriptionDocument xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html" xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html"></pbcoreDescriptionDocument>'
|
65
66
|
Nokogiri::XML(xml)
|
66
67
|
end
|
67
|
-
end
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
require "hydra-pbcore/datastream/deprecated/document"
|
77
|
-
require "hydra-pbcore/datastream/deprecated/digital_document"
|
78
|
-
require "hydra-pbcore/datastream/deprecated/instantiation"
|
69
|
+
autoload :Mapper
|
70
|
+
autoload :Methods
|
71
|
+
autoload :Conversions
|
72
|
+
autoload :Behaviors
|
73
|
+
autoload :Templates
|
74
|
+
autoload :Datastream
|
75
|
+
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module HydraPbcore
|
2
2
|
class Behaviors
|
3
3
|
|
4
|
-
# This module is
|
4
|
+
# This module is a leftover from version 1 of the hydra-pbcore gem and is no longer actively
|
5
|
+
# developed. It will be removed in a future release.
|
5
6
|
|
6
7
|
# Nokogiri's add_namespace doesn't seem to work, so we have to insert it "manually"
|
7
8
|
def self.insert_pbcore_namespace(doc)
|
8
|
-
puts "WARNING: HydraPbcore::Behaviors is deprecated and will be removed in release
|
9
|
+
puts "WARNING: HydraPbcore::Behaviors is deprecated and will be removed in a future release"
|
9
10
|
index = doc.to_s.index("xmlns:xsi")
|
10
11
|
new_s = doc.to_s.insert(index.to_i, 'xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html" ')
|
11
12
|
new_doc = Nokogiri::XML(new_s)
|
@@ -15,7 +16,7 @@ class Behaviors
|
|
15
16
|
# Validates a PBCore document against an xsd
|
16
17
|
# Returns an array of errors -- an empty array means it's valid
|
17
18
|
def self.validate(doc)
|
18
|
-
puts "WARNING: HydraPbcore::Behaviors is deprecated and will be removed in release
|
19
|
+
puts "WARNING: HydraPbcore::Behaviors is deprecated and will be removed in a future release"
|
19
20
|
xsd = Nokogiri::XML::Schema(open("http://pbcore.org/xsd/pbcore-2.0.xsd"))
|
20
21
|
xsd.validate(doc)
|
21
22
|
end
|
@@ -23,7 +24,7 @@ class Behaviors
|
|
23
24
|
|
24
25
|
# Reorders the nodes of pbcoreDescriptionDocument to conform with the correct order
|
25
26
|
def self.reorder_document(doc)
|
26
|
-
puts "WARNING: HydraPbcore::Behaviors is deprecated and will be removed in release
|
27
|
+
puts "WARNING: HydraPbcore::Behaviors is deprecated and will be removed in a future release"
|
27
28
|
nodes = [
|
28
29
|
"pbcoreAssetType",
|
29
30
|
"pbcoreAssetDate",
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module HydraPbcore::Datastream
|
2
|
-
class Document < ActiveFedora::
|
2
|
+
class Document < ActiveFedora::OmDatastream
|
3
3
|
|
4
4
|
include HydraPbcore::Methods
|
5
5
|
include HydraPbcore::Templates
|
@@ -116,6 +116,17 @@ class Document < ActiveFedora::NokogiriDatastream
|
|
116
116
|
:index_as => [:not_searchable, :converted_date, :displayable]
|
117
117
|
)
|
118
118
|
|
119
|
+
# Creator names and roles
|
120
|
+
t.creator(:path=>"pbcoreCreator") do
|
121
|
+
t.name_(:path=>"creator", :index_as => [:searchable, :facetable])
|
122
|
+
t.role_(:path=>"creatorRole",
|
123
|
+
:attributes=>{ :source=>"PBCore creatorRole" },
|
124
|
+
:index_as => [:searchable, :displayable]
|
125
|
+
)
|
126
|
+
end
|
127
|
+
t.creator_name(:proxy=>[:creator, :name])
|
128
|
+
t.creator_role(:proxy=>[:creator, :role])
|
129
|
+
|
119
130
|
# Contributor names and roles
|
120
131
|
t.contributor(:path=>"pbcoreContributor") do
|
121
132
|
t.name_(:path=>"contributor", :index_as => [:searchable, :facetable])
|
@@ -162,36 +173,6 @@ class Document < ActiveFedora::NokogiriDatastream
|
|
162
173
|
:descriptionTypeRef=>"http://pbcore.org/vocabularies/pbcoreDescription/descriptionType#table-of-contents",
|
163
174
|
:annotation=>"Parts List"
|
164
175
|
)
|
165
|
-
xml.pbcoreRelation {
|
166
|
-
xml.pbcoreRelationType(:source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of") {
|
167
|
-
xml.text "Is Part Of"
|
168
|
-
}
|
169
|
-
xml.pbcoreRelationIdentifier(:annotation=>"Event Series")
|
170
|
-
}
|
171
|
-
xml.pbcoreRelation {
|
172
|
-
xml.pbcoreRelationType(:source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of") {
|
173
|
-
xml.text "Is Part Of"
|
174
|
-
}
|
175
|
-
xml.pbcoreRelationIdentifier(:annotation=>"Archival Collection")
|
176
|
-
}
|
177
|
-
xml.pbcoreRelation {
|
178
|
-
xml.pbcoreRelationType(:source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of") {
|
179
|
-
xml.text "Is Part Of"
|
180
|
-
}
|
181
|
-
xml.pbcoreRelationIdentifier(:annotation=>"Archival Series")
|
182
|
-
}
|
183
|
-
xml.pbcoreRelation {
|
184
|
-
xml.pbcoreRelationType(:source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of") {
|
185
|
-
xml.text "Is Part Of"
|
186
|
-
}
|
187
|
-
xml.pbcoreRelationIdentifier(:annotation=>"Collection Number")
|
188
|
-
}
|
189
|
-
xml.pbcoreRelation {
|
190
|
-
xml.pbcoreRelationType(:source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of") {
|
191
|
-
xml.text "Is Part Of"
|
192
|
-
}
|
193
|
-
xml.pbcoreRelationIdentifier(:annotation=>"Accession Number")
|
194
|
-
}
|
195
176
|
xml.pbcoreRightsSummary {
|
196
177
|
xml.rightsSummary
|
197
178
|
}
|
@@ -204,4 +185,4 @@ class Document < ActiveFedora::NokogiriDatastream
|
|
204
185
|
end
|
205
186
|
|
206
187
|
end
|
207
|
-
end
|
188
|
+
end
|
File without changes
|
File without changes
|
@@ -4,6 +4,13 @@ module HydraPbcore::Templates
|
|
4
4
|
included do
|
5
5
|
class_eval do
|
6
6
|
|
7
|
+
define_template :creator do |xml, author, role|
|
8
|
+
xml.pbcoreCreator {
|
9
|
+
xml.creator(author)
|
10
|
+
xml.creatorRole(role, :source=>"PBCore creatorRole")
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
7
14
|
define_template :publisher do |xml, publisher, role|
|
8
15
|
xml.pbcorePublisher {
|
9
16
|
xml.publisher(publisher)
|
@@ -54,9 +61,20 @@ module HydraPbcore::Templates
|
|
54
61
|
}
|
55
62
|
end
|
56
63
|
|
64
|
+
define_template :relation do |xml, value, annotation|
|
65
|
+
xml.pbcoreRelation {
|
66
|
+
xml.pbcoreRelationType("Is Part Of", :source=>"PBCore relationType", :ref=>"http://pbcore.org/vocabularies/relationType#is-part-of")
|
67
|
+
xml.pbcoreRelationIdentifier(value, :annotation=>annotation)
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
57
71
|
end
|
58
72
|
end
|
59
73
|
|
74
|
+
def insert_creator(author=nil, role=nil)
|
75
|
+
add_child_node(ng_xml.root, :creator, author, role)
|
76
|
+
end
|
77
|
+
|
60
78
|
def insert_contributor(author=nil, role=nil)
|
61
79
|
add_child_node(ng_xml.root, :contributor, author, role)
|
62
80
|
end
|
@@ -81,6 +99,10 @@ module HydraPbcore::Templates
|
|
81
99
|
add_child_node(ng_xml.root, :event_date, date)
|
82
100
|
end
|
83
101
|
|
102
|
+
def insert_relation(value, annotation)
|
103
|
+
add_child_node(ng_xml.root, :relation, value, annotation)
|
104
|
+
end
|
105
|
+
|
84
106
|
def digital_instantiation
|
85
107
|
builder = Nokogiri::XML::Builder.new do |xml|
|
86
108
|
|
@@ -171,4 +193,4 @@ module HydraPbcore::Templates
|
|
171
193
|
end
|
172
194
|
|
173
195
|
|
174
|
-
end
|
196
|
+
end
|
data/spec/document_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe HydraPbcore::Datastream::Document do
|
|
9
9
|
describe "::xml_template" do
|
10
10
|
it "should match an exmplar" do
|
11
11
|
save_template @object_ds.to_xml, "document_template.xml"
|
12
|
-
|
12
|
+
tmp_file_should_match_exemplar("document_template.xml")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -35,6 +35,8 @@ describe HydraPbcore::Datastream::Document do
|
|
35
35
|
[:lc_genre],
|
36
36
|
[:lc_subject_genre],
|
37
37
|
[:event_series],
|
38
|
+
[:creator_name],
|
39
|
+
[:creator_role],
|
38
40
|
[:contributor_name],
|
39
41
|
[:contributor_role],
|
40
42
|
[:publisher_name],
|
@@ -54,9 +56,12 @@ describe HydraPbcore::Datastream::Document do
|
|
54
56
|
end
|
55
57
|
|
56
58
|
it "should update fields requiring inserted nodes" do
|
59
|
+
@object_ds.insert_creator
|
57
60
|
@object_ds.insert_publisher
|
58
61
|
@object_ds.insert_contributor
|
59
62
|
[
|
63
|
+
[:creator_name],
|
64
|
+
[:creator_role],
|
60
65
|
[:publisher_name],
|
61
66
|
[:publisher_role],
|
62
67
|
[:contributor_name],
|
@@ -69,6 +74,22 @@ describe HydraPbcore::Datastream::Document do
|
|
69
74
|
end
|
70
75
|
end
|
71
76
|
|
77
|
+
it "should have insert_relation" do
|
78
|
+
@object_ds = HydraPbcore::Datastream::Document.new(nil, nil)
|
79
|
+
@object_ds.insert_relation("My Collection", 'Archival Collection')
|
80
|
+
@object_ds.archival_collection.should == ['My Collection']
|
81
|
+
|
82
|
+
@object_ds.insert_relation("My event", 'Event Series')
|
83
|
+
@object_ds.event_series.should == ['My event']
|
84
|
+
|
85
|
+
@object_ds.insert_relation("My series", 'Archival Series')
|
86
|
+
@object_ds.archival_series.should == ['My series']
|
87
|
+
|
88
|
+
@object_ds.insert_relation("My Acces Num", 'Accession Number')
|
89
|
+
@object_ds.accession_number.should == ['My Acces Num']
|
90
|
+
end
|
91
|
+
|
92
|
+
|
72
93
|
it "should differentiate between multiple added nodes" do
|
73
94
|
@object_ds.insert_contributor
|
74
95
|
@object_ds.insert_contributor
|
@@ -110,6 +131,12 @@ describe HydraPbcore::Datastream::Document do
|
|
110
131
|
@object_ds.insert_place("inserted")
|
111
132
|
@object_ds.insert_date("2012-11-11")
|
112
133
|
|
134
|
+
@object_ds.insert_relation("inserted", 'Archival Collection')
|
135
|
+
@object_ds.insert_relation("inserted", 'Event Series')
|
136
|
+
@object_ds.insert_relation("inserted", 'Archival Series')
|
137
|
+
@object_ds.insert_relation("inserted", 'Accession Number')
|
138
|
+
@object_ds.insert_relation("inserted", 'Collection Number')
|
139
|
+
|
113
140
|
@object_ds.pbc_id = "inserted"
|
114
141
|
@object_ds.main_title = "inserted"
|
115
142
|
@object_ds.alternative_title = "inserted"
|
@@ -135,15 +162,11 @@ describe HydraPbcore::Datastream::Document do
|
|
135
162
|
@object_ds.publisher_role = "inserted"
|
136
163
|
@object_ds.note = "inserted"
|
137
164
|
@object_ds.rights_summary = "inserted"
|
138
|
-
@object_ds.archival_collection = "inserted"
|
139
|
-
@object_ds.archival_series = "inserted"
|
140
|
-
@object_ds.collection_number = "inserted"
|
141
|
-
@object_ds.accession_number = "inserted"
|
142
165
|
end
|
143
166
|
|
144
|
-
it "solr document should match an
|
167
|
+
it "solr document should match an exemplar" do
|
145
168
|
save_template @object_ds.to_solr.to_xml, "document_solr.xml"
|
146
|
-
|
169
|
+
tmp_file_should_match_exemplar("document_solr.xml")
|
147
170
|
end
|
148
171
|
|
149
172
|
describe "solr dates" do
|
@@ -162,7 +185,7 @@ describe HydraPbcore::Datastream::Document do
|
|
162
185
|
|
163
186
|
it "xml document should match an exmplar" do
|
164
187
|
save_template @object_ds.to_xml, "document.xml"
|
165
|
-
|
188
|
+
tmp_file_should_match_exemplar("document.xml")
|
166
189
|
end
|
167
190
|
|
168
191
|
it "xml document should validate against the PBCore schema" do
|
@@ -3,28 +3,8 @@
|
|
3
3
|
<pbcoreTitle titleType="Main"/>
|
4
4
|
<pbcoreDescription descriptionType="Description" descriptionTypeSource="pbcoreDescription/descriptionType" descriptionTypeRef="http://pbcore.org/vocabularies/pbcoreDescription/descriptionType#description" annotation="Summary"/>
|
5
5
|
<pbcoreDescription descriptionType="Table of Contents" descriptionTypeSource="pbcoreDescription/descriptionType" descriptionTypeRef="http://pbcore.org/vocabularies/pbcoreDescription/descriptionType#table-of-contents" annotation="Parts List"/>
|
6
|
-
<pbcoreRelation>
|
7
|
-
<pbcoreRelationType source="PBCore relationType" ref="http://pbcore.org/vocabularies/relationType#is-part-of">Is Part Of</pbcoreRelationType>
|
8
|
-
<pbcoreRelationIdentifier annotation="Event Series"/>
|
9
|
-
</pbcoreRelation>
|
10
|
-
<pbcoreRelation>
|
11
|
-
<pbcoreRelationType source="PBCore relationType" ref="http://pbcore.org/vocabularies/relationType#is-part-of">Is Part Of</pbcoreRelationType>
|
12
|
-
<pbcoreRelationIdentifier annotation="Archival Collection"/>
|
13
|
-
</pbcoreRelation>
|
14
|
-
<pbcoreRelation>
|
15
|
-
<pbcoreRelationType source="PBCore relationType" ref="http://pbcore.org/vocabularies/relationType#is-part-of">Is Part Of</pbcoreRelationType>
|
16
|
-
<pbcoreRelationIdentifier annotation="Archival Series"/>
|
17
|
-
</pbcoreRelation>
|
18
|
-
<pbcoreRelation>
|
19
|
-
<pbcoreRelationType source="PBCore relationType" ref="http://pbcore.org/vocabularies/relationType#is-part-of">Is Part Of</pbcoreRelationType>
|
20
|
-
<pbcoreRelationIdentifier annotation="Collection Number"/>
|
21
|
-
</pbcoreRelation>
|
22
|
-
<pbcoreRelation>
|
23
|
-
<pbcoreRelationType source="PBCore relationType" ref="http://pbcore.org/vocabularies/relationType#is-part-of">Is Part Of</pbcoreRelationType>
|
24
|
-
<pbcoreRelationIdentifier annotation="Accession Number"/>
|
25
|
-
</pbcoreRelation>
|
26
6
|
<pbcoreRightsSummary>
|
27
7
|
<rightsSummary/>
|
28
8
|
</pbcoreRightsSummary>
|
29
9
|
<pbcoreAnnotation annotationType="Notes"/>
|
30
|
-
</pbcoreDescriptionDocument>
|
10
|
+
</pbcoreDescriptionDocument>
|
data/spec/instantiation_spec.rb
CHANGED
@@ -98,7 +98,7 @@ describe HydraPbcore::Datastream::Instantiation do
|
|
98
98
|
@digital.insert_previous("inserted")
|
99
99
|
|
100
100
|
save_template @digital.to_xml, "digital_instantiation.xml"
|
101
|
-
|
101
|
+
tmp_file_should_match_exemplar("digital_instantiation.xml")
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should have different essenceTrackStandard nodes" do
|
@@ -159,7 +159,7 @@ describe HydraPbcore::Datastream::Instantiation do
|
|
159
159
|
|
160
160
|
it "should match an exmplar" do
|
161
161
|
save_template @digital.to_solr.to_xml, "digital_instantiation_solr.xml"
|
162
|
-
|
162
|
+
tmp_file_should_match_exemplar("digital_instantiation_solr.xml")
|
163
163
|
end
|
164
164
|
|
165
165
|
it "should display dates as they were entered" do
|
@@ -214,7 +214,7 @@ describe HydraPbcore::Datastream::Instantiation do
|
|
214
214
|
@physical.cleaning_note = "inserted"
|
215
215
|
@physical.condition_note = "inserted"
|
216
216
|
save_template @physical.to_xml, "physical_instantiation.xml"
|
217
|
-
|
217
|
+
tmp_file_should_match_exemplar("physical_instantiation.xml")
|
218
218
|
end
|
219
219
|
|
220
220
|
describe "solr documents" do
|
@@ -241,7 +241,7 @@ describe HydraPbcore::Datastream::Instantiation do
|
|
241
241
|
|
242
242
|
it "should match an exmplar" do
|
243
243
|
save_template @physical.to_solr.to_xml, "physical_instantiation_solr.xml"
|
244
|
-
|
244
|
+
tmp_file_should_match_exemplar("physical_instantiation_solr.xml")
|
245
245
|
end
|
246
246
|
|
247
247
|
it "should display dates as they were entered" do
|
@@ -259,4 +259,4 @@ describe HydraPbcore::Datastream::Instantiation do
|
|
259
259
|
|
260
260
|
end
|
261
261
|
|
262
|
-
end
|
262
|
+
end
|
@@ -14,7 +14,7 @@ describe "Converting" do
|
|
14
14
|
doc = HydraPbcore::Datastream::Deprecated::Document.from_xml(integration_fixture "document_rrhof_524.xml")
|
15
15
|
doc.to_document
|
16
16
|
save_template doc.to_xml, "converted_rrhof_524.xml"
|
17
|
-
|
17
|
+
tmp_file_should_match_exemplar("converted_rrhof_524.xml")
|
18
18
|
end
|
19
19
|
it "should raise an error with the wrong class" do
|
20
20
|
lambda { @fake.to_document }.should raise_error
|
@@ -27,7 +27,7 @@ describe "Converting" do
|
|
27
27
|
inst = doc.to_physical_instantiation
|
28
28
|
inst.should be_kind_of HydraPbcore::Datastream::Instantiation
|
29
29
|
save_template inst.to_xml, "converted_rrhof_524_instantiation.xml"
|
30
|
-
|
30
|
+
tmp_file_should_match_exemplar("converted_rrhof_524_instantiation.xml")
|
31
31
|
end
|
32
32
|
it "should raise an error with the wrong class" do
|
33
33
|
lambda { @fake.to_document }.should raise_error
|
@@ -39,7 +39,7 @@ describe "Converting" do
|
|
39
39
|
inst = HydraPbcore::Datastream::Deprecated::Instantiation.from_xml(integration_fixture "instantiation_rrhof_1184.xml")
|
40
40
|
inst.to_instantiation
|
41
41
|
save_template inst.to_xml, "converted_instantiation_rrhof_1184.xml"
|
42
|
-
|
42
|
+
tmp_file_should_match_exemplar("converted_instantiation_rrhof_1184.xml")
|
43
43
|
end
|
44
44
|
it "should raise an error with the wrong class" do
|
45
45
|
lambda { @fake.to_document }.should raise_error
|
@@ -52,7 +52,7 @@ describe "Converting" do
|
|
52
52
|
doc = HydraPbcore::Datastream::Deprecated::DigitalDocument.from_xml(integration_fixture file)
|
53
53
|
doc.clean_document
|
54
54
|
save_template doc.to_xml, ("converted_"+file)
|
55
|
-
|
55
|
+
tmp_file_should_match_exemplar(("converted_"+file))
|
56
56
|
save_template doc.to_pbcore_xml, "valid_pbcore.xml"
|
57
57
|
doc.valid?.should == []
|
58
58
|
end
|
@@ -63,11 +63,11 @@ describe "Converting" do
|
|
63
63
|
doc.to_document
|
64
64
|
doc.clean_document
|
65
65
|
save_template doc.to_xml, ("converted_"+file)
|
66
|
-
|
66
|
+
tmp_file_should_match_exemplar(("converted_"+file))
|
67
67
|
save_template doc.to_pbcore_xml, "valid_pbcore.xml"
|
68
68
|
doc.valid?.should == []
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
end
|
73
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -35,15 +35,12 @@ def save_template input, filename
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# Tests if a file in spec/fixtures is the same as the file in tmp
|
38
|
-
def
|
39
|
-
f = Nokogiri::XML(fixture
|
40
|
-
s = Nokogiri::XML(sample
|
41
|
-
|
42
|
-
f, s,
|
43
|
-
opts = { :element_order => false, :normalize_whitespace => true }
|
44
|
-
)
|
38
|
+
def tmp_file_should_match_exemplar(file)
|
39
|
+
f = Nokogiri::XML(fixture(file))
|
40
|
+
s = Nokogiri::XML(sample(file))
|
41
|
+
f.should be_equivalent_to s
|
45
42
|
end
|
46
43
|
|
47
44
|
def random_string
|
48
45
|
(0...50).map{ ('a'..'z').to_a[rand(26)] }.join
|
49
|
-
end
|
46
|
+
end
|
data/spec/templates_spec.rb
CHANGED
@@ -16,16 +16,16 @@ describe HydraPbcore::Templates do
|
|
16
16
|
describe "#digital_instantiation" do
|
17
17
|
it "should return a template for a digital instantiaion" do
|
18
18
|
save_template @test.digital_instantiation, "digital_instantiation_template.xml"
|
19
|
-
|
19
|
+
tmp_file_should_match_exemplar("digital_instantiation_template.xml")
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "#physical_instantiation" do
|
24
24
|
it "should create a template for physical instantiaions such as tapes" do
|
25
25
|
save_template @test.physical_instantiation, "physical_instantiation_template.xml"
|
26
|
-
|
26
|
+
tmp_file_should_match_exemplar("physical_instantiation_template.xml")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
|
31
|
-
end
|
31
|
+
end
|
data/tmp/.gitkeep
ADDED
File without changes
|
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:
|
4
|
+
version: 2.0.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-
|
12
|
+
date: 2013-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -179,24 +179,25 @@ extensions: []
|
|
179
179
|
extra_rdoc_files: []
|
180
180
|
files:
|
181
181
|
- .gitignore
|
182
|
-
- .rvmrc
|
183
182
|
- Gemfile
|
184
183
|
- LICENSE
|
185
184
|
- README.md
|
186
185
|
- Rakefile
|
187
186
|
- hydra-pbcore.gemspec
|
188
187
|
- lib/hydra-pbcore.rb
|
189
|
-
- lib/
|
190
|
-
- lib/
|
191
|
-
- lib/
|
192
|
-
- lib/
|
193
|
-
- lib/
|
194
|
-
- lib/
|
195
|
-
- lib/
|
196
|
-
- lib/
|
197
|
-
- lib/
|
198
|
-
- lib/
|
199
|
-
- lib/
|
188
|
+
- lib/hydra_pbcore/behaviors.rb
|
189
|
+
- lib/hydra_pbcore/conversions.rb
|
190
|
+
- lib/hydra_pbcore/datastream.rb
|
191
|
+
- lib/hydra_pbcore/datastream/deprecated.rb
|
192
|
+
- lib/hydra_pbcore/datastream/deprecated/digital_document.rb
|
193
|
+
- lib/hydra_pbcore/datastream/deprecated/document.rb
|
194
|
+
- lib/hydra_pbcore/datastream/deprecated/instantiation.rb
|
195
|
+
- lib/hydra_pbcore/datastream/document.rb
|
196
|
+
- lib/hydra_pbcore/datastream/instantiation.rb
|
197
|
+
- lib/hydra_pbcore/mapper.rb
|
198
|
+
- lib/hydra_pbcore/methods.rb
|
199
|
+
- lib/hydra_pbcore/templates.rb
|
200
|
+
- lib/hydra_pbcore/version.rb
|
200
201
|
- spec/deprecated/digital_document_spec.rb
|
201
202
|
- spec/deprecated/document_spec.rb
|
202
203
|
- spec/deprecated/instantiation_spec.rb
|
@@ -233,6 +234,7 @@ files:
|
|
233
234
|
- spec/mapper_spec.rb
|
234
235
|
- spec/spec_helper.rb
|
235
236
|
- spec/templates_spec.rb
|
237
|
+
- tmp/.gitkeep
|
236
238
|
homepage: ''
|
237
239
|
licenses: []
|
238
240
|
post_install_message:
|
@@ -294,4 +296,3 @@ test_files:
|
|
294
296
|
- spec/mapper_spec.rb
|
295
297
|
- spec/spec_helper.rb
|
296
298
|
- spec/templates_spec.rb
|
297
|
-
has_rdoc:
|
data/.rvmrc
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
-
# development environment upon cd'ing into the directory
|
5
|
-
|
6
|
-
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
-
# Only full ruby name is supported here, for short names use:
|
8
|
-
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
-
environment_id="ruby-1.9.3-p286@hydra-pbcore"
|
10
|
-
|
11
|
-
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
-
# rvmrc_rvm_version="1.14.3 (version)" # 1.10.1 seams as a safe start
|
13
|
-
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
-
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
-
# return 1
|
16
|
-
# }
|
17
|
-
|
18
|
-
# First we attempt to load the desired environment directly from the environment
|
19
|
-
# file. This is very fast and efficient compared to running through the entire
|
20
|
-
# CLI and selector. If you want feedback on which environment was used then
|
21
|
-
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
-
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
-
then
|
25
|
-
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
-
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
-
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
-
else
|
29
|
-
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
-
rvm --create "$environment_id" || {
|
31
|
-
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
-
return 1
|
33
|
-
}
|
34
|
-
fi
|
35
|
-
|
36
|
-
# If you use bundler, this might be useful to you:
|
37
|
-
# if [[ -s Gemfile ]] && {
|
38
|
-
# ! builtin command -v bundle >/dev/null ||
|
39
|
-
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
-
# }
|
41
|
-
# then
|
42
|
-
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
-
# gem install bundler
|
44
|
-
# fi
|
45
|
-
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
-
# then
|
47
|
-
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
-
# fi
|
data/lib/hydra-pbcore/version.rb
DELETED