cloudinary 1.0.47 → 1.0.48

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ require 'rest_client'
2
+
1
3
  class Cloudinary::Api
2
4
  class Error < CloudinaryException; end
3
5
  class NotFound < Error; end
@@ -103,6 +103,11 @@ module Cloudinary::CarrierWave
103
103
  def delete_remote?
104
104
  true
105
105
  end
106
+
107
+ # Let Cloudinary download remote URLs directly
108
+ def cloudinary_should_handle_remote?
109
+ true
110
+ end
106
111
 
107
112
  class CloudinaryFile
108
113
  attr_reader :identifier, :public_id, :filename, :format, :version, :storage_type, :resource_type
@@ -1,5 +1,6 @@
1
1
  module Cloudinary::CarrierWave
2
2
  def download!(uri)
3
+ return super if !self.cloudinary_should_handle_remote?
3
4
  if respond_to?(:process_uri)
4
5
  uri = process_uri(uri)
5
6
  else # Backward compatibility with old CarrierWave
@@ -210,6 +210,20 @@ module Cloudinary::FormBuilder
210
210
  end
211
211
  end
212
212
 
213
+ if defined? ActionView::Helpers::AssetUrlHelper
214
+ module ActionView::Helpers::AssetUrlHelper
215
+ alias :original_path_to_asset :path_to_asset
216
+
217
+ def path_to_asset(source, options)
218
+ options ||= {}
219
+ if Cloudinary.config.enhance_image_tag && options[:type] == :image
220
+ source = Cloudinary::Utils.cloudinary_url(source, options.merge(:type=>:asset))
221
+ end
222
+ original_path_to_asset(source, options)
223
+ end
224
+ end
225
+ end
226
+
213
227
  ActionView::Base.send :include, CloudinaryHelper
214
228
 
215
229
  begin
@@ -16,7 +16,7 @@ class Cloudinary::Uploader
16
16
 
17
17
  def self.build_upload_params(options)
18
18
  params = {:timestamp=>Time.now.to_i,
19
- :transformation => Cloudinary::Utils.generate_transformation_string(options),
19
+ :transformation => Cloudinary::Utils.generate_transformation_string(options.clone),
20
20
  :public_id=> options[:public_id],
21
21
  :callback=> options[:callback],
22
22
  :format=>options[:format],
@@ -123,7 +123,7 @@ class Cloudinary::Uploader
123
123
  :format=>options[:format],
124
124
  :async=>options[:async],
125
125
  :notification_url=>options[:notification_url],
126
- :transformation => Cloudinary::Utils.generate_transformation_string(options)
126
+ :transformation => Cloudinary::Utils.generate_transformation_string(options.clone)
127
127
  }
128
128
  end
129
129
  end
@@ -136,7 +136,7 @@ class Cloudinary::Uploader
136
136
  :type=>options[:type],
137
137
  :format=>options[:format],
138
138
  :notification_url=>options[:notification_url],
139
- :transformation => Cloudinary::Utils.generate_transformation_string(options)
139
+ :transformation => Cloudinary::Utils.generate_transformation_string(options.clone)
140
140
  }
141
141
  end
142
142
  end
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.0.47"
3
+ VERSION = "1.0.48"
4
4
  end
data/spec/utils_spec.rb CHANGED
@@ -372,4 +372,10 @@ describe Cloudinary::Utils do
372
372
  options.should == {}
373
373
  result.should == "http://res.cloudinary.com/test123/image/upload/fl_abc.def/test"
374
374
  end
375
+
376
+ it "build_upload_params should not destroy options" do
377
+ options = {:width=>100, :crop=>:scale}
378
+ Cloudinary::Uploader.build_upload_params(options)[:transformation].should == "c_scale,w_100"
379
+ options.length.should == 2
380
+ end
375
381
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudinary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.47
4
+ version: 1.0.48
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-03-14 00:00:00.000000000 Z
14
+ date: 2013-03-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rest-client