carrierwave-google-storage 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95ab4499bd1442d693992d49f6230361cd6652a7
4
- data.tar.gz: cb66b658581cf8bd6a4b750413202e0dc2adc059
3
+ metadata.gz: c8a4f2b75d288ec70c7d458ce3c2ff83ebe1a892
4
+ data.tar.gz: 34a785ebacdaeeff8c6aa6458a484ac3722884e8
5
5
  SHA512:
6
- metadata.gz: a2c3fce12e63fd0cfd2a2081b48865a925bef75f8c7644d294ae16e6c7abd834678e9bd4c01c2573decdcb6d9a4fd78727d783890ef183b7798d9826d70dc665
7
- data.tar.gz: ce87925cd35eaea1c39ec183a3cee79dd8b46bee9652bc2a92e8c9f6657422c98173b879d552ad65d3ad828b3a18a160215bc338102ededbcd07a9e731751a84
6
+ metadata.gz: 2b334339564c3d2995ef0707bf0a9990adb424d4f968da3f5cad689318e95b004f88213fba90b2ea046c9b17162c751cee702e70f2e5ab3102b87afdd28e77d1
7
+ data.tar.gz: 5ba58a130adccd9286265916caacf21982426eb04289ee2ca657871e044383910498f697a2c3da873252296fa0bce9dc6c6e3a93bd3ded06312d975d00f36e09
@@ -1,7 +1,7 @@
1
1
  module Carrierwave
2
2
  module Google
3
3
  module Storage
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
6
6
  end
7
7
  end
@@ -29,12 +29,13 @@ module CarrierWave
29
29
  self.file_exists = true
30
30
  yield
31
31
  rescue Exception => exception
32
+ @file = nil
32
33
  self.file_exists = false if (exception.class == ::Gcloud::Storage::ApiError) && (exception.message == "Not Found")
33
- raise exception
34
34
  end
35
35
  end
36
36
 
37
37
  def attributes
38
+ return unless file_exists
38
39
  {
39
40
  content_type: file.content_type,
40
41
  size: file.size,
@@ -63,7 +64,8 @@ module CarrierWave
63
64
  end
64
65
 
65
66
  def read
66
- (file.download CarrierWave::Support::UriFilename.filename(file.name), verify: :all).read
67
+ tmp_file = Tempfile.new(CarrierWave::Support::UriFilename.filename(file.name))
68
+ (file.download tmp_file.path, verify: :all).read
67
69
  end
68
70
 
69
71
  def store(new_file)
@@ -75,6 +77,17 @@ module CarrierWave
75
77
  file.copy("#{uploader.store_dir}/#{new_path}")
76
78
  end
77
79
 
80
+ def url(options = {})
81
+ return unless file_exists
82
+ uploader.gcloud_bucket_is_public ? public_url : authenticated_url
83
+ end
84
+
85
+ private
86
+
87
+ def bucket
88
+ bucket ||= connection.bucket(uploader.gcloud_bucket)
89
+ end
90
+
78
91
  def authenticated_url(options = {})
79
92
  file.signed_url
80
93
  end
@@ -87,16 +100,6 @@ module CarrierWave
87
100
  end
88
101
  end
89
102
 
90
- def url(options = {})
91
- uploader.gcloud_bucket_is_public ? public_url : authenticated_url
92
- end
93
-
94
- private
95
-
96
- def bucket
97
- bucket ||= connection.bucket(uploader.gcloud_bucket)
98
- end
99
-
100
103
  end
101
104
  end
102
105
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-google-storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jasdeep Singh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2016-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave