cloudinary 1.0.20 → 1.0.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -109,7 +109,7 @@ module Cloudinary::CarrierWave
109
109
 
110
110
  def self.split_format(identifier)
111
111
  last_dot = identifier.rindex(".")
112
- return [public_id, nil] if last_dot.nil?
112
+ return [identifier, nil] if last_dot.nil?
113
113
  public_id = identifier[0, last_dot]
114
114
  format = identifier[last_dot+1..-1]
115
115
  return [public_id, format]
@@ -45,6 +45,15 @@ class Cloudinary::Uploader
45
45
  end
46
46
  end
47
47
 
48
+ TEXT_PARAMS = [:public_id, :font_family, :font_size, :font_color, :text_align, :font_weight, :font_style, :background, :opacity, :text_decoration]
49
+ def self.text(text, options={})
50
+ call_api("text", options) do
51
+ params = {:timestamp => Time.now.to_i, :text=>text}
52
+ TEXT_PARAMS.each{|k| params[k] = options[k] if !options[k].nil?}
53
+ params
54
+ end
55
+ end
56
+
48
57
  def self.generate_sprite(tag, options={})
49
58
  version_store = options.delete(:version_store)
50
59
 
@@ -17,15 +17,9 @@ class Cloudinary::Utils
17
17
  crop = options.delete(:crop)
18
18
  width=height=nil if crop.nil?
19
19
 
20
- x = options.delete(:x)
21
- y = options.delete(:y)
22
- radius = options.delete(:radius)
23
- default_image = options.delete(:default_image)
24
20
  background = options.delete(:background)
25
21
  background = background.sub(/^#/, 'rgb:') if background
26
-
27
- gravity = options.delete(:gravity)
28
- quality = options.delete(:quality)
22
+
29
23
  base_transformations = build_array(options.delete(:transformation))
30
24
  if base_transformations.any?{|base_transformation| base_transformation.is_a?(Hash)}
31
25
  base_transformations = base_transformations.map do
@@ -36,9 +30,13 @@ class Cloudinary::Utils
36
30
  named_transformation = base_transformations.join(".")
37
31
  base_transformations = []
38
32
  end
39
- prefix = options.delete(:prefix)
40
33
 
41
- params = {:w=>width, :h=>height, :t=>named_transformation, :c=>crop, :q=>quality, :g=>gravity, :p=>prefix, :x=>x, :y=>y, :r=>radius, :d=>default_image, :b=>background}
34
+ params = {:w=>width, :h=>height, :t=>named_transformation, :c=>crop, :b=>background}
35
+ { :x=>:x, :y=>:y, :r=>:radius, :d=>:default_image, :g=>:gravity, :q=>:quality, :p=>:prefix, :a=>:angle, :l=>:overlay }.each do
36
+ |param, option|
37
+ params[param] = options.delete(option)
38
+ end
39
+
42
40
  transformation = params.reject{|k,v| v.blank?}.map{|k,v| [k.to_s, v]}.sort_by(&:first).map{|k,v| "#{k}_#{v}"}.join(",")
43
41
  raw_transformation = options.delete(:raw_transformation)
44
42
  transformation = [transformation, raw_transformation].reject(&:blank?).join(",")
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.0.20"
3
+ VERSION = "1.0.21"
4
4
  end
data/spec/utils_spec.rb CHANGED
@@ -184,5 +184,19 @@ describe Cloudinary::Utils do
184
184
  options.should == {}
185
185
  result.should == "http://res.cloudinary.com/test123/image/upload/d_default/test"
186
186
  end
187
+
188
+ it "should support angle" do
189
+ options = {:angle=>"55"}
190
+ result = Cloudinary::Utils.cloudinary_url("test", options)
191
+ options.should == {}
192
+ result.should == "http://res.cloudinary.com/test123/image/upload/a_55/test"
193
+ end
194
+
195
+ it "should support overlay" do
196
+ options = {:overlay=>"text:hello"}
197
+ result = Cloudinary::Utils.cloudinary_url("test", options)
198
+ options.should == {}
199
+ result.should == "http://res.cloudinary.com/test123/image/upload/l_text:hello/test"
200
+ end
187
201
 
188
202
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cloudinary
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.20
5
+ version: 1.0.21
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nadav Soferman
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2012-05-06 00:00:00 +03:00
15
+ date: 2012-05-09 00:00:00 +03:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency