rof 1.0.4 → 1.0.7
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 +4 -4
- data/lib/rof/get_from_fedora.rb +33 -18
- data/lib/rof/osf_to_rof.rb +12 -11
- data/lib/rof/rdf_context.rb +3 -0
- data/lib/rof/version.rb +1 -1
- data/rof.gemspec +2 -1
- data/spec/lib/rof/cli_spec.rb +3 -0
- data/spec/lib/rof/get_from_fedora_spec.rb +22 -0
- data/spec/lib/rof/osf_to_rof_spec.rb +4 -1
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7f604446f5b61795e262bc554d46203d6ab3e00
|
4
|
+
data.tar.gz: 433b2a744b3600fe9dbd15536d95daeb2796f9f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4deb205a5a32c0a3c9765bd6e949a8e29063a23e6eb6f366012f71c75636cf0c26a3c298371651d1b646dadc4ef1002d64053c0b5345fd8574e917772d13d3bd
|
7
|
+
data.tar.gz: 173692dabcdee2fbcb720cbdc7a991ddb3d16cd39aa3e681e9370450731e9a51c6f4a093e75df9f59f30ae130dbcd27ad66a65bde412751a3f1fa6e7d9acb253
|
data/lib/rof/get_from_fedora.rb
CHANGED
@@ -47,26 +47,30 @@ module ROF
|
|
47
47
|
meta = create_meta(ds, config)
|
48
48
|
@fedora_info["#{dsname}-meta"] = meta unless meta.empty?
|
49
49
|
|
50
|
-
#
|
51
|
-
# if content is
|
52
|
-
# if content is > X bytes, save as file only if config option is given
|
50
|
+
# if content is short < X bytes and valid utf-8, save as string
|
51
|
+
# if content is > X bytes or is not utf-8, save as file only if config option is given
|
53
52
|
content = ds.datastream_content
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
abspath = File.join(config['download_path'], fname)
|
61
|
-
@fedora_info["#{dsname}-file"] = fname
|
62
|
-
if File.file?(config['download_path'])
|
63
|
-
puts "Error: --download directory #{config['download_path']} specified is an existing file."
|
64
|
-
exit 1
|
65
|
-
end
|
66
|
-
FileUtils.mkdir_p(config['download_path'])
|
67
|
-
File.open(abspath, 'w') do |f|
|
68
|
-
f.write(content)
|
53
|
+
if content.length <= 1024 || config['inline']
|
54
|
+
# this downloads the contents of the datastream into memory
|
55
|
+
content_string = content.to_s.force_encoding('UTF-8')
|
56
|
+
if content_string.valid_encoding?
|
57
|
+
@fedora_info[dsname] = content_string
|
58
|
+
next # we're done! move on to next datastream
|
69
59
|
end
|
60
|
+
# not utf-8, so keep going and see if download option was given
|
61
|
+
end
|
62
|
+
next unless config['download']
|
63
|
+
# download option was given, so save this datastream as a file
|
64
|
+
fname = "#{@fedora_info['pid']}-#{dsname}"
|
65
|
+
abspath = File.join(config['download_path'], fname)
|
66
|
+
@fedora_info["#{dsname}-file"] = fname
|
67
|
+
if File.file?(config['download_path'])
|
68
|
+
puts "Error: --download directory #{config['download_path']} specified is an existing file."
|
69
|
+
exit 1
|
70
|
+
end
|
71
|
+
FileUtils.mkdir_p(config['download_path'])
|
72
|
+
File.open(abspath, 'w') do |f|
|
73
|
+
f.write(content)
|
70
74
|
end
|
71
75
|
end
|
72
76
|
end
|
@@ -127,6 +131,10 @@ module ROF
|
|
127
131
|
|
128
132
|
root = xml_doc.root
|
129
133
|
|
134
|
+
# check for optional embargo date - set if present
|
135
|
+
this_embargo = root.elements['embargo']
|
136
|
+
rights_array['embargo-date'] = this_embargo.elements['machine'].elements['date'][0] if has_embargo_date(this_embargo)
|
137
|
+
|
130
138
|
%w(read edit).each do |access|
|
131
139
|
this_access = root.elements["//access[@type=\'#{access}\']"]
|
132
140
|
|
@@ -152,6 +160,13 @@ module ROF
|
|
152
160
|
@fedora_info['rights'] = rights_array
|
153
161
|
end
|
154
162
|
|
163
|
+
# test for embargo xml cases
|
164
|
+
def self.has_embargo_date(embargo_xml)
|
165
|
+
return false if embargo_xml == '' || embargo_xml.nil?
|
166
|
+
return false unless embargo_xml.elements['machine'].has_elements? && embargo_xml.elements['machine'].elements['date'].has_text?
|
167
|
+
true
|
168
|
+
end
|
169
|
+
|
155
170
|
def self.RELSEXT(ds, _config)
|
156
171
|
# RELS-EXT is RDF-XML - parse it
|
157
172
|
ctx = ROF::RelsExtRefContext.dup
|
data/lib/rof/osf_to_rof.rb
CHANGED
@@ -34,8 +34,8 @@ module ROF
|
|
34
34
|
def self.ttl_from_targz(config, this_project, ttl_filename)
|
35
35
|
id = this_project['project_identifier']
|
36
36
|
ttl_path = File.join(id,
|
37
|
-
|
38
|
-
|
37
|
+
'data/obj/root',
|
38
|
+
ttl_filename)
|
39
39
|
ROF::Utility.file_from_targz(File.join(config['package_dir'], id + '.tar.gz'),
|
40
40
|
ttl_path)
|
41
41
|
ttl_data = fetch_from_ttl(File.join(config['package_dir'], ttl_path))
|
@@ -55,13 +55,13 @@ module ROF
|
|
55
55
|
metadata = {}
|
56
56
|
metadata['@context'] = ROF::RdfContext.dup
|
57
57
|
# metdata derived from project ttl file
|
58
|
-
metadata['dc:created'] = Time.iso8601(ttl_data[0][@osf_map['dc:created']][0]['@value']).to_date.iso8601 +
|
58
|
+
metadata['dc:created'] = Time.iso8601(ttl_data[0][@osf_map['dc:created']][0]['@value']).to_date.iso8601 + 'Z'
|
59
59
|
metadata['dc:title'] = ttl_data[0][@osf_map['dc:title']][0]['@value']
|
60
60
|
metadata['dc:description'] =
|
61
61
|
ttl_data[0][@osf_map['dc:description']][0]['@value']
|
62
62
|
metadata['dc:subject'] = map_subject(ttl_data[0])
|
63
63
|
# metadata derived from osf_projects data, passed from UI
|
64
|
-
metadata['dc:source'] =
|
64
|
+
metadata['dc:source'] = 'https://osf.io/' + project['project_identifier']
|
65
65
|
metadata['dc:creator#adminstrative_unit'] = project['administrative_unit']
|
66
66
|
metadata['dc:creator#affiliation'] = project['affiliation']
|
67
67
|
metadata['dc:creator'] = map_creator(config, project, ttl_data)
|
@@ -101,13 +101,14 @@ module ROF
|
|
101
101
|
# sets the creator- needs to read another ttl for the User data
|
102
102
|
# only contrubutors with isBibliographic true are considered
|
103
103
|
def self.map_creator(config, project, ttl_data)
|
104
|
-
creator =
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
104
|
+
creator = []
|
105
|
+
ttl_data[0][@osf_map['hasContributor']].each do |contributor|
|
106
|
+
ttl_data.each do |item|
|
107
|
+
next unless item['@id'] == contributor['@id']
|
108
|
+
if item[@osf_map['isBibliographic']][0]['@value'] == 'true'
|
109
|
+
creator.push map_user_from_ttl(config, project,
|
110
|
+
item[@osf_map['hasUser']][0]['@id'])
|
111
|
+
end
|
111
112
|
end
|
112
113
|
end
|
113
114
|
creator
|
data/lib/rof/rdf_context.rb
CHANGED
@@ -4,9 +4,12 @@ module ROF
|
|
4
4
|
'dc' => 'http://purl.org/dc/terms/',
|
5
5
|
'ebucore' => 'http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#',
|
6
6
|
'foaf' => 'http://xmlns.com/foaf/0.1/',
|
7
|
+
'hydramata-rel' => 'http://projecthydra.org/ns/relations#',
|
7
8
|
'mrel' => 'http://id.loc.gov/vocabulary/relators/',
|
9
|
+
'ms' => 'http://www.ndltd.org/standards/metadata/etdms/1.1/',
|
8
10
|
'nd' => 'https://library.nd.edu/ns/terms/',
|
9
11
|
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
|
12
|
+
'ths' => 'http://id.loc.gov/vocabulary/relators/',
|
10
13
|
'vracore' => 'http://purl.org/vra/',
|
11
14
|
|
12
15
|
'dc:dateSubmitted' => {
|
data/lib/rof/version.rb
CHANGED
data/rof.gemspec
CHANGED
@@ -25,13 +25,14 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_dependency "rdf-turtle"
|
26
26
|
spec.add_dependency "rdf-isomorphic"
|
27
27
|
spec.add_dependency "json-ld", "~> 2.0.0"
|
28
|
-
spec.add_dependency "mime-types", "~> 2.4
|
28
|
+
spec.add_dependency "mime-types", "~> 2.4"
|
29
29
|
spec.add_dependency "rubydora", "~> 1.8.1"
|
30
30
|
spec.add_dependency "noids_client"
|
31
31
|
spec.add_dependency 'deprecation', '~> 0.1'
|
32
32
|
# only needed because we use ruby < 2.2.2 in production and that doesn't play
|
33
33
|
# nice with rails 5
|
34
34
|
spec.add_dependency 'activesupport', '< 5.0'
|
35
|
+
spec.add_dependency 'ebnf', '< 1.0.2'
|
35
36
|
|
36
37
|
spec.add_development_dependency "bundler", "~> 1.3"
|
37
38
|
spec.add_development_dependency "rake"
|
data/spec/lib/rof/cli_spec.rb
CHANGED
@@ -32,11 +32,14 @@ describe ROF::CLI do
|
|
32
32
|
"@context"=> {
|
33
33
|
"bibo"=>"http://purl.org/ontology/bibo/",
|
34
34
|
"dc"=>"http://purl.org/dc/terms/",
|
35
|
+
"ms" => 'http://www.ndltd.org/standards/metadata/etdms/1.1/',
|
35
36
|
"ebucore"=>"http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#",
|
36
37
|
"foaf"=>"http://xmlns.com/foaf/0.1/",
|
38
|
+
'hydramata-rel' => 'http://projecthydra.org/ns/relations#',
|
37
39
|
"mrel"=>"http://id.loc.gov/vocabulary/relators/",
|
38
40
|
"nd"=>"https://library.nd.edu/ns/terms/",
|
39
41
|
"rdfs"=>"http://www.w3.org/2000/01/rdf-schema#",
|
42
|
+
'ths' => 'http://id.loc.gov/vocabulary/relators/',
|
40
43
|
"vracore"=>"http://purl.org/vra/",
|
41
44
|
"dc:dateSubmitted" => {"@type" => "http://www.w3.org/2001/XMLSchema#date"},
|
42
45
|
"dc:created"=>{"@type"=>"http://www.w3.org/2001/XMLSchema#date"},
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe ROF::FedoraToRof do
|
4
|
+
it 'handles embargo presence or absence' do
|
5
|
+
|
6
|
+
rights_tests = [
|
7
|
+
['<embargo> <human/> <machine> <date>2017-08-01</date> </machine> </embargo>', true],
|
8
|
+
['<embargo> <human/> <machine> <date></date> </machine> </embargo>', false],
|
9
|
+
['<embargo> <human/> <machine/> </embargo>', false]
|
10
|
+
]
|
11
|
+
|
12
|
+
begin
|
13
|
+
|
14
|
+
rights_tests.each do |this_test|
|
15
|
+
xml_doc = REXML::Document.new(this_test[0])
|
16
|
+
root = xml_doc.root
|
17
|
+
rights = ROF::FedoraToRof.has_embargo_date(root)
|
18
|
+
expect(rights).to eq(this_test[1])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -38,9 +38,12 @@ RSpec.describe ROF::OsfToRof do
|
|
38
38
|
"dc"=>"http://purl.org/dc/terms/",
|
39
39
|
"ebucore"=>"http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#",
|
40
40
|
"foaf"=>"http://xmlns.com/foaf/0.1/",
|
41
|
+
'hydramata-rel' => 'http://projecthydra.org/ns/relations#',
|
41
42
|
"mrel"=>"http://id.loc.gov/vocabulary/relators/",
|
43
|
+
'ms' => 'http://www.ndltd.org/standards/metadata/etdms/1.1/',
|
42
44
|
"nd"=>"https://library.nd.edu/ns/terms/",
|
43
45
|
"rdfs"=>"http://www.w3.org/2000/01/rdf-schema#",
|
46
|
+
'ths' => 'http://id.loc.gov/vocabulary/relators/',
|
44
47
|
"vracore"=>"http://purl.org/vra/",
|
45
48
|
"dc:dateSubmitted"=>{"@type"=>"http://www.w3.org/2001/XMLSchema#date"},
|
46
49
|
"dc:created"=>{"@type"=>"http://www.w3.org/2001/XMLSchema#date"},
|
@@ -52,7 +55,7 @@ RSpec.describe ROF::OsfToRof do
|
|
52
55
|
"dc:source"=>"https://osf.io/b6psa",
|
53
56
|
"dc:creator#adminstrative_unit"=>"Library",
|
54
57
|
"dc:creator#affiliation"=>"OddFellows Local 151",
|
55
|
-
"dc:creator"=>"Mark Suhovecky"},
|
58
|
+
"dc:creator"=>["Mark Suhovecky"]},
|
56
59
|
"files"=>["b6psa.tar.gz"]}]
|
57
60
|
|
58
61
|
FileUtils.cp('spec/fixtures/osf/b6psa.tar.gz', tar_file)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 2.4
|
89
|
+
version: '2.4'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.4
|
96
|
+
version: '2.4'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rubydora
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - "<"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '5.0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: ebnf
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "<"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 1.0.2
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "<"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.0.2
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: bundler
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -310,6 +324,7 @@ files:
|
|
310
324
|
- spec/lib/rof/filters/file_to_url_spec.rb
|
311
325
|
- spec/lib/rof/filters/label_spec.rb
|
312
326
|
- spec/lib/rof/filters/work_spec.rb
|
327
|
+
- spec/lib/rof/get_from_fedora_spec.rb
|
313
328
|
- spec/lib/rof/ingest_spec.rb
|
314
329
|
- spec/lib/rof/ingesters/rels_ext_ingester_spec.rb
|
315
330
|
- spec/lib/rof/ingesters/rights_metadata_ingester_spec.rb
|
@@ -357,6 +372,7 @@ test_files:
|
|
357
372
|
- spec/lib/rof/filters/file_to_url_spec.rb
|
358
373
|
- spec/lib/rof/filters/label_spec.rb
|
359
374
|
- spec/lib/rof/filters/work_spec.rb
|
375
|
+
- spec/lib/rof/get_from_fedora_spec.rb
|
360
376
|
- spec/lib/rof/ingest_spec.rb
|
361
377
|
- spec/lib/rof/ingesters/rels_ext_ingester_spec.rb
|
362
378
|
- spec/lib/rof/ingesters/rights_metadata_ingester_spec.rb
|