cloudinary 1.0.30 → 1.0.31

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,16 @@ require 'json'
4
4
 
5
5
  class Cloudinary::Uploader
6
6
 
7
+ def self.build_eager(eager)
8
+ return nil if eager.nil?
9
+ Cloudinary::Utils.build_array(eager).map do
10
+ |transformation, format|
11
+ transformation = transformation.clone
12
+ format = transformation.delete(:format) || format
13
+ [Cloudinary::Utils.generate_transformation_string(transformation), format].compact.join("/")
14
+ end.join("|")
15
+ end
16
+
7
17
  def self.build_upload_params(options)
8
18
  params = {:timestamp=>Time.now.to_i,
9
19
  :transformation => Cloudinary::Utils.generate_transformation_string(options),
@@ -13,15 +23,8 @@ class Cloudinary::Uploader
13
23
  :type=>options[:type],
14
24
  :backup=>options[:backup],
15
25
  :invalidate=>options[:invalidate],
26
+ :eager=>build_eager(options[:eager]),
16
27
  :tags=>options[:tags] && Cloudinary::Utils.build_array(options[:tags]).join(",")}
17
- if options[:eager]
18
- params[:eager] = Cloudinary::Utils.build_array(options[:eager]).map do
19
- |transformation, format|
20
- transformation = transformation.clone
21
- format = transformation.delete(:format) || format
22
- [Cloudinary::Utils.generate_transformation_string(transformation), format].compact.join("/")
23
- end.join("|")
24
- end
25
28
  params
26
29
  end
27
30
 
@@ -47,6 +50,18 @@ class Cloudinary::Uploader
47
50
  }
48
51
  end
49
52
  end
53
+
54
+ def self.explicit(public_id, options={})
55
+ call_api("explicit", options) do
56
+ {
57
+ :timestamp=>Time.now.to_i,
58
+ :type=>options[:type],
59
+ :public_id=> public_id,
60
+ :callback=> options[:callback],
61
+ :eagar=>build_eager(options[:eager]),
62
+ }
63
+ end
64
+ end
50
65
 
51
66
  TEXT_PARAMS = [:public_id, :font_family, :font_size, :font_color, :text_align, :font_weight, :font_style, :background, :opacity, :text_decoration]
52
67
  def self.text(text, options={})
@@ -76,7 +76,9 @@ class Cloudinary::Utils
76
76
  secure = ssl_detected || Cloudinary.config.secure if secure.nil?
77
77
  private_cdn = options.delete(:private_cdn) || Cloudinary.config.private_cdn
78
78
  secure_distribution = options.delete(:secure_distribution) || Cloudinary.config.secure_distribution
79
+ cname = options.delete(:cname) || Cloudinary.config.cname
79
80
  force_remote = options.delete(:force_remote)
81
+ cdn_subdomain = options.include?(:cdn_subdomain) ? options.delete(:cdn_subdomain) : Cloudinary.config.cdn_subdomain
80
82
 
81
83
  original_source = source
82
84
  return original_source if source.blank?
@@ -117,9 +119,9 @@ class Cloudinary::Utils
117
119
  if secure
118
120
  prefix = "https://#{secure_distribution}"
119
121
  else
120
- cdn_subdomain = options.include?(:cdn_subdomain) ? options[:cdn_subdomain] : Cloudinary.config.cdn_subdomain
121
122
  subdomain = cdn_subdomain ? "a#{(Zlib::crc32(source) % 5) + 1}." : ""
122
- prefix = "http://#{subdomain}#{private_cdn ? "#{cloud_name}-" : ""}res.cloudinary.com"
123
+ host = cname.blank? ? "#{private_cdn ? "#{cloud_name}-" : ""}res.cloudinary.com" : cname
124
+ prefix = "http://#{subdomain}#{host}"
123
125
  end
124
126
  prefix += "/#{cloud_name}" if !private_cdn
125
127
  end
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.0.30"
3
+ VERSION = "1.0.31"
4
4
  end
data/spec/utils_spec.rb CHANGED
@@ -259,4 +259,18 @@ describe Cloudinary::Utils do
259
259
  options.should == {}
260
260
  result.should == "https://d3jpl91pxevbkh.cloudfront.net/test123/image/upload/test"
261
261
  end
262
+
263
+ it "should support extenal cname" do
264
+ options = {:cname=>"hello.com"}
265
+ result = Cloudinary::Utils.cloudinary_url("test", options)
266
+ options.should == {}
267
+ result.should == "http://hello.com/test123/image/upload/test"
268
+ end
269
+
270
+ it "should support extenal cname with cdn_subdomain on" do
271
+ options = {:cname=>"hello.com", :cdn_subdomain=>true}
272
+ result = Cloudinary::Utils.cloudinary_url("test", options)
273
+ options.should == {}
274
+ result.should == "http://a2.hello.com/test123/image/upload/test"
275
+ end
262
276
  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.30
4
+ version: 1.0.31
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: 2012-07-12 00:00:00.000000000 Z
14
+ date: 2012-07-18 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rest-client