valkyrie 2.0.0.RC7 → 2.0.0.RC8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -6
- data/lib/valkyrie/specs/shared_specs/storage_adapter.rb +14 -1
- data/lib/valkyrie/storage/disk.rb +2 -1
- data/lib/valkyrie/storage/fedora.rb +26 -15
- data/lib/valkyrie/storage/memory.rb +2 -1
- data/lib/valkyrie/version.rb +1 -1
- data/valkyrie.gemspec +2 -1
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1242297f1c266e9f2ac26d998acc53d5336b40f8a5eba9af2fb48700264a7354
|
4
|
+
data.tar.gz: 3f3e3f76fad663011aec778d5834d209160fe6c1327e23fdb6fa54548e999229
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33acf17faa1554a6a3b493f9df4c64b8e4ce006d8f83c2c032057805ecb59e08465cb9a197f92231ef96a4e4f1c64eb9f1a727c4049d66f792f228c466d6bfc9
|
7
|
+
data.tar.gz: a2bd7732e83f4f81ab394e62429c78929a515faf5bc4715cdf9b6afd6881f9fb01091e9dcfe1f7f656e5d7f36cb1e4a0f189f6bb67dd363e4c9f7fcde9eaea69
|
data/CHANGELOG.md
CHANGED
@@ -70,7 +70,21 @@ involved for their contributions in the last year:
|
|
70
70
|
[stkenny](https://github.com/stkenny)
|
71
71
|
[tpendragon](https://github.com/tpendragon)
|
72
72
|
|
73
|
-
# v1.
|
73
|
+
# v1.7.0 2019-05-29
|
74
|
+
|
75
|
+
## Changes since last release
|
76
|
+
|
77
|
+
* Permit storage adapters to have arbitrary arguments to #upload.
|
78
|
+
[jrgriffiniii](https://github.com/jrgriffiniii)
|
79
|
+
* Storage adapters can now all upload regular IO objects.
|
80
|
+
[tpendragon](https://github.com/tpendragon)
|
81
|
+
* Fedora Storage Adapter has a configurable `resource_uri_transformer` for going
|
82
|
+
from a `Resource` to a Fedora path.
|
83
|
+
[elrayle](https://github.com/elrayle)
|
84
|
+
* Improve Gem metadata and allow Bundler 2
|
85
|
+
[jcoyne](https://github.com/jcoyne)
|
86
|
+
|
87
|
+
# v1.6.0 2019-04-17
|
74
88
|
|
75
89
|
## Changes since last release
|
76
90
|
|
@@ -88,7 +102,7 @@ this release:
|
|
88
102
|
[escowles](https://github.com/escowles)
|
89
103
|
[no-reply](https://github.com/no-reply)
|
90
104
|
|
91
|
-
# v1.5.1
|
105
|
+
# v1.5.1 2019-02-08
|
92
106
|
|
93
107
|
## Changes since last release
|
94
108
|
|
@@ -101,7 +115,7 @@ this release:
|
|
101
115
|
[cjcolvar](https://github.com/cjcolvar)
|
102
116
|
[escowles](https://github.com/escowles)
|
103
117
|
|
104
|
-
# v1.5.0
|
118
|
+
# v1.5.0 2019-02-06
|
105
119
|
|
106
120
|
## Changes since last release
|
107
121
|
|
@@ -148,7 +162,7 @@ this release:
|
|
148
162
|
[no-reply](https://github.com/no-reply)
|
149
163
|
[revgum](https://github.com/revgum)
|
150
164
|
|
151
|
-
# v1.5.0 RC2
|
165
|
+
# v1.5.0 RC2 2019-02-01
|
152
166
|
|
153
167
|
## Changes since last release
|
154
168
|
|
@@ -159,7 +173,7 @@ Additional thanks to the following for code review:
|
|
159
173
|
|
160
174
|
[mjgiarlo](https://github.com/mjgiarlo)
|
161
175
|
|
162
|
-
# v1.5.0 RC1
|
176
|
+
# v1.5.0 RC1 2019-02-01
|
163
177
|
|
164
178
|
## Changes since last release
|
165
179
|
|
@@ -203,7 +217,7 @@ this release:
|
|
203
217
|
[no-reply](https://github.com/no-reply)
|
204
218
|
[revgum](https://github.com/revgum)
|
205
219
|
|
206
|
-
# v1.4.0
|
220
|
+
# v1.4.0 2019-01-08
|
207
221
|
|
208
222
|
## Changes since last release.
|
209
223
|
|
@@ -17,11 +17,24 @@ RSpec.shared_examples 'a Valkyrie::StorageAdapter' do
|
|
17
17
|
it { is_expected.to respond_to(:delete).with_keywords(:id) }
|
18
18
|
it { is_expected.to respond_to(:upload).with_keywords(:file, :resource, :original_filename) }
|
19
19
|
|
20
|
+
it "can upload a file which is just an IO" do
|
21
|
+
io_file = Tempfile.new('temp_io')
|
22
|
+
io_file.write File.read(ROOT_PATH.join("spec", "fixtures", "files", "example.tif"))
|
23
|
+
io_file.rewind
|
24
|
+
sha1 = Digest::SHA1.file(io_file).to_s
|
25
|
+
|
26
|
+
resource = Valkyrie::Specs::CustomResource.new(id: SecureRandom.uuid)
|
27
|
+
|
28
|
+
expect(uploaded_file = storage_adapter.upload(file: io_file, original_filename: 'foo.jpg', resource: resource, fake_upload_argument: true)).to be_kind_of Valkyrie::StorageAdapter::File
|
29
|
+
|
30
|
+
expect(uploaded_file.valid?(digests: { sha1: sha1 })).to be true
|
31
|
+
end
|
32
|
+
|
20
33
|
it "can upload, validate, re-fetch, and delete a file" do
|
21
34
|
resource = Valkyrie::Specs::CustomResource.new(id: "test")
|
22
35
|
sha1 = Digest::SHA1.file(file).to_s
|
23
36
|
size = file.size
|
24
|
-
expect(uploaded_file = storage_adapter.upload(file: file, original_filename: 'foo.jpg', resource: resource)).to be_kind_of Valkyrie::StorageAdapter::File
|
37
|
+
expect(uploaded_file = storage_adapter.upload(file: file, original_filename: 'foo.jpg', resource: resource, fake_upload_argument: true)).to be_kind_of Valkyrie::StorageAdapter::File
|
25
38
|
|
26
39
|
expect(uploaded_file).to respond_to(:checksum).with_keywords(:digests)
|
27
40
|
expect(uploaded_file).to respond_to(:valid?).with_keywords(:size, :digests)
|
@@ -12,8 +12,9 @@ module Valkyrie::Storage
|
|
12
12
|
# @param file [IO]
|
13
13
|
# @param original_filename [String]
|
14
14
|
# @param resource [Valkyrie::Resource]
|
15
|
+
# @param _extra_arguments [Hash] additional arguments which may be passed to other adapters
|
15
16
|
# @return [Valkyrie::StorageAdapter::File]
|
16
|
-
def upload(file:, original_filename:, resource: nil)
|
17
|
+
def upload(file:, original_filename:, resource: nil, **_extra_arguments)
|
17
18
|
new_path = path_generator.generate(resource: resource, file: file, original_filename: original_filename)
|
18
19
|
FileUtils.mkdir_p(new_path.parent)
|
19
20
|
file_mover.call(file.path, new_path)
|
@@ -4,6 +4,7 @@ module Valkyrie::Storage
|
|
4
4
|
class Fedora
|
5
5
|
attr_reader :connection, :base_path, :fedora_version
|
6
6
|
PROTOCOL = 'fedora://'
|
7
|
+
SLASH = '/'
|
7
8
|
|
8
9
|
# @param [Ldp::Client] connection
|
9
10
|
def initialize(connection:, base_path: "/", fedora_version: 5)
|
@@ -29,17 +30,22 @@ module Valkyrie::Storage
|
|
29
30
|
# @param file [IO]
|
30
31
|
# @param original_filename [String]
|
31
32
|
# @param resource [Valkyrie::Resource]
|
33
|
+
# @param content_type [String] content type of file (e.g. 'image/tiff') (default='application/octet-stream')
|
34
|
+
# @param resource_uri_transformer [Lambda] transforms the resource's id (e.g. 'DDS78RK') into a uri (optional)
|
35
|
+
# @param extra_arguments [Hash] additional arguments which may be passed to other adapters
|
32
36
|
# @return [Valkyrie::StorageAdapter::StreamFile]
|
33
|
-
def upload(file:, original_filename:, resource:
|
34
|
-
|
37
|
+
def upload(file:, original_filename:, resource:, content_type: "application/octet-stream", # rubocop:disable Metrics/ParameterLists
|
38
|
+
resource_uri_transformer: default_resource_uri_transformer, **_extra_arguments)
|
39
|
+
identifier = resource_uri_transformer.call(resource, base_url) + '/original'
|
35
40
|
sha1 = fedora_version == 5 ? "sha" : "sha1"
|
36
41
|
connection.http.put do |request|
|
37
42
|
request.url identifier
|
38
|
-
request.headers['Content-Type'] =
|
43
|
+
request.headers['Content-Type'] = content_type
|
44
|
+
request.headers['Content-Length'] = file.length.to_s
|
39
45
|
request.headers['Content-Disposition'] = "attachment; filename=\"#{original_filename}\""
|
40
46
|
request.headers['digest'] = "#{sha1}=#{Digest::SHA1.file(file)}"
|
41
47
|
request.headers['link'] = "<http://www.w3.org/ns/ldp#NonRDFSource>; rel=\"type\""
|
42
|
-
io = Faraday::UploadIO.new(file
|
48
|
+
io = Faraday::UploadIO.new(file, content_type, original_filename)
|
43
49
|
request.body = io
|
44
50
|
end
|
45
51
|
find_by(id: Valkyrie::ID.new(identifier.to_s.sub(/^.+\/\//, PROTOCOL)))
|
@@ -68,6 +74,13 @@ module Valkyrie::Storage
|
|
68
74
|
end
|
69
75
|
private_constant :IOProxy
|
70
76
|
|
77
|
+
# Translate the Valkrie ID into a URL for the fedora file
|
78
|
+
# @return [RDF::URI]
|
79
|
+
def fedora_identifier(id:)
|
80
|
+
identifier = id.to_s.sub(PROTOCOL, "#{connection.http.scheme}://")
|
81
|
+
RDF::URI(identifier)
|
82
|
+
end
|
83
|
+
|
71
84
|
private
|
72
85
|
|
73
86
|
# @return [IOProxy]
|
@@ -77,19 +90,17 @@ module Valkyrie::Storage
|
|
77
90
|
IOProxy.new(response.body)
|
78
91
|
end
|
79
92
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
def id_to_uri(id)
|
88
|
-
RDF::URI("#{connection_prefix}/#{CGI.escape(id.to_s)}")
|
93
|
+
def default_resource_uri_transformer
|
94
|
+
lambda do |resource, base_url|
|
95
|
+
id = CGI.escape(resource.id.to_s)
|
96
|
+
RDF::URI.new(base_url + id)
|
97
|
+
end
|
89
98
|
end
|
90
99
|
|
91
|
-
def
|
92
|
-
|
100
|
+
def base_url
|
101
|
+
pre_divider = base_path.starts_with?(SLASH) ? '' : SLASH
|
102
|
+
post_divider = base_path.ends_with?(SLASH) ? '' : SLASH
|
103
|
+
"#{connection.http.url_prefix}#{pre_divider}#{base_path}#{post_divider}"
|
93
104
|
end
|
94
105
|
end
|
95
106
|
end
|
@@ -13,8 +13,9 @@ module Valkyrie::Storage
|
|
13
13
|
# @param file [IO]
|
14
14
|
# @param original_filename [String]
|
15
15
|
# @param resource [Valkyrie::Resource]
|
16
|
+
# @param _extra_arguments [Hash] additional arguments which may be passed to other adapters
|
16
17
|
# @return [Valkyrie::StorageAdapter::StreamFile]
|
17
|
-
def upload(file:, original_filename:, resource: nil)
|
18
|
+
def upload(file:, original_filename:, resource: nil, **_extra_arguments)
|
18
19
|
identifier = Valkyrie::ID.new("memory://#{resource.id}")
|
19
20
|
cache[identifier] = Valkyrie::StorageAdapter::StreamFile.new(id: identifier, io: file)
|
20
21
|
end
|
data/lib/valkyrie/version.rb
CHANGED
data/valkyrie.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ["tpendragon@princeton.edu"]
|
12
12
|
|
13
13
|
spec.summary = 'An ORM using the Data Mapper pattern, specifically built to solve Digital Repository use cases.'
|
14
|
+
spec.homepage = "https://github.com/samvera/valkyrie"
|
14
15
|
|
15
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
17
|
f.match(%r{^(test|spec|features)/})
|
@@ -33,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
33
34
|
spec.add_dependency 'rdf-vocab'
|
34
35
|
spec.add_dependency 'disposable', '~> 0.4.5'
|
35
36
|
|
36
|
-
spec.add_development_dependency "bundler", "
|
37
|
+
spec.add_development_dependency "bundler", "> 1.16.0", "< 3"
|
37
38
|
spec.add_development_dependency "rake", "~> 10.0"
|
38
39
|
spec.add_development_dependency "rspec", "~> 3.0"
|
39
40
|
spec.add_development_dependency "pry"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valkyrie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.RC8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trey Pendragon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -196,16 +196,22 @@ dependencies:
|
|
196
196
|
name: bundler
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
|
-
- - "
|
199
|
+
- - ">"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 1.16.0
|
202
|
+
- - "<"
|
200
203
|
- !ruby/object:Gem::Version
|
201
|
-
version: '
|
204
|
+
version: '3'
|
202
205
|
type: :development
|
203
206
|
prerelease: false
|
204
207
|
version_requirements: !ruby/object:Gem::Requirement
|
205
208
|
requirements:
|
206
|
-
- - "
|
209
|
+
- - ">"
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
version: 1.16.0
|
212
|
+
- - "<"
|
207
213
|
- !ruby/object:Gem::Version
|
208
|
-
version: '
|
214
|
+
version: '3'
|
209
215
|
- !ruby/object:Gem::Dependency
|
210
216
|
name: rake
|
211
217
|
requirement: !ruby/object:Gem::Requirement
|
@@ -552,7 +558,7 @@ files:
|
|
552
558
|
- tasks/docker.rake
|
553
559
|
- valkyrie.gemspec
|
554
560
|
- valkyrie_logo.png
|
555
|
-
homepage:
|
561
|
+
homepage: https://github.com/samvera/valkyrie
|
556
562
|
licenses: []
|
557
563
|
metadata: {}
|
558
564
|
post_install_message:
|