cloudinary 1.0.40 → 1.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cloudinary.rb +9 -0
- data/lib/cloudinary/api.rb +8 -2
- data/lib/cloudinary/carrier_wave/process.rb +2 -1
- data/lib/cloudinary/utils.rb +2 -1
- data/lib/cloudinary/version.rb +1 -1
- data/spec/api_spec.rb +16 -0
- data/spec/utils_spec.rb +11 -0
- metadata +2 -2
data/lib/cloudinary.rb
CHANGED
@@ -19,6 +19,14 @@ require "cloudinary/railtie" if defined?(Rails) && defined?(Rails::Railtie)
|
|
19
19
|
require "cloudinary/engine" if defined?(Rails) && defined?(Rails::Engine)
|
20
20
|
|
21
21
|
module Cloudinary
|
22
|
+
FORMAT_ALIASES = {
|
23
|
+
"jpeg" => "jpg",
|
24
|
+
"jpe" => "jpg",
|
25
|
+
"tif" => "tiff",
|
26
|
+
"ps" => "eps",
|
27
|
+
"ept" => "eps"
|
28
|
+
}
|
29
|
+
|
22
30
|
@@config = nil
|
23
31
|
|
24
32
|
def self.config(new_config=nil)
|
@@ -45,6 +53,7 @@ module Cloudinary
|
|
45
53
|
end
|
46
54
|
|
47
55
|
def self.config_from_url(url)
|
56
|
+
@@config ||= OpenStruct.new
|
48
57
|
uri = URI.parse(url)
|
49
58
|
set_config(
|
50
59
|
"cloud_name" => uri.host,
|
data/lib/cloudinary/api.rb
CHANGED
@@ -47,14 +47,20 @@ class Cloudinary::Api
|
|
47
47
|
resource_type = options[:resource_type] || "image"
|
48
48
|
type = options[:type] || "upload"
|
49
49
|
uri = "resources/#{resource_type}/#{type}"
|
50
|
-
call_api(:delete, uri, {:public_ids=>public_ids}, options)
|
50
|
+
call_api(:delete, uri, {:public_ids=>public_ids}.merge(only(options, :keep_original)), options)
|
51
51
|
end
|
52
52
|
|
53
53
|
def self.delete_resources_by_prefix(prefix, options={})
|
54
54
|
resource_type = options[:resource_type] || "image"
|
55
55
|
type = options[:type] || "upload"
|
56
56
|
uri = "resources/#{resource_type}/#{type}"
|
57
|
-
call_api(:delete, uri, {:prefix=>prefix}, options)
|
57
|
+
call_api(:delete, uri, {:prefix=>prefix}.merge(only(options, :keep_original)), options)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.delete_resources_by_tag(tag, options={})
|
61
|
+
resource_type = options[:resource_type] || "image"
|
62
|
+
uri = "resources/#{resource_type}/tags/#{tag}"
|
63
|
+
call_api(:delete, uri, only(options, :keep_original), options)
|
58
64
|
end
|
59
65
|
|
60
66
|
def self.delete_derived_resources(derived_resource_ids, options={})
|
@@ -141,6 +141,7 @@ module Cloudinary::CarrierWave
|
|
141
141
|
format = Cloudinary::CarrierWave.split_format(original_filename || "").last
|
142
142
|
format ||= "png" # TODO Default format?
|
143
143
|
end
|
144
|
-
format.to_s.downcase
|
144
|
+
format = format.to_s.downcase
|
145
|
+
Cloudinary::FORMAT_ALIASES[format] || format
|
145
146
|
end
|
146
147
|
end
|
data/lib/cloudinary/utils.rb
CHANGED
@@ -52,8 +52,9 @@ class Cloudinary::Utils
|
|
52
52
|
if border.is_a?(Hash)
|
53
53
|
border = "#{border[:width] || 2}px_solid_#{(border[:color] || "black").sub(/^#/, 'rgb:')}"
|
54
54
|
end
|
55
|
+
flags = build_array(options.delete(:flags)).join(".")
|
55
56
|
|
56
|
-
params = {:w=>width, :h=>height, :t=>named_transformation, :c=>crop, :b=>background, :e=>effect, :a=>angle, :bo=>border}
|
57
|
+
params = {:w=>width, :h=>height, :t=>named_transformation, :c=>crop, :b=>background, :e=>effect, :a=>angle, :bo=>border, :fl=>flags}
|
57
58
|
{ :x=>:x, :y=>:y, :r=>:radius, :d=>:default_image, :g=>:gravity, :q=>:quality, :cs=>:color_space,
|
58
59
|
:p=>:prefix, :l=>:overlay, :u=>:underlay, :f=>:fetch_format, :dn=>:density, :pg=>:page, :dl=>:delay
|
59
60
|
}.each do
|
data/lib/cloudinary/version.rb
CHANGED
data/spec/api_spec.rb
CHANGED
@@ -78,6 +78,22 @@ describe Cloudinary::Api do
|
|
78
78
|
lambda{@api.resource("api_test3")}.should raise_error(Cloudinary::Api::NotFound)
|
79
79
|
end
|
80
80
|
|
81
|
+
it "should allow deleting resources by prefix" do
|
82
|
+
Cloudinary::Uploader.upload("spec/logo.png", :public_id=>"api_test_by_prefix")
|
83
|
+
resource = @api.resource("api_test_by_prefix")
|
84
|
+
resource.should_not be_blank
|
85
|
+
@api.delete_resources_by_prefix("api_test_by")
|
86
|
+
lambda{@api.resource("api_test_by_prefix")}.should raise_error(Cloudinary::Api::NotFound)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should allow deleting resources by tags" do
|
90
|
+
Cloudinary::Uploader.upload("spec/logo.png", :public_id=>"api_test4", :tags=>["api_test_tag_for_delete"])
|
91
|
+
resource = @api.resource("api_test4")
|
92
|
+
resource.should_not be_blank
|
93
|
+
@api.delete_resources_by_tag("api_test_tag_for_delete")
|
94
|
+
lambda{@api.resource("api_test4")}.should raise_error(Cloudinary::Api::NotFound)
|
95
|
+
end
|
96
|
+
|
81
97
|
it "should allow listing tags" do
|
82
98
|
tags = @api.tags()["tags"]
|
83
99
|
tags.should include('api_test_tag')
|
data/spec/utils_spec.rb
CHANGED
@@ -324,4 +324,15 @@ describe Cloudinary::Utils do
|
|
324
324
|
options.should == {}
|
325
325
|
result.should == "http://res.cloudinary.com/test123/image/upload/bo_1px_solid_blue/test"
|
326
326
|
end
|
327
|
+
|
328
|
+
it "should support flags" do
|
329
|
+
options = {"flags"=>"abc"}
|
330
|
+
result = Cloudinary::Utils.cloudinary_url("test", options)
|
331
|
+
options.should == {}
|
332
|
+
result.should == "http://res.cloudinary.com/test123/image/upload/fl_abc/test"
|
333
|
+
options = {"flags"=>["abc", "def"]}
|
334
|
+
result = Cloudinary::Utils.cloudinary_url("test", options)
|
335
|
+
options.should == {}
|
336
|
+
result.should == "http://res.cloudinary.com/test123/image/upload/fl_abc.def/test"
|
337
|
+
end
|
327
338
|
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.
|
4
|
+
version: 1.0.41
|
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-10-
|
14
|
+
date: 2012-10-28 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rest-client
|