valkyrie 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a009fdb760bb925b92e9ade5096b39dae461c754816df543314850a012f7a656
4
- data.tar.gz: f26925e5eb0dc7df138f81dc89ad6bb5c4444ea556ac8fedde7d73bd3e76b69e
3
+ metadata.gz: 5ac665913c03a2c8fcfe74541f13ec24fce4985a12d8ddff1491e3416f9ef9d9
4
+ data.tar.gz: d95b257f4408f318db357f023982c9bc7463ba3b3efcab698737e447dbf04966
5
5
  SHA512:
6
- metadata.gz: 6cef97cbaa3a6ecb12cfb78626d2ed5fea0d8f433ad07a4cc5a6fb145c7346447959af98456e1f620f24203924d9dd2763b8a31b0804776971182d80fd1eb23a
7
- data.tar.gz: 2bdaffa5595d88b6da9c66f64f4e64a52b1af10ae24706d40357ed9ccad5b2a49209a2a8e9f263268b719133db90383205ce910b166074c681ffbec8011498cb
6
+ metadata.gz: 465b81cf5749139e46148e2afbbc37b01636d57dbb5e940d576c1127ea8da22a57024887fc72be442e4c796e464ce70e88318a7d1302c7b182777265cf1d154c
7
+ data.tar.gz: 657348cdac69a4acf09874036f4adfd7250917e48d4a1a423f40e937affdae2be4da5366ae0f36cd43f8eaa4f14791bdd95bf7ae985fb20231fcbde4ce42eeb8
data/.circleci/config.yml CHANGED
@@ -10,7 +10,7 @@ jobs:
10
10
  type: "string"
11
11
  ruby:
12
12
  description: "Ruby version"
13
- default: "2.6.2"
13
+ default: "2.6.3"
14
14
  type: "string"
15
15
  environment:
16
16
  BUNDLE_GEMFILE: << parameters.gemfile >>
@@ -69,11 +69,11 @@ workflows:
69
69
  jobs:
70
70
  - build:
71
71
  gemfile: "gemfiles/activerecord_5_2.gemfile"
72
- ruby: 2.6.2
72
+ ruby: 2.6.3
73
73
  name: "Ruby2-6_Rails5-2"
74
74
  - build:
75
75
  gemfile: "gemfiles/activerecord_5_1.gemfile"
76
- ruby: 2.6.2
76
+ ruby: 2.6.3
77
77
  name: "Ruby2-6_Rails5-1"
78
78
  - build:
79
79
  gemfile: "gemfiles/activerecord_5_2.gemfile"
@@ -85,11 +85,11 @@ workflows:
85
85
  name: "Ruby2-5_Rails5-1"
86
86
  - build:
87
87
  gemfile: "gemfiles/activerecord_5_2.gemfile"
88
- ruby: 2.4.5
88
+ ruby: 2.4.6
89
89
  name: "Ruby2-4_Rails5-2"
90
90
  - build:
91
91
  gemfile: "gemfiles/activerecord_5_1.gemfile"
92
- ruby: 2.4.5
92
+ ruby: 2.4.6
93
93
  name: "Ruby2-4_Rails5-1"
94
94
  nightly:
95
95
  triggers:
@@ -102,11 +102,11 @@ workflows:
102
102
  jobs:
103
103
  - build:
104
104
  gemfile: "gemfiles/activerecord_5_2.gemfile"
105
- ruby: 2.6.2
105
+ ruby: 2.6.3
106
106
  name: "Ruby2-6_Rails5-2"
107
107
  - build:
108
108
  gemfile: "gemfiles/activerecord_5_1.gemfile"
109
- ruby: 2.6.2
109
+ ruby: 2.6.3
110
110
  name: "Ruby2-6_Rails5-1"
111
111
  - build:
112
112
  gemfile: "gemfiles/activerecord_5_2.gemfile"
@@ -118,9 +118,9 @@ workflows:
118
118
  name: "Ruby2-5_Rails5-1"
119
119
  - build:
120
120
  gemfile: "gemfiles/activerecord_5_2.gemfile"
121
- ruby: 2.4.5
121
+ ruby: 2.4.6
122
122
  name: "Ruby2-4_Rails5-2"
123
123
  - build:
124
124
  gemfile: "gemfiles/activerecord_5_1.gemfile"
125
- ruby: 2.4.5
125
+ ruby: 2.4.6
126
126
  name: "Ruby2-4_Rails5-1"
data/CHANGELOG.md CHANGED
@@ -1,4 +1,18 @@
1
- # v1.6.0 2018-04-17
1
+ # v1.7.0 2019-05-29
2
+
3
+ ## Changes since last release
4
+
5
+ * Permit storage adapters to have arbitrary arguments to #upload.
6
+ [jrgriffiniii](https://github.com/jrgriffiniii)
7
+ * Storage adapters can now all upload regular IO objects.
8
+ [tpendragon](https://github.com/tpendragon)
9
+ * Fedora Storage Adapter has a configurable `resource_uri_transformer` for going
10
+ from a `Resource` to a Fedora path.
11
+ [elrayle](https://github.com/elrayle)
12
+ * Improve Gem metadata and allow Bundler 2
13
+ [jcoyne](https://github.com/jcoyne)
14
+
15
+ # v1.6.0 2019-04-17
2
16
 
3
17
  ## Changes since last release
4
18
 
@@ -16,7 +30,7 @@ this release:
16
30
  [escowles](https://github.com/escowles)
17
31
  [no-reply](https://github.com/no-reply)
18
32
 
19
- # v1.5.1 2018-02-08
33
+ # v1.5.1 2019-02-08
20
34
 
21
35
  ## Changes since last release
22
36
 
@@ -29,7 +43,7 @@ this release:
29
43
  [cjcolvar](https://github.com/cjcolvar)
30
44
  [escowles](https://github.com/escowles)
31
45
 
32
- # v1.5.0 2018-02-06
46
+ # v1.5.0 2019-02-06
33
47
 
34
48
  ## Changes since last release
35
49
 
@@ -76,7 +90,7 @@ this release:
76
90
  [no-reply](https://github.com/no-reply)
77
91
  [revgum](https://github.com/revgum)
78
92
 
79
- # v1.5.0 RC2 2018-02-01
93
+ # v1.5.0 RC2 2019-02-01
80
94
 
81
95
  ## Changes since last release
82
96
 
@@ -87,7 +101,7 @@ Additional thanks to the following for code review:
87
101
 
88
102
  [mjgiarlo](https://github.com/mjgiarlo)
89
103
 
90
- # v1.5.0 RC1 2018-02-01
104
+ # v1.5.0 RC1 2019-02-01
91
105
 
92
106
  ## Changes since last release
93
107
 
@@ -131,7 +145,7 @@ this release:
131
145
  [no-reply](https://github.com/no-reply)
132
146
  [revgum](https://github.com/revgum)
133
147
 
134
- # v1.4.0 2018-01-08
148
+ # v1.4.0 2019-01-08
135
149
 
136
150
  ## Changes since last release.
137
151
 
data/README.md CHANGED
@@ -17,7 +17,7 @@ Jump in: [![Slack Status](http://slack.samvera.org/badge.svg)](http://slack.samv
17
17
  ## Primary Contacts
18
18
 
19
19
  ### Product Owner
20
- [Carolyn Cole](https://github.com/cam156)
20
+ [Katherine Lynch](https://github.com/kelynch)
21
21
 
22
22
  ### Technical Lead
23
23
  [Trey Pendragon](https://github.com/tpendragon)
@@ -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: 4)
@@ -31,17 +32,22 @@ module Valkyrie::Storage
31
32
  # @param file [IO]
32
33
  # @param original_filename [String]
33
34
  # @param resource [Valkyrie::Resource]
35
+ # @param content_type [String] content type of file (e.g. 'image/tiff') (default='application/octet-stream')
36
+ # @param resource_uri_transformer [Lambda] transforms the resource's id (e.g. 'DDS78RK') into a uri (optional)
37
+ # @param extra_arguments [Hash] additional arguments which may be passed to other adapters
34
38
  # @return [Valkyrie::StorageAdapter::StreamFile]
35
- def upload(file:, original_filename:, resource:)
36
- identifier = id_to_uri(resource.id) + '/original'
39
+ def upload(file:, original_filename:, resource:, content_type: "application/octet-stream", # rubocop:disable Metrics/ParameterLists
40
+ resource_uri_transformer: default_resource_uri_transformer, **_extra_arguments)
41
+ identifier = resource_uri_transformer.call(resource, base_url) + '/original'
37
42
  sha1 = fedora_version == 5 ? "sha" : "sha1"
38
43
  connection.http.put do |request|
39
44
  request.url identifier
40
- request.headers['Content-Type'] = file.content_type
45
+ request.headers['Content-Type'] = content_type
46
+ request.headers['Content-Length'] = file.length.to_s
41
47
  request.headers['Content-Disposition'] = "attachment; filename=\"#{original_filename}\""
42
48
  request.headers['digest'] = "#{sha1}=#{Digest::SHA1.file(file)}"
43
49
  request.headers['link'] = "<http://www.w3.org/ns/ldp#NonRDFSource>; rel=\"type\""
44
- io = Faraday::UploadIO.new(file.tempfile.path, file.content_type)
50
+ io = Faraday::UploadIO.new(file, content_type, original_filename)
45
51
  request.body = io
46
52
  end
47
53
  find_by(id: Valkyrie::ID.new(identifier.to_s.sub(/^.+\/\//, PROTOCOL)))
@@ -70,6 +76,13 @@ module Valkyrie::Storage
70
76
  end
71
77
  private_constant :IOProxy
72
78
 
79
+ # Translate the Valkrie ID into a URL for the fedora file
80
+ # @return [RDF::URI]
81
+ def fedora_identifier(id:)
82
+ identifier = id.to_s.sub(PROTOCOL, "#{connection.http.scheme}://")
83
+ RDF::URI(identifier)
84
+ end
85
+
73
86
  private
74
87
 
75
88
  # @return [IOProxy]
@@ -79,19 +92,17 @@ module Valkyrie::Storage
79
92
  IOProxy.new(response.body)
80
93
  end
81
94
 
82
- # Translate the Valkrie ID into a URL for the fedora file
83
- # @return [RDF::URI]
84
- def fedora_identifier(id:)
85
- identifier = id.to_s.sub(PROTOCOL, "#{connection.http.scheme}://")
86
- RDF::URI(identifier)
87
- end
88
-
89
- def id_to_uri(id)
90
- RDF::URI("#{connection_prefix}/#{CGI.escape(id.to_s)}")
95
+ def default_resource_uri_transformer
96
+ lambda do |resource, base_url|
97
+ id = CGI.escape(resource.id.to_s)
98
+ RDF::URI.new(base_url + id)
99
+ end
91
100
  end
92
101
 
93
- def connection_prefix
94
- "#{connection.http.url_prefix}/#{base_path}"
102
+ def base_url
103
+ pre_divider = base_path.starts_with?(SLASH) ? '' : SLASH
104
+ post_divider = base_path.ends_with?(SLASH) ? '' : SLASH
105
+ "#{connection.http.url_prefix}#{pre_divider}#{base_path}#{post_divider}"
95
106
  end
96
107
  end
97
108
  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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Valkyrie
3
- VERSION = "1.6.0"
3
+ VERSION = "1.7.0"
4
4
  end
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)/})
@@ -35,7 +36,7 @@ Gem::Specification.new do |spec|
35
36
  spec.add_dependency 'json'
36
37
  spec.add_dependency 'ldp'
37
38
 
38
- spec.add_development_dependency "bundler", "~> 1.16"
39
+ spec.add_development_dependency "bundler", "> 1.16.0", "< 3"
39
40
  spec.add_development_dependency "rake", "~> 10.0"
40
41
  spec.add_development_dependency "rspec", "~> 3.0"
41
42
  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: 1.6.0
4
+ version: 1.7.0
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-04-17 00:00:00.000000000 Z
11
+ date: 2019-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -224,16 +224,22 @@ dependencies:
224
224
  name: bundler
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - "~>"
227
+ - - ">"
228
+ - !ruby/object:Gem::Version
229
+ version: 1.16.0
230
+ - - "<"
228
231
  - !ruby/object:Gem::Version
229
- version: '1.16'
232
+ version: '3'
230
233
  type: :development
231
234
  prerelease: false
232
235
  version_requirements: !ruby/object:Gem::Requirement
233
236
  requirements:
234
- - - "~>"
237
+ - - ">"
238
+ - !ruby/object:Gem::Version
239
+ version: 1.16.0
240
+ - - "<"
235
241
  - !ruby/object:Gem::Version
236
- version: '1.16'
242
+ version: '3'
237
243
  - !ruby/object:Gem::Dependency
238
244
  name: rake
239
245
  requirement: !ruby/object:Gem::Requirement
@@ -592,7 +598,7 @@ files:
592
598
  - tasks/docker.rake
593
599
  - valkyrie.gemspec
594
600
  - valkyrie_logo.png
595
- homepage:
601
+ homepage: https://github.com/samvera/valkyrie
596
602
  licenses: []
597
603
  metadata: {}
598
604
  post_install_message: