active-fedora 11.5.6 → 12.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +4 -0
- data/.travis.yml +15 -0
- data/Gemfile +1 -3
- data/README.md +10 -13
- data/active-fedora.gemspec +7 -9
- data/lib/active_fedora.rb +3 -5
- data/lib/active_fedora/associations/collection_proxy.rb +0 -2
- data/lib/active_fedora/attributes/property_builder.rb +3 -1
- data/lib/active_fedora/caching_connection.rb +1 -1
- data/lib/active_fedora/errors.rb +4 -0
- data/lib/active_fedora/fedora.rb +5 -0
- data/lib/active_fedora/file.rb +3 -1
- data/lib/active_fedora/file/attributes.rb +5 -0
- data/lib/active_fedora/file_io.rb +120 -0
- data/lib/active_fedora/indexing.rb +6 -1
- data/lib/active_fedora/indexing/default_descriptors.rb +128 -0
- data/lib/active_fedora/indexing/descendant_fetcher.rb +22 -18
- data/lib/active_fedora/indexing/descriptor.rb +44 -0
- data/lib/active_fedora/indexing/field_mapper.rb +146 -0
- data/lib/active_fedora/indexing/inserter.rb +40 -0
- data/lib/active_fedora/indexing/suffix.rb +81 -0
- data/lib/active_fedora/indexing_service.rb +2 -2
- data/lib/active_fedora/ldp_resource.rb +1 -2
- data/lib/active_fedora/railtie.rb +0 -1
- data/lib/active_fedora/rdf/field_map_entry.rb +2 -2
- data/lib/active_fedora/rdf/indexing_service.rb +6 -6
- data/lib/active_fedora/relation.rb +0 -14
- data/lib/active_fedora/relation/delegation.rb +1 -2
- data/lib/active_fedora/relation/finder_methods.rb +19 -39
- data/lib/active_fedora/version.rb +1 -1
- data/lib/generators/active_fedora/config/fedora/templates/.fcrepo_wrapper +1 -1
- data/lib/generators/active_fedora/config/solr/templates/solr.yml +3 -3
- data/lib/generators/active_fedora/config/solr/templates/solr/config/schema.xml +34 -33
- data/spec/integration/base_spec.rb +39 -35
- data/spec/integration/indexing/descendant_fetcher_spec.rb +64 -0
- data/spec/integration/relation_spec.rb +1 -39
- data/spec/integration/scoping_spec.rb +17 -11
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/active_fedora/indexing/inserter_spec.rb +30 -0
- data/spec/unit/attributes_spec.rb +3 -7
- data/spec/unit/fedora_spec.rb +12 -0
- data/spec/unit/file_configurator_spec.rb +0 -9
- data/spec/unit/file_io_spec.rb +137 -0
- data/spec/unit/file_spec.rb +14 -17
- metadata +26 -30
- data/.circleci/config.yml +0 -43
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::FileIO do
|
4
|
+
# 300,000 byte test string
|
5
|
+
test_file = (0..300_000).reduce('') do |s, c| s << (c % 256).chr end
|
6
|
+
|
7
|
+
let(:file_contents) { test_file }
|
8
|
+
let(:fedora_file) {
|
9
|
+
ActiveFedora::File.new .tap do |file|
|
10
|
+
file.content = file_contents
|
11
|
+
file.save
|
12
|
+
end
|
13
|
+
}
|
14
|
+
let(:io) { described_class.new(fedora_file) }
|
15
|
+
|
16
|
+
describe "#read" do
|
17
|
+
it "reads the entire file when called without parameters" do
|
18
|
+
expect(io.read).to eql(file_contents)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns nil at end of file when requested with length" do
|
22
|
+
io.read
|
23
|
+
expect(io.read(10)).to be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns only requested amount of bytes" do
|
27
|
+
expect(io.read(5)).to eql(file_contents[0..4])
|
28
|
+
expect(io.read(5)).to eql(file_contents[5..9])
|
29
|
+
expect(io.read(100_000)).to eql(file_contents[10..100_009])
|
30
|
+
expect(io.read(200_000)).to eql(file_contents[100_010..-1])
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns an empty string if 0 bytes is requested" do
|
34
|
+
expect(io.read(0)).to eql('')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "raises an error with negative length parameter" do
|
38
|
+
expect { io.read(-1) }.to raise_error(ArgumentError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns ASCII-8BIT strings" do
|
42
|
+
expect(io.read(10).encoding.to_s).to eql("ASCII-8BIT")
|
43
|
+
expect(io.read.encoding.to_s).to eql("ASCII-8BIT")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "can take a buffer parameter" do
|
47
|
+
buffer = ''
|
48
|
+
expect(io.read(100, buffer)).to eql(file_contents[0..99])
|
49
|
+
expect(buffer).to eql(file_contents[0..99])
|
50
|
+
# IO.read will clear the buffer if it's not empty
|
51
|
+
expect(io.read(100, buffer)).to eql(file_contents[100..199])
|
52
|
+
expect(buffer).to eql(file_contents[100..199])
|
53
|
+
end
|
54
|
+
|
55
|
+
context "with empty file" do
|
56
|
+
let(:file_contents) { '' }
|
57
|
+
it "returns an empty string when called without parameters" do
|
58
|
+
expect(io.read).to eql('')
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns nil when called with length parameter" do
|
62
|
+
expect(io.read(10)).to be_nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "edge cases" do
|
67
|
+
let(:stream) {
|
68
|
+
instance_double(ActiveFedora::File::Streaming::FileBody).tap do |stream|
|
69
|
+
allow(stream).to receive(:each) do |&block|
|
70
|
+
['abcd', 'efghijkl', 'mnopqrst', 'uvwxy', 'z'].each(&block)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
}
|
74
|
+
before {
|
75
|
+
allow(fedora_file).to receive(:stream).and_return(stream)
|
76
|
+
}
|
77
|
+
let(:file_contents) { 'abcdefghijklmnopqrstuvwxyz' }
|
78
|
+
it "are handled correctly" do
|
79
|
+
expect(io.read(4)).to eql('abcd')
|
80
|
+
expect(io.read(7)).to eql('efghijk')
|
81
|
+
expect(io.read(9)).to eql('lmnopqrst')
|
82
|
+
expect(io.read(6)).to eql('uvwxyz')
|
83
|
+
expect(io.read(4)).to be_nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#pos" do
|
89
|
+
it "returns current position" do
|
90
|
+
expect(io.pos).to be(0)
|
91
|
+
io.read(5)
|
92
|
+
expect(io.pos).to be(5)
|
93
|
+
io.read(100_000)
|
94
|
+
expect(io.pos).to be(100_005)
|
95
|
+
io.read
|
96
|
+
expect(io.pos).to be(file_contents.length)
|
97
|
+
io.rewind
|
98
|
+
expect(io.pos).to be(0)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#rewind" do
|
103
|
+
it "restarts the stream" do
|
104
|
+
io.read(10)
|
105
|
+
io.rewind
|
106
|
+
expect(io.read(10)).to eql(file_contents[0..9])
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#close" do
|
111
|
+
it "closes the stream" do
|
112
|
+
io.read(10)
|
113
|
+
io.close
|
114
|
+
expect { io.read(10) } .to raise_error(IOError)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "#binmode" do
|
119
|
+
it "responds to binmode" do
|
120
|
+
expect { io.binmode } .not_to raise_error
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "#binmode?" do
|
125
|
+
it "returns true" do
|
126
|
+
expect(io.binmode?).to be(true)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "working with IO.copy_stream" do
|
131
|
+
let(:output_stream) { StringIO.new .tap(&:binmode) }
|
132
|
+
it "copies the stream" do
|
133
|
+
IO.copy_stream(io, output_stream)
|
134
|
+
expect(output_stream.string).to eql(file_contents)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
data/spec/unit/file_spec.rb
CHANGED
@@ -192,23 +192,6 @@ describe ActiveFedora::File do
|
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
|
-
context 'when file is new and content behaves like io' do
|
196
|
-
let(:file_content) { "hello world" }
|
197
|
-
|
198
|
-
before do
|
199
|
-
af_file.uri = "http://localhost:8983/fedora/rest/test/1234/abcd"
|
200
|
-
af_file.content = StringIO.new(file_content)
|
201
|
-
allow(af_file).to receive(:new_record?).and_return(true)
|
202
|
-
end
|
203
|
-
|
204
|
-
describe "#content" do
|
205
|
-
it 'can be re-read' do
|
206
|
-
expect(af_file.content.read).to eq file_content
|
207
|
-
expect(af_file.content.read).to eq file_content
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
195
|
describe "#mime_type" do
|
213
196
|
let(:parent) { ActiveFedora::Base.create }
|
214
197
|
before do
|
@@ -336,6 +319,20 @@ describe ActiveFedora::File do
|
|
336
319
|
end
|
337
320
|
end
|
338
321
|
|
322
|
+
describe "#modified_date" do
|
323
|
+
subject { af_file.modified_date }
|
324
|
+
describe "when new record" do
|
325
|
+
it { is_expected.to be_nil }
|
326
|
+
end
|
327
|
+
describe "when persisted" do
|
328
|
+
before do
|
329
|
+
af_file.content = "foo"
|
330
|
+
af_file.save!
|
331
|
+
end
|
332
|
+
it { is_expected.to be_a(DateTime) }
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
339
336
|
describe "callbacks" do
|
340
337
|
before do
|
341
338
|
class MyFile < ActiveFedora::File
|
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:
|
4
|
+
version: 12.0.0
|
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:
|
13
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -61,7 +61,7 @@ dependencies:
|
|
61
61
|
version: 4.2.4
|
62
62
|
- - "<"
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: '
|
64
|
+
version: '6'
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
version: 4.2.4
|
72
72
|
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '6'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: activemodel
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
version: '4.2'
|
82
82
|
- - "<"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: '
|
84
|
+
version: '6'
|
85
85
|
type: :runtime
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -91,7 +91,7 @@ dependencies:
|
|
91
91
|
version: '4.2'
|
92
92
|
- - "<"
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: '
|
94
|
+
version: '6'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: active-triples
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,20 +140,6 @@ dependencies:
|
|
140
140
|
- - "~>"
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: 0.7.0
|
143
|
-
- !ruby/object:Gem::Dependency
|
144
|
-
name: rdf-vocab
|
145
|
-
requirement: !ruby/object:Gem::Requirement
|
146
|
-
requirements:
|
147
|
-
- - "<"
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: 3.1.5
|
150
|
-
type: :runtime
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
requirements:
|
154
|
-
- - "<"
|
155
|
-
- !ruby/object:Gem::Version
|
156
|
-
version: 3.1.5
|
157
143
|
- !ruby/object:Gem::Dependency
|
158
144
|
name: ruby-progressbar
|
159
145
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,14 +188,14 @@ dependencies:
|
|
202
188
|
requirements:
|
203
189
|
- - ">="
|
204
190
|
- !ruby/object:Gem::Version
|
205
|
-
version: '
|
191
|
+
version: '0'
|
206
192
|
type: :development
|
207
193
|
prerelease: false
|
208
194
|
version_requirements: !ruby/object:Gem::Requirement
|
209
195
|
requirements:
|
210
196
|
- - ">="
|
211
197
|
- !ruby/object:Gem::Version
|
212
|
-
version: '
|
198
|
+
version: '0'
|
213
199
|
- !ruby/object:Gem::Dependency
|
214
200
|
name: rdoc
|
215
201
|
requirement: !ruby/object:Gem::Requirement
|
@@ -258,14 +244,14 @@ dependencies:
|
|
258
244
|
requirements:
|
259
245
|
- - "~>"
|
260
246
|
- !ruby/object:Gem::Version
|
261
|
-
version: '
|
247
|
+
version: '1.0'
|
262
248
|
type: :development
|
263
249
|
prerelease: false
|
264
250
|
version_requirements: !ruby/object:Gem::Requirement
|
265
251
|
requirements:
|
266
252
|
- - "~>"
|
267
253
|
- !ruby/object:Gem::Version
|
268
|
-
version: '
|
254
|
+
version: '1.0'
|
269
255
|
- !ruby/object:Gem::Dependency
|
270
256
|
name: fcrepo_wrapper
|
271
257
|
requirement: !ruby/object:Gem::Requirement
|
@@ -286,14 +272,14 @@ dependencies:
|
|
286
272
|
requirements:
|
287
273
|
- - "~>"
|
288
274
|
- !ruby/object:Gem::Version
|
289
|
-
version: '3.
|
275
|
+
version: '3.5'
|
290
276
|
type: :development
|
291
277
|
prerelease: false
|
292
278
|
version_requirements: !ruby/object:Gem::Requirement
|
293
279
|
requirements:
|
294
280
|
- - "~>"
|
295
281
|
- !ruby/object:Gem::Version
|
296
|
-
version: '3.
|
282
|
+
version: '3.5'
|
297
283
|
- !ruby/object:Gem::Dependency
|
298
284
|
name: rspec-its
|
299
285
|
requirement: !ruby/object:Gem::Requirement
|
@@ -367,14 +353,13 @@ dependencies:
|
|
367
353
|
description: ActiveFedora provides for creating and managing objects in the Fedora
|
368
354
|
Repository Architecture.
|
369
355
|
email:
|
370
|
-
-
|
356
|
+
- samvera-tech@googlegroups.com
|
371
357
|
executables: []
|
372
358
|
extensions: []
|
373
359
|
extra_rdoc_files:
|
374
360
|
- LICENSE
|
375
361
|
- README.md
|
376
362
|
files:
|
377
|
-
- ".circleci/config.yml"
|
378
363
|
- ".gitignore"
|
379
364
|
- ".gitmodules"
|
380
365
|
- ".mailmap"
|
@@ -382,6 +367,7 @@ files:
|
|
382
367
|
- ".rubocop.yml"
|
383
368
|
- ".rubocop_todo.yml"
|
384
369
|
- ".solr_wrapper"
|
370
|
+
- ".travis.yml"
|
385
371
|
- CONTRIBUTING.md
|
386
372
|
- CONTRIBUTORS.md
|
387
373
|
- Gemfile
|
@@ -480,6 +466,7 @@ files:
|
|
480
466
|
- lib/active_fedora/file/attributes.rb
|
481
467
|
- lib/active_fedora/file/streaming.rb
|
482
468
|
- lib/active_fedora/file_configurator.rb
|
469
|
+
- lib/active_fedora/file_io.rb
|
483
470
|
- lib/active_fedora/file_path_builder.rb
|
484
471
|
- lib/active_fedora/file_persistence.rb
|
485
472
|
- lib/active_fedora/file_relation.rb
|
@@ -491,8 +478,13 @@ files:
|
|
491
478
|
- lib/active_fedora/indexers/global_indexer.rb
|
492
479
|
- lib/active_fedora/indexers/null_indexer.rb
|
493
480
|
- lib/active_fedora/indexing.rb
|
481
|
+
- lib/active_fedora/indexing/default_descriptors.rb
|
494
482
|
- lib/active_fedora/indexing/descendant_fetcher.rb
|
483
|
+
- lib/active_fedora/indexing/descriptor.rb
|
484
|
+
- lib/active_fedora/indexing/field_mapper.rb
|
485
|
+
- lib/active_fedora/indexing/inserter.rb
|
495
486
|
- lib/active_fedora/indexing/map.rb
|
487
|
+
- lib/active_fedora/indexing/suffix.rb
|
496
488
|
- lib/active_fedora/indexing_service.rb
|
497
489
|
- lib/active_fedora/inheritable_accessors.rb
|
498
490
|
- lib/active_fedora/inheritance.rb
|
@@ -635,6 +627,7 @@ files:
|
|
635
627
|
- spec/integration/has_and_belongs_to_many_associations_spec.rb
|
636
628
|
- spec/integration/has_many_associations_spec.rb
|
637
629
|
- spec/integration/has_subresource_spec.rb
|
630
|
+
- spec/integration/indexing/descendant_fetcher_spec.rb
|
638
631
|
- spec/integration/indexing_spec.rb
|
639
632
|
- spec/integration/indirect_container_spec.rb
|
640
633
|
- spec/integration/json_serialization_spec.rb
|
@@ -656,6 +649,7 @@ files:
|
|
656
649
|
- spec/spec.opts
|
657
650
|
- spec/spec_helper.rb
|
658
651
|
- spec/support/an_active_model.rb
|
652
|
+
- spec/unit/active_fedora/indexing/inserter_spec.rb
|
659
653
|
- spec/unit/active_fedora_spec.rb
|
660
654
|
- spec/unit/aggregation/list_source_spec.rb
|
661
655
|
- spec/unit/aggregation/ordered_reader_spec.rb
|
@@ -681,6 +675,7 @@ files:
|
|
681
675
|
- spec/unit/fedora_spec.rb
|
682
676
|
- spec/unit/file/streaming_spec.rb
|
683
677
|
- spec/unit/file_configurator_spec.rb
|
678
|
+
- spec/unit/file_io_spec.rb
|
684
679
|
- spec/unit/file_path_builder_spec.rb
|
685
680
|
- spec/unit/file_spec.rb
|
686
681
|
- spec/unit/files_hash_spec.rb
|
@@ -731,7 +726,7 @@ files:
|
|
731
726
|
- spec/unit/with_metadata/metadata_node_spec.rb
|
732
727
|
homepage: https://github.com/projecthydra/active_fedora
|
733
728
|
licenses:
|
734
|
-
-
|
729
|
+
- Apache-2.0
|
735
730
|
metadata: {}
|
736
731
|
post_install_message:
|
737
732
|
rdoc_options: []
|
@@ -748,7 +743,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
748
743
|
- !ruby/object:Gem::Version
|
749
744
|
version: '0'
|
750
745
|
requirements: []
|
751
|
-
|
746
|
+
rubyforge_project:
|
747
|
+
rubygems_version: 2.6.13
|
752
748
|
signing_key:
|
753
749
|
specification_version: 4
|
754
750
|
summary: A convenience libary for manipulating documents in the Fedora Repository.
|
data/.circleci/config.yml
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
version: 2.1
|
2
|
-
orbs:
|
3
|
-
samvera: samvera/circleci-orb@0
|
4
|
-
jobs:
|
5
|
-
bundle_lint_test:
|
6
|
-
parameters:
|
7
|
-
ruby_version:
|
8
|
-
type: string
|
9
|
-
bundler_version:
|
10
|
-
type: string
|
11
|
-
default: 1.17.3
|
12
|
-
rails_version:
|
13
|
-
type: string
|
14
|
-
solr_config_path:
|
15
|
-
type: string
|
16
|
-
default: lib/generators/active_fedora/config/solr/templates/solr/config
|
17
|
-
executor:
|
18
|
-
name: 'samvera/ruby_fcrepo_solr'
|
19
|
-
ruby_version: << parameters.ruby_version >>
|
20
|
-
environment:
|
21
|
-
RAILS_VERSION: << parameters.rails_version >>
|
22
|
-
steps:
|
23
|
-
- samvera/cached_checkout
|
24
|
-
|
25
|
-
- samvera/bundle_for_gem:
|
26
|
-
ruby_version: << parameters.ruby_version >>
|
27
|
-
bundler_version: << parameters.bundler_version >>
|
28
|
-
project: 'active-fedora'
|
29
|
-
|
30
|
-
- samvera/install_solr_core:
|
31
|
-
solr_config_path: << parameters.solr_config_path >>
|
32
|
-
|
33
|
-
- samvera/rubocop
|
34
|
-
|
35
|
-
- samvera/parallel_rspec
|
36
|
-
|
37
|
-
workflows:
|
38
|
-
ci:
|
39
|
-
jobs:
|
40
|
-
- bundle_lint_test:
|
41
|
-
name: ruby2-3_rails4-2
|
42
|
-
ruby_version: 2.4.9
|
43
|
-
rails_version: 4.2.8
|