active-fedora 7.1.0 → 7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_fedora/datastreams.rb +11 -10
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +1 -1
- data/lib/active_fedora/rdf/rdf_datastream.rb +21 -5
- data/lib/active_fedora/version.rb +1 -1
- data/spec/unit/datastream_collections_spec.rb +0 -1
- data/spec/unit/datastreams_spec.rb +11 -1
- data/spec/unit/ntriples_datastream_spec.rb +1 -1
- data/spec/unit/rdf_datastream_spec.rb +26 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 203a347c89c96ff4ad8016269999d4ea0cfa1fca
|
4
|
+
data.tar.gz: afdb1db5a4ce51cb2957b2a2f6856c24f2c3fa4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41f183bdade943a90f304d30ddc80bd34bbbb22d798718f908a2b4b61b7d8e27fe7f003c83983695ab1acbc16cd5964ea31d6623cbeb8392e007d688ba18e3f7
|
7
|
+
data.tar.gz: 1c361808bc616a266f82394f10342b7969482971d691e50b885ac20057e3c33b6a407849cd992c6a5c44d4356027d50f33afbbccf5733d83cea18b34181fcd87
|
@@ -141,18 +141,19 @@ module ActiveFedora
|
|
141
141
|
[:mimeType, :controlGroup, :dsLabel, :dsLocation, :checksumType, :versionable].each do |key|
|
142
142
|
ds.send("#{key}=".to_sym, opts[key]) unless opts[key].nil?
|
143
143
|
end
|
144
|
-
|
145
|
-
|
146
|
-
if
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
ds.dsLabel
|
144
|
+
if ds.managed? || ds.inline?
|
145
|
+
blob = opts[:blob]
|
146
|
+
if blob
|
147
|
+
if !ds.mimeType.present?
|
148
|
+
##TODO, this is all done by rubydora -- remove
|
149
|
+
ds.mimeType = blob.respond_to?(:content_type) ? blob.content_type : "application/octet-stream"
|
150
|
+
end
|
151
|
+
if !ds.dsLabel.present? && blob.respond_to?(:path)
|
152
|
+
ds.dsLabel = File.basename(blob.path)
|
153
|
+
end
|
152
154
|
end
|
155
|
+
ds.content = blob || ""
|
153
156
|
end
|
154
|
-
|
155
|
-
ds.content = blob || ""
|
156
157
|
ds
|
157
158
|
end
|
158
159
|
|
@@ -3,7 +3,7 @@ require 'rdf/ntriples'
|
|
3
3
|
module ActiveFedora
|
4
4
|
class NtriplesRDFDatastream < RDFDatastream
|
5
5
|
def self.default_attributes
|
6
|
-
super.merge(:controlGroup => 'M', :mimeType => '
|
6
|
+
super.merge(:controlGroup => 'M', :mimeType => 'application/n-triples')
|
7
7
|
end
|
8
8
|
|
9
9
|
def serialization_format
|
@@ -38,10 +38,10 @@ module ActiveFedora
|
|
38
38
|
serialize
|
39
39
|
end
|
40
40
|
|
41
|
-
def content=(
|
41
|
+
def content=(new_content)
|
42
42
|
resource.clear!
|
43
|
-
resource << deserialize(
|
44
|
-
|
43
|
+
resource << deserialize(new_content)
|
44
|
+
new_content
|
45
45
|
end
|
46
46
|
|
47
47
|
def content_changed?
|
@@ -100,10 +100,15 @@ module ActiveFedora
|
|
100
100
|
|
101
101
|
def deserialize(data=nil)
|
102
102
|
return RDF::Graph.new if new? && data.nil?
|
103
|
-
|
103
|
+
|
104
|
+
if data.nil?
|
105
|
+
data = datastream_content
|
106
|
+
elsif behaves_like_io?(data)
|
107
|
+
data = io_content(data)
|
108
|
+
end
|
104
109
|
|
105
110
|
# Because datastream_content can return nil, we should check that here.
|
106
|
-
return
|
111
|
+
return RDF::Graph.new if data.nil?
|
107
112
|
|
108
113
|
data.force_encoding('utf-8')
|
109
114
|
RDF::Graph.new << RDF::Reader.for(serialization_format).new(data)
|
@@ -113,5 +118,16 @@ module ActiveFedora
|
|
113
118
|
raise "you must override the `serialization_format' method in a subclass"
|
114
119
|
end
|
115
120
|
|
121
|
+
private
|
122
|
+
|
123
|
+
def io_content(data)
|
124
|
+
begin
|
125
|
+
data.rewind
|
126
|
+
data.read
|
127
|
+
ensure
|
128
|
+
data.rewind
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
116
132
|
end
|
117
133
|
end
|
@@ -302,7 +302,6 @@ describe ActiveFedora::DatastreamCollections do
|
|
302
302
|
datastreams["external"].first.dsid.should == "EXTERNAL1"
|
303
303
|
datastreams["external"].first.dsLocation.should == "http://myresource.com"
|
304
304
|
datastreams["external"].first.controlGroup.should == "E"
|
305
|
-
datastreams["external"].first.content.should == ""
|
306
305
|
|
307
306
|
datastreams["high"].size.should == 1
|
308
307
|
datastreams["high"].first.dsLabel.should == 'dino.jpg'
|
@@ -213,10 +213,20 @@ describe ActiveFedora::Datastreams do
|
|
213
213
|
end
|
214
214
|
|
215
215
|
it "should use the filename as a default label" do
|
216
|
-
|
216
|
+
mock_file = double(:path => '/asdf/fdsa')
|
217
217
|
ds = subject.create_datastream(ActiveFedora::Datastream, nil, {:blob => mock_file})
|
218
218
|
ds.dsLabel.should == 'fdsa'
|
219
219
|
end
|
220
|
+
|
221
|
+
it "should not set content for controlGroup 'E'" do
|
222
|
+
ds = subject.create_datastream(ActiveFedora::Datastream, nil, {controlGroup: 'E'})
|
223
|
+
expect(ds.content).to be_nil
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should not set content for controlGroup 'R'" do
|
227
|
+
ds = subject.create_datastream(ActiveFedora::Datastream, nil, {controlGroup: 'R'})
|
228
|
+
expect(ds.content).to be_nil
|
229
|
+
end
|
220
230
|
end
|
221
231
|
|
222
232
|
describe "#additional_attributes_for_external_and_redirect_control_groups" do
|
@@ -25,7 +25,7 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
25
25
|
@subject.controlGroup.should == 'M'
|
26
26
|
end
|
27
27
|
it "should have mimeType" do
|
28
|
-
@subject.mimeType.should == '
|
28
|
+
@subject.mimeType.should == 'application/n-triples'
|
29
29
|
end
|
30
30
|
it "should have dsid" do
|
31
31
|
@subject.dsid.should == 'descMetadata'
|
@@ -54,13 +54,27 @@ describe ActiveFedora::RDFDatastream do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
describe "deserialize" do
|
57
|
-
|
57
|
+
let(:ds) { ActiveFedora::NtriplesRDFDatastream.new }
|
58
|
+
subject { ds.deserialize(data) }
|
59
|
+
|
60
|
+
context "with non-utf-8 characters" do
|
58
61
|
# see https://github.com/ruby-rdf/rdf/issues/142
|
59
|
-
|
60
|
-
|
62
|
+
let(:data) { "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT') }
|
63
|
+
|
64
|
+
it "should be able to handle non-utf-8 characters" do
|
65
|
+
expect(subject.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
66
|
+
end
|
67
|
+
end
|
61
68
|
|
62
|
-
|
63
|
-
|
69
|
+
context "when the object is saved and has no content in the datastream" do
|
70
|
+
let(:data) { nil }
|
71
|
+
before do
|
72
|
+
allow(ds).to receive(:new?).and_return(false);
|
73
|
+
allow(ds).to receive(:datastream_content).and_return(nil);
|
74
|
+
end
|
75
|
+
it "should return an empty graph" do
|
76
|
+
expect(subject).to be_kind_of RDF::Graph
|
77
|
+
end
|
64
78
|
end
|
65
79
|
end
|
66
80
|
|
@@ -71,6 +85,13 @@ describe ActiveFedora::RDFDatastream do
|
|
71
85
|
ds.content = data
|
72
86
|
expect(ds.resource.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
73
87
|
end
|
88
|
+
context "when passed an IO-like object" do
|
89
|
+
let(:file) { File.new(File.join(File.dirname(__FILE__), "..", "fixtures", "dublin_core_rdf_descMetadata.nt")) }
|
90
|
+
it "should read it" do
|
91
|
+
ds.content = file
|
92
|
+
expect(ds.resource.dump(:ntriples)).to eq File.read(file.path)
|
93
|
+
end
|
94
|
+
end
|
74
95
|
end
|
75
96
|
|
76
97
|
describe 'legacy non-utf-8 characters' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.1.
|
4
|
+
version: 7.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-09-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|