cloudinary 1.0.10 → 1.0.11
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 +18 -10
- data/lib/cloudinary/helper.rb +5 -0
- data/lib/cloudinary/utils.rb +3 -4
- data/lib/cloudinary/version.rb +1 -1
- metadata +2 -2
data/lib/cloudinary.rb
CHANGED
@@ -16,22 +16,30 @@ require "cloudinary/railtie" if defined?(Rails) && defined?(Rails::Railtie)
|
|
16
16
|
module Cloudinary
|
17
17
|
@@config = nil
|
18
18
|
|
19
|
-
def self.config(new_config=nil)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
yield(@@config)
|
24
|
-
end
|
19
|
+
def self.config(new_config=nil)
|
20
|
+
first_time = @@config.nil?
|
21
|
+
@@config ||= OpenStruct.new((YAML.load_file(Rails.root.join("config").join("cloudinary.yml"))[Rails.env] rescue {}))
|
22
|
+
|
25
23
|
# Heroku support
|
26
|
-
if
|
27
|
-
|
24
|
+
if first_time && ENV["CLOUDINARY_CLOUD_NAME"]
|
25
|
+
set_config(
|
28
26
|
"cloud_name" => ENV["CLOUDINARY_CLOUD_NAME"],
|
29
27
|
"api_key" => ENV["CLOUDINARY_API_KEY"],
|
30
28
|
"api_secret" => ENV["CLOUDINARY_API_SECRET"],
|
31
29
|
"secure_distribution" => ENV["CLOUDINARY_SECURE_DISTRIBUTION"],
|
32
30
|
"private_cdn" => ENV["CLOUDINARY_PRIVATE_CDN"].to_s == 'true'
|
33
31
|
)
|
34
|
-
end
|
35
|
-
|
32
|
+
end
|
33
|
+
|
34
|
+
set_config(new_config) if new_config
|
35
|
+
yield(@@config) if block_given?
|
36
|
+
|
37
|
+
@@config
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def self.set_config(new_config)
|
43
|
+
new_config.each{|k,v| @@config.send(:"#{k}=", v) if !v.nil?}
|
36
44
|
end
|
37
45
|
end
|
data/lib/cloudinary/helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'digest/md5'
|
1
2
|
module CloudinaryHelper
|
2
3
|
include ActionView::Helpers::AssetTagHelper
|
3
4
|
alias :original_image_tag :image_tag
|
@@ -48,6 +49,10 @@ module CloudinaryHelper
|
|
48
49
|
cl_image_tag(profile, {:type=>:facebook}.merge(options))
|
49
50
|
end
|
50
51
|
|
52
|
+
def gravatar_profile_image_tag(email, options = {})
|
53
|
+
cl_image_tag(Digest::MD5.hexdigest(email.strip.downcase), {:type=>:gravatar, :format=>:jpg}.merge(options))
|
54
|
+
end
|
55
|
+
|
51
56
|
def twitter_profile_image_tag(profile, options = {})
|
52
57
|
cl_image_tag(profile, {:type=>:twitter}.merge(options))
|
53
58
|
end
|
data/lib/cloudinary/utils.rb
CHANGED
@@ -72,9 +72,8 @@ class Cloudinary::Utils
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
@metadata ||= defined?(Cloudinary::Static) ? Cloudinary::Static.metadata : {}
|
75
|
-
if @metadata["images/#{source}"]
|
76
|
-
return source if !Cloudinary.config.static_image_support
|
77
|
-
type = :asset
|
75
|
+
if type == :asset && @metadata["images/#{source}"]
|
76
|
+
return source if !Cloudinary.config.static_image_support
|
78
77
|
original_source = source
|
79
78
|
source = @metadata["images/#{source}"]["public_id"]
|
80
79
|
source += File.extname(original_source) if !format
|
@@ -84,7 +83,7 @@ class Cloudinary::Utils
|
|
84
83
|
end
|
85
84
|
type ||= :upload
|
86
85
|
|
87
|
-
source = "#{source}.#{format}" if format && type != :fetch
|
86
|
+
source = "#{source}.#{format}" if !format.blank? && type != :fetch
|
88
87
|
source = smart_escape(source) if [:fetch, :asset].include?(type)
|
89
88
|
|
90
89
|
if cloud_name.start_with?("/")
|
data/lib/cloudinary/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cloudinary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.11
|
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-04-
|
15
|
+
date: 2012-04-19 00:00:00 +03:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|