shrine-google_cloud_storage 2.0.1 → 3.0.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: fa8300b784f31a4d398fc656917be9717fb7c05668de36ab15584bad9f85ff25
4
- data.tar.gz: 967a2776f9f7246be332f21835478863b254ae9d55247ab14dafb61f715a378b
3
+ metadata.gz: a34cac58aef221675146d164422739c7479e066f0057c66535316f5c73d2e1b5
4
+ data.tar.gz: a8d23873e4df8609cd7ee8a4243bf1dc434d88b8bd6e3bd4025393139e461df9
5
5
  SHA512:
6
- metadata.gz: f53205e5d15a03e3508ff5bf235017050b0281af87095f4643e7ab072cc909195391cd97144d577814274e78d4c547ff6d9e6f9afe8818d55087f71736105dd5
7
- data.tar.gz: 81df0875f5f7ce14df49ebfb717aceecaa09c79134fe50c37b6b5fd7b1810c91c03a53221bb0484336bed9b4027d1bc9071c50ed104b007cf6dadceceffffa78
6
+ metadata.gz: a0e51f47f9fb65a594803b9ad33a7ea3cd1209767176951c0d564ca7e0988838cc046f7866331ae9179739bc597a2bfb18039c1bbaa498358f7c269967ac00ca
7
+ data.tar.gz: b11dccee9fb4ed67f2ff3e0de94f15d697a9e1dce2f2f24b00e15e3a69786c2f7e873828218584446db048c0df928e7721b2f9bb38e4915d063acf2cd6b6d22c
data/README.md CHANGED
@@ -12,8 +12,7 @@ gem "shrine-google_cloud_storage"
12
12
 
13
13
  ## Authentication
14
14
 
15
- The GCS plugin uses Google's [Project and Credential Lookup]. Please check
16
- documentation for the various ways to provide credentials.
15
+ The GCS plugin uses the `google-cloud-storage` gem. Please refer to [its documentation for setting up authentication](http://googleapis.github.io/google-cloud-ruby/docs/google-cloud-storage/latest/file.AUTHENTICATION.html).
17
16
 
18
17
  ## Usage
19
18
 
@@ -97,4 +96,3 @@ GCS_DEBUG=true
97
96
 
98
97
  [Google Cloud Storage]: https://cloud.google.com/storage/
99
98
  [Shrine]: https://github.com/shrinerb/shrine
100
- [Project and Credential Lookup]: http://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-storage/master/guides/authentication#projectandcredentiallookup
@@ -68,31 +68,27 @@ class Shrine
68
68
  end
69
69
  end
70
70
 
71
- # Downloads the file from GCS, and returns a `Tempfile`.
72
- def download(id)
73
- tempfile = Tempfile.new(["googlestorage", File.extname(id)], binmode: true)
74
- get_file(id).download tempfile.path
75
- tempfile.tap(&:open)
76
- end
77
-
78
71
  # Opens the remote file and returns it as `Down::ChunkedIO` object.
79
72
  # @return [Down::ChunkedIO] object
80
73
  # @see https://github.com/janko-m/down#downchunkedio
81
- def open(id)
74
+ def open(id, rewindable: true, **options)
82
75
  file = get_file(id)
83
76
 
77
+ raise Shrine::FileNotFound, "file #{id.inspect} not found on storage" unless file
78
+
84
79
  # create enumerator which lazily yields chunks of downloaded content
85
80
  chunks = Enumerator.new do |yielder|
86
81
  # trick to get google client to stream the download
87
82
  proc_io = ProcIO.new { |data| yielder << data }
88
- file.download(proc_io, verify: :none)
83
+ file.download(proc_io, verify: :none, **options)
89
84
  end
90
85
 
91
86
  # wrap chunks in an IO-like object which downloads when needed
92
87
  Down::ChunkedIO.new(
93
- chunks: chunks,
94
- size: file.size,
95
- data: { file: file }
88
+ chunks: chunks,
89
+ size: file.size,
90
+ rewindable: rewindable,
91
+ data: { file: file },
96
92
  )
97
93
  end
98
94
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-google_cloud_storage"
3
- gem.version = "2.0.1"
3
+ gem.version = "3.0.0"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.1"
6
6
 
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "shrine-google_cloud_storage.gemspec"]
14
14
  gem.require_path = "lib"
15
15
 
16
- gem.add_dependency "shrine", "~> 2.11"
16
+ gem.add_dependency "shrine", "~> 3.0"
17
17
  gem.add_dependency "google-cloud-storage", "~> 1.6"
18
18
 
19
19
  gem.add_development_dependency "rake"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine-google_cloud_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renaud Chaput
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-21 00:00:00.000000000 Z
11
+ date: 2019-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shrine
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.11'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.11'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: google-cloud-storage
29
29
  requirement: !ruby/object:Gem::Requirement