cloudinary 1.0.46 → 1.0.47

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -34,7 +34,7 @@ Rails 3.x: edit your `Gemfile` and run `bundle install`:
34
34
 
35
35
  Rails 2.x environment.rb:
36
36
 
37
- $ config.gem 'carrierwave', :version => '~> 0.4.1'
37
+ $ config.gem 'carrierwave', :version => '~> 0.4.10'
38
38
  $ config.gem 'cloudinary'
39
39
 
40
40
 
@@ -50,19 +50,19 @@ Accessing an uploaded image with the `sample` public ID through a CDN:
50
50
 
51
51
  http://res.cloudinary.com/demo/image/upload/sample.jpg
52
52
 
53
- ![Sample](https://d3jpl91pxevbkh.cloudfront.net/demo/image/upload/w_0.4/sample.jpg "Sample")
53
+ ![Sample](https://cloudinary-a.akamaihd.net/demo/image/upload/w_0.4/sample.jpg "Sample")
54
54
 
55
55
  Generating a 150x100 version of the `sample` image and downloading it through a CDN:
56
56
 
57
57
  http://res.cloudinary.com/demo/image/upload/w_150,h_100,c_fill/sample.jpg
58
58
 
59
- ![Sample 150x100](https://d3jpl91pxevbkh.cloudfront.net/demo/image/upload/w_150,h_100,c_fill/sample.jpg "Sample 150x100")
59
+ ![Sample 150x100](https://cloudinary-a.akamaihd.net/demo/image/upload/w_150,h_100,c_fill/sample.jpg "Sample 150x100")
60
60
 
61
61
  Converting to a 150x100 PNG with rounded corners of 20 pixels:
62
62
 
63
63
  http://res.cloudinary.com/demo/image/upload/w_150,h_100,c_fill,r_20/sample.png
64
64
 
65
- ![Sample 150x150 Rounded PNG](https://d3jpl91pxevbkh.cloudfront.net/demo/image/upload/w_150,h_100,c_fill,r_20/sample.png "Sample 150x150 Rounded PNG")
65
+ ![Sample 150x150 Rounded PNG](https://cloudinary-a.akamaihd.net/demo/image/upload/w_150,h_100,c_fill,r_20/sample.png "Sample 150x150 Rounded PNG")
66
66
 
67
67
  For plenty more transformation options, see our [image transformations documentation](http://cloudinary.com/documentation/image_transformations).
68
68
 
@@ -70,7 +70,7 @@ Generating a 120x90 thumbnail based on automatic face detection of the Facebook
70
70
 
71
71
  http://res.cloudinary.com/demo/image/facebook/c_thumb,g_face,h_90,w_120/billclinton.jpg
72
72
 
73
- ![Facebook 90x120](https://d3jpl91pxevbkh.cloudfront.net/demo/image/facebook/c_thumb,g_face,h_90,w_120/billclinton.jpg "Facebook 90x200")
73
+ ![Facebook 90x120](https://cloudinary-a.akamaihd.net/demo/image/facebook/c_thumb,g_face,h_90,w_120/billclinton.jpg "Facebook 90x200")
74
74
 
75
75
  For more details, see our documentation for embedding [Facebook](http://cloudinary.com/documentation/facebook_profile_pictures) and [Twitter](http://cloudinary.com/documentation/twitter_profile_pictures) profile pictures.
76
76
 
@@ -5,21 +5,26 @@ require "yaml"
5
5
  require "uri"
6
6
  require "cloudinary/version"
7
7
  require "cloudinary/exceptions"
8
- require "cloudinary/utils"
9
- require "cloudinary/uploader"
10
- require "cloudinary/api"
11
- require "cloudinary/downloader"
12
- require "cloudinary/blob"
13
- require "cloudinary/preloaded_file"
14
- require "cloudinary/static"
15
8
  require "cloudinary/missing"
16
- require "cloudinary/carrier_wave" if defined?(::CarrierWave)
17
9
  require "cloudinary/helper" if defined?(::ActionView::Base)
18
10
  require "cloudinary/controller" if defined?(::ActionController::Base)
19
11
  require "cloudinary/railtie" if defined?(Rails) && defined?(Rails::Railtie)
20
12
  require "cloudinary/engine" if defined?(Rails) && defined?(Rails::Engine)
21
13
 
22
- module Cloudinary
14
+ module Cloudinary
15
+ autoload :Utils, 'cloudinary/utils'
16
+ autoload :Uploader, 'cloudinary/uploader'
17
+ autoload :Api, "cloudinary/api"
18
+ autoload :Downloader, "cloudinary/downloader"
19
+ autoload :Blob, "cloudinary/blob"
20
+ autoload :PreloadedFile, "cloudinary/preloaded_file"
21
+ autoload :Static, "cloudinary/static"
22
+ autoload :CarrierWave, "cloudinary/carrier_wave"
23
+
24
+ CF_SHARED_CDN = "d3jpl91pxevbkh.cloudfront.net"
25
+ AKAMAI_SHARED_CDN = "cloudinary-a.akamaihd.net"
26
+ SHARED_CDN = AKAMAI_SHARED_CDN
27
+
23
28
  FORMAT_ALIASES = {
24
29
  "jpeg" => "jpg",
25
30
  "jpe" => "jpg",
@@ -4,7 +4,8 @@ require 'zlib'
4
4
  require 'aws_cf_signer'
5
5
 
6
6
  class Cloudinary::Utils
7
- SHARED_CDN = "d3jpl91pxevbkh.cloudfront.net"
7
+ # @deprecated Use Cloudinary::SHARED_CDN
8
+ SHARED_CDN = Cloudinary::SHARED_CDN
8
9
 
9
10
  # Warning: options are being destructively updated!
10
11
  def self.generate_transformation_string(options={})
@@ -91,15 +92,16 @@ class Cloudinary::Utils
91
92
  resource_type = options.delete(:resource_type) || "image"
92
93
  version = options.delete(:version)
93
94
  format = options.delete(:format)
94
- cloud_name = options.delete(:cloud_name) || Cloudinary.config.cloud_name || raise(CloudinaryException, "Must supply cloud_name in tag or in configuration")
95
+ cloud_name = config_option_consume(options, :cloud_name) || raise(CloudinaryException, "Must supply cloud_name in tag or in configuration")
96
+
95
97
  secure = options.delete(:secure)
96
98
  ssl_detected = options.delete(:ssl_detected)
97
99
  secure = ssl_detected || Cloudinary.config.secure if secure.nil?
98
- private_cdn = options.delete(:private_cdn) || Cloudinary.config.private_cdn
99
- secure_distribution = options.delete(:secure_distribution) || Cloudinary.config.secure_distribution
100
- cname = options.delete(:cname) || Cloudinary.config.cname
101
- force_remote = options.delete(:force_remote)
102
- cdn_subdomain = options.include?(:cdn_subdomain) ? options.delete(:cdn_subdomain) : Cloudinary.config.cdn_subdomain
100
+ private_cdn = config_option_consume(options, :private_cdn)
101
+ secure_distribution = config_option_consume(options, :secure_distribution)
102
+ cname = config_option_consume(options, :cname)
103
+ force_remote = options.delete(:force_remote)
104
+ cdn_subdomain = config_option_consume(options, :cdn_subdomain)
103
105
 
104
106
  original_source = source
105
107
  return original_source if source.blank?
@@ -137,14 +139,8 @@ class Cloudinary::Utils
137
139
  if cloud_name.start_with?("/")
138
140
  prefix = "/res" + cloud_name
139
141
  else
140
- if secure && secure_distribution.nil?
141
- if private_cdn
142
- raise CloudinaryException, "secure_distribution not defined"
143
- else
144
- secure_distribution = SHARED_CDN
145
- end
146
- end
147
-
142
+ secure_distribution ||= Cloudinary::SHARED_CDN
143
+
148
144
  if secure
149
145
  prefix = "https://#{secure_distribution}"
150
146
  else
@@ -152,7 +148,7 @@ class Cloudinary::Utils
152
148
  host = cname.blank? ? "#{private_cdn ? "#{cloud_name}-" : ""}res.cloudinary.com" : cname
153
149
  prefix = "http://#{subdomain}#{host}"
154
150
  end
155
- prefix += "/#{cloud_name}" if !private_cdn
151
+ prefix += "/#{cloud_name}" if !private_cdn || (secure && secure_distribution == Cloudinary::AKAMAI_SHARED_CDN)
156
152
  end
157
153
 
158
154
  source = prefix + "/" + [resource_type,
@@ -271,4 +267,9 @@ class Cloudinary::Utils
271
267
  def self.resource_type_for_format(format)
272
268
  self.supported_image_format?(format) ? 'image' : 'raw'
273
269
  end
270
+
271
+ def self.config_option_consume(options, option_name, default_value = nil)
272
+ return options.delete(option_name) if options.include?(option_name)
273
+ return Cloudinary.config.send(option_name) || default_value
274
+ end
274
275
  end
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.0.46"
3
+ VERSION = "1.0.47"
4
4
  end
@@ -9,6 +9,8 @@ describe Cloudinary::Utils do
9
9
  config.secure_distribution = nil
10
10
  config.private_cdn = false
11
11
  config.secure = false
12
+ config.cname = nil
13
+ config.cdn_subdomains = false
12
14
  end
13
15
  end
14
16
 
@@ -28,7 +30,7 @@ describe Cloudinary::Utils do
28
30
  options = {:secure=>true}
29
31
  result = Cloudinary::Utils.cloudinary_url("test", options)
30
32
  options.should == {}
31
- result.should == "https://d3jpl91pxevbkh.cloudfront.net/test123/image/upload/test"
33
+ result.should == "https://cloudinary-a.akamaihd.net/test123/image/upload/test"
32
34
  end
33
35
 
34
36
  it "should allow overriding secure distribution if secure=true" do
@@ -46,9 +48,40 @@ describe Cloudinary::Utils do
46
48
  result.should == "https://config.secure.distribution.com/test123/image/upload/test"
47
49
  end
48
50
 
49
- it "should raise exception if secure is given with private_cdn and no secure_distribution" do
50
- Cloudinary.config.private_cdn = true
51
- lambda {Cloudinary::Utils.cloudinary_url("test", :secure=>true)}.should raise_error
51
+ it "should default to akamai if secure is given with private_cdn and no secure_distribution" do
52
+ options = {:secure=>true, :private_cdn=>true}
53
+ result = Cloudinary::Utils.cloudinary_url("test", options)
54
+ options.should == {}
55
+ result.should == "https://cloudinary-a.akamaihd.net/test123/image/upload/test"
56
+ end
57
+
58
+ it "should not add cloud_name if secure private_cdn and secure non akamai secure_distribution" do
59
+ options = {:secure=>true, :private_cdn=>true, :secure_distribution=>"something.cloudfront.net"}
60
+ result = Cloudinary::Utils.cloudinary_url("test", options)
61
+ options.should == {}
62
+ result.should == "https://something.cloudfront.net/image/upload/test"
63
+ end
64
+
65
+ it "should allow overriding private_cdn if private_cdn=true" do
66
+ result = Cloudinary::Utils.cloudinary_url("test", :private_cdn => true)
67
+ result.should == "http://test123-res.cloudinary.com/image/upload/test"
68
+ end
69
+
70
+ it "should allow overriding private_cdn if private_cdn=false" do
71
+ Cloudinary.config.private_cdn = true
72
+ result = Cloudinary::Utils.cloudinary_url("test", :private_cdn => false)
73
+ result.should == "http://res.cloudinary.com/test123/image/upload/test"
74
+ end
75
+
76
+ it "should allow overriding cname if cname=example.com" do
77
+ result = Cloudinary::Utils.cloudinary_url("test", :cname => "example.com")
78
+ result.should == "http://example.com/test123/image/upload/test"
79
+ end
80
+
81
+ it "should allow overriding cname if cname=false" do
82
+ Cloudinary.config.cname = "example.com"
83
+ result = Cloudinary::Utils.cloudinary_url("test", :cname => nil)
84
+ result.should == "http://res.cloudinary.com/test123/image/upload/test"
52
85
  end
53
86
 
54
87
  it "should use format from options" do
@@ -270,7 +303,7 @@ describe Cloudinary::Utils do
270
303
  options = {:ssl_detected=>true}
271
304
  result = Cloudinary::Utils.cloudinary_url("test", options)
272
305
  options.should == {}
273
- result.should == "https://d3jpl91pxevbkh.cloudfront.net/test123/image/upload/test"
306
+ result.should == "https://cloudinary-a.akamaihd.net/test123/image/upload/test"
274
307
  end
275
308
 
276
309
  it "should use secure if given over ssl_detected and configuration" do
@@ -286,7 +319,7 @@ describe Cloudinary::Utils do
286
319
  Cloudinary.config.secure = true
287
320
  result = Cloudinary::Utils.cloudinary_url("test", options)
288
321
  options.should == {}
289
- result.should == "https://d3jpl91pxevbkh.cloudfront.net/test123/image/upload/test"
322
+ result.should == "https://cloudinary-a.akamaihd.net/test123/image/upload/test"
290
323
  end
291
324
 
292
325
  it "should support extenal cname" do
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.46
4
+ version: 1.0.47
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-10 00:00:00.000000000 Z
14
+ date: 2013-03-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rest-client