shrine-cloudinary 0.4.0 → 0.4.1

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: 7620a61d65d4509c6835b0ab21fc0f47d13cf39a
4
- data.tar.gz: d414fe35b912c48e317ed361e5a1a39082c03df7
3
+ metadata.gz: 12d3db82804fda919a833b89c383245be1231462
4
+ data.tar.gz: b6445028d38f2702ce59a5e47c8f1dbbc9e7a8ca
5
5
  SHA512:
6
- metadata.gz: 1a181bb8b94a81a687c2ce4bb671799a7445e39565d558f2538d640d841dff5f61ccfbd883a223ea428d076e873587492e57ef40a997c94f73a057d74a09cc87
7
- data.tar.gz: f81035721ad1988bbb369966a2effa215d79cf451165c90eabe5773077335493e0a15f4a90901506d90dcab8db764b97c099aaedd0a60efbbda3b135afacc191
6
+ metadata.gz: 3683b89aa2464558e29ee230fd16a7aee44cca885b9fc988c453955dfcaade3508baddcf4a94b99c4b017d7e8023e8a7459eff3ddcdb4017fdfc63f4fbd50c87
7
+ data.tar.gz: fc48706b308d4170b3161c4c1fa468129af7181c8df22c90363fcd043867f68ee62ae64cbb5d05373d776fd82065675e2c77a001478b381cd22afd5a284cf6f7
data/README.md CHANGED
@@ -54,7 +54,7 @@ side, you can generate a presign inline:
54
54
  ```erb
55
55
  <input name="file" type="file"
56
56
  class="cloudinary-fileupload" data-cloudinary-field="image_id"
57
- data-form-data="<%= Shrine.storages[:cache].presign.fields.to_json %>" ></input>
57
+ data-form-data="<%= Shrine.storages[:cache].presign.fields.to_json %>">
58
58
  ```
59
59
 
60
60
  Alternatively you can add an endpoint to your app which can generate presigns
@@ -271,7 +271,7 @@ This gem has been inspired by Cloudinary's [CarrierWave integration].
271
271
  [Cloudinary]: http://cloudinary.com/
272
272
  [Shrine]: https://github.com/janko-m/shrine
273
273
  [CarrierWave integration]: https://github.com/cloudinary/cloudinary_gem
274
- [Cloudinary options]: http://cloudinary.com/documentation/upload_images#remote_upload
274
+ [Cloudinary options]: http://cloudinary.com/documentation/image_upload_api_reference#upload
275
275
  [Rails image manipulation]: http://cloudinary.com/documentation/rails_image_manipulation
276
276
  [responsive breakpoints]: http://cloudinary.com/blog/introducing_intelligent_responsive_image_breakpoints_solutions
277
277
  [explicit API]: http://cloudinary.com/documentation/image_upload_api_reference#explicit
@@ -81,8 +81,8 @@ class Shrine
81
81
  end
82
82
 
83
83
  def presign(id = nil, **options)
84
+ upload_options = id ? {public_id: public_id(id)} : {folder: prefix}
84
85
  upload_options.update(@upload_options)
85
- upload_options.update(id ? {public_id: public_id(id)} : {folder: prefix})
86
86
 
87
87
  fields = ::Cloudinary::Uploader.build_upload_params(upload_options.merge(options))
88
88
  fields.reject! { |key, value| value.nil? || value == "" }
@@ -114,15 +114,27 @@ class Shrine
114
114
  if remote?(io)
115
115
  ::Cloudinary::Uploader.upload(io.url, **options)
116
116
  else
117
- io = io.download if io.is_a?(UploadedFile)
118
- if large?(io)
119
- ::Cloudinary::Uploader.upload_large(io, chunk_size: chunk_size, **options)
120
- else
121
- ::Cloudinary::Uploader.upload(io, **options)
117
+ to_file(io) do |file|
118
+ if large?(file)
119
+ ::Cloudinary::Uploader.upload_large(file, chunk_size: chunk_size, **options)
120
+ else
121
+ ::Cloudinary::Uploader.upload(file, **options)
122
+ end
122
123
  end
123
124
  end
124
125
  end
125
126
 
127
+ def to_file(io)
128
+ if io.is_a?(UploadedFile)
129
+ file = io.download
130
+ result = yield file
131
+ file.delete
132
+ result
133
+ else
134
+ yield io
135
+ end
136
+ end
137
+
126
138
  def remote?(io)
127
139
  io.is_a?(UploadedFile) && io.url.to_s =~ /^ftp:|^https?:/
128
140
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-cloudinary"
3
- gem.version = "0.4.0"
3
+ gem.version = "0.4.1"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.1"
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine-cloudinary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-05 00:00:00.000000000 Z
11
+ date: 2016-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shrine