carrierwave-google-storage 0.2.1 → 0.3.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
  SHA1:
3
- metadata.gz: c8a4f2b75d288ec70c7d458ce3c2ff83ebe1a892
4
- data.tar.gz: 34a785ebacdaeeff8c6aa6458a484ac3722884e8
3
+ metadata.gz: 9b44ea3caef674bdc79ea21880533ae5ca75c967
4
+ data.tar.gz: cf6e32bc8128698cfc721440ea23a34f2a1cb3dd
5
5
  SHA512:
6
- metadata.gz: 2b334339564c3d2995ef0707bf0a9990adb424d4f968da3f5cad689318e95b004f88213fba90b2ea046c9b17162c751cee702e70f2e5ab3102b87afdd28e77d1
7
- data.tar.gz: 5ba58a130adccd9286265916caacf21982426eb04289ee2ca657871e044383910498f697a2c3da873252296fa0bce9dc6c6e3a93bd3ded06312d975d00f36e09
6
+ metadata.gz: ec79c50a119f99cf3947ee2b39fa0ebd8fb14fc05f1848df6f833ab8ecb4cb0479ee3a8e2aa5ce7f521a1934acd710bd1027a3fea53ec45b3c8512ea20c74e36
7
+ data.tar.gz: 1b5ee85ba6184c60a148db657ee9b5f3d273afdb4e18ede76a3a28541e58a9e6016ea00d0694e8005a8b203155554cb60332904455d2b37497f5343921728073
@@ -1,7 +1,7 @@
1
1
  module Carrierwave
2
2
  module Google
3
3
  module Storage
4
- VERSION = "0.2.1"
4
+ VERSION = "0.3.0"
5
5
  end
6
6
  end
7
7
  end
@@ -1,4 +1,3 @@
1
-
2
1
  module CarrierWave
3
2
  module Storage
4
3
  class Gcloud < Abstract
@@ -9,13 +9,12 @@ module CarrierWave
9
9
  delegate :content_type, :size, to: :file
10
10
 
11
11
  def initialize(uploader, connection, path)
12
- @uploader = uploader
13
- @connection = connection
14
- @path = path
12
+ @uploader, @connection, @path = uploader, connection, path
15
13
  end
16
14
 
17
15
  def file
18
16
  by_verifying_existence { @file ||= bucket.file(path) }
17
+ @file
19
18
  end
20
19
  alias_method :to_file, :file
21
20
 
@@ -29,7 +28,6 @@ module CarrierWave
29
28
  self.file_exists = true
30
29
  yield
31
30
  rescue Exception => exception
32
- @file = nil
33
31
  self.file_exists = false if (exception.class == ::Gcloud::Storage::ApiError) && (exception.message == "Not Found")
34
32
  end
35
33
  end
@@ -60,7 +58,7 @@ module CarrierWave
60
58
  end
61
59
 
62
60
  def filename(options = {})
63
- CarrierWave::Support::UriFilename.filename(file.name)
61
+ CarrierWave::Support::UriFilename.filename(file.url) if exists?
64
62
  end
65
63
 
66
64
  def read
@@ -69,7 +67,8 @@ module CarrierWave
69
67
  end
70
68
 
71
69
  def store(new_file)
72
- bucket.create_file new_file.path, "#{uploader.store_dir}/#{new_file.filename}"
70
+ new_file_path = uploader.filename ? uploader.filename : new_file.filename
71
+ bucket.create_file new_file.path, "#{uploader.store_dir}/#{new_file_path}"
73
72
  self
74
73
  end
75
74
 
@@ -81,12 +80,6 @@ module CarrierWave
81
80
  return unless file_exists
82
81
  uploader.gcloud_bucket_is_public ? public_url : authenticated_url
83
82
  end
84
-
85
- private
86
-
87
- def bucket
88
- bucket ||= connection.bucket(uploader.gcloud_bucket)
89
- end
90
83
 
91
84
  def authenticated_url(options = {})
92
85
  file.signed_url
@@ -100,6 +93,12 @@ module CarrierWave
100
93
  end
101
94
  end
102
95
 
96
+ private
97
+
98
+ def bucket
99
+ bucket ||= connection.bucket(uploader.gcloud_bucket)
100
+ end
101
+
103
102
  end
104
103
  end
105
104
  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.1
4
+ version: 0.3.0
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-05 00:00:00.000000000 Z
11
+ date: 2016-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave