valkyrie-shrine 0.1.1 → 0.2.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: '0908bc4244f8aada0a0016f0409a30ed7bcb16742796cdaefce8b682a14909f8'
4
- data.tar.gz: c3f4f1e9d9b9291ac1171f53575bf9240094b0b774b9617f2b6cb2c39ee8172e
3
+ metadata.gz: 2ff75a9dea7b1a3e920b1fa9152fad9e109414bb047afe1265111e3746e73671
4
+ data.tar.gz: 5f913f31d5499c272974669d9a30b478a367545daee706bc5580031e4b551c9c
5
5
  SHA512:
6
- metadata.gz: 7e9d584eb2b9712515a49b5a0b466dee46990362c6cc6e5a1d0deae02ae97cb6e16445b56080582e6899bd6d679a2f45aece574a3b37af2eb7cad89a22f43996
7
- data.tar.gz: 27dd5f1a9121264f91aee77bb7626145767cb0f9673bed525208e905580d650ea8c05dea7fa80305eada198634ed443a4bdc548ef86a0fc619e3d44bf05d0a64
6
+ metadata.gz: aff9fadbab0b342f8180114f0ea38d51a93f8935e491bb5b35b1185c186efd33a94748faacc8e0a36541723cd37891dd72068c702f2227669cb92b733ec57bc4
7
+ data.tar.gz: cef14742ca6ea9edaa892fdb16636c4312f174781b7014632b8cc4b331036e8a01f3b31b92126fd381c0ee35d8394c1c957a7d172410336556a2f667096bfe7e
data/README.md CHANGED
@@ -21,8 +21,8 @@ Follow the Valkyrie [README](https://github.com/samvera-labs/valkyrie) to get a
21
21
  # config/initializers/valkyrie.rb
22
22
  require 'shrine/storage/s3'
23
23
  require 'shrine/storage/file_system'
24
- require 'valkyrie/storage/shrine/s3_checksum'
25
- require 'valkyrie/storage/shrine/file_system_checksum'
24
+ require 'valkyrie/storage/shrine/checksum/s3'
25
+ require 'valkyrie/storage/shrine/checksum/file_system'
26
26
 
27
27
  Shrine.storages = {
28
28
  file: Shrine::Storage::FileSystem.new("public", prefix: "uploads"),
@@ -38,6 +38,8 @@ Follow the Valkyrie [README](https://github.com/samvera-labs/valkyrie) to get a
38
38
  )
39
39
  ```
40
40
 
41
+ Then proceed to configure your application following the [Valkyrie documentation](https://github.com/samvera-labs/valkyrie#sample-configuration-configvalkyrieyml)
42
+
41
43
  ## Development
42
44
 
43
45
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -46,4 +48,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
46
48
 
47
49
  ## Contributing
48
50
 
49
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/valkyrie-shrine.
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/samvera-labs/valkyrie-shrine.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Valkyrie
4
4
  module Shrine
5
- VERSION = "0.1.1"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -8,9 +8,20 @@ module Valkyrie
8
8
  class Shrine
9
9
  PROTOCOL = 'shrine://'
10
10
 
11
- attr_reader :shrine, :verifier
11
+ attr_reader :shrine, :verifier, :path_generator
12
12
 
13
- def initialize(shrine_storage, verifier = nil)
13
+ class IDPathGenerator
14
+ def initialize(base_path: nil)
15
+ @base_path = base_path
16
+ end
17
+
18
+ def generate(resource:, file:, original_filename:)
19
+ resource.id.to_s
20
+ end
21
+ end
22
+
23
+ def initialize(shrine_storage, verifier = nil, path_generator = IDPathGenerator)
24
+ @path_generator = path_generator.new(base_path: "")
14
25
  @shrine = shrine_storage
15
26
  if verifier.nil?
16
27
  try_to_find_verifier
@@ -27,7 +38,7 @@ module Valkyrie
27
38
  # @raise Valkyrie::Shrine::IntegrityError if #verify_checksum is defined
28
39
  # on the shrine object and the file and result digests do not match
29
40
  def upload(file:, original_filename:, resource:, **upload_options)
30
- identifier = resource.id.to_s
41
+ identifier = path_generator.generate(resource: resource, file: file, original_filename: original_filename).to_s
31
42
  shrine.upload(file, identifier, **upload_options)
32
43
  find_by(id: "#{PROTOCOL}#{identifier}").tap do |result|
33
44
  if verifier
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_dependency 'aws-sdk-s3', '~> 1'
27
27
  spec.add_dependency 'shrine', '~> 2.0'
28
- spec.add_dependency 'valkyrie', '~> 2.0.0.RC3'
28
+ spec.add_dependency 'valkyrie', '> 1.0'
29
29
 
30
30
  spec.add_development_dependency 'bixby', '~> 2.0.0.pre.beta1'
31
31
  spec.add_development_dependency 'bundler', '~> 2.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valkyrie-shrine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brendan Quinn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-07 00:00:00.000000000 Z
11
+ date: 2019-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: valkyrie
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.0.RC3
47
+ version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.0.RC3
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bixby
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  requirements: []
211
- rubygems_version: 3.0.2
211
+ rubygems_version: 3.0.3
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: Shrine storage adapter for Valkyrie