paperclip-cloudinary 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26170d304fef36a6ea287a5f1bef2559cf029c7e
4
- data.tar.gz: 6b16e4ae21c1d61cc6f30e491ddc9e6911f6ed92
3
+ metadata.gz: 991caf710e11807bfa06aae6188801216d9358c1
4
+ data.tar.gz: d1367fd08d75492adb8c958ee1ebf1ad7bff9bdf
5
5
  SHA512:
6
- metadata.gz: 23d63a198657b36b713021d3e01ab6be53b7f99f192a5293d10ccdd630e9663ea9bbc08033811035431d21bce6a2615aa255f7b920947d43d08c744edd23a3cf
7
- data.tar.gz: eb40b01ba53f7660f4671c8d9f07ce93374887c24b7d0f4331d38cbb33c115189034b7f44c867602b15a82eb836544708caeb28ed7f648ff6c4f086d74fc66d3
6
+ metadata.gz: 75319debfce96d914576815c8c4f564da17a5ce89e269a9c979091fa82247283b0b7b7f38997dfef9f55f45bd1a4216955e78203472363f30f597c4c06faf72c
7
+ data.tar.gz: c6aa1be805712f6bf7e350cb0ad0935d66a17711d9e76d715384d36a474d4de02103c0991b45f0d0bcce59562ee1e176f51dd6da816c47b0ccf0da3dbfafc6df
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paperclip-cloudinary (1.1.0)
4
+ paperclip-cloudinary (1.2.0)
5
5
  cloudinary (~> 1.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -114,8 +114,7 @@ has_attached_file :image,
114
114
  ]
115
115
  }
116
116
  }
117
- }
118
- }
117
+ }
119
118
  ```
120
119
 
121
120
  Here, all image versions would be uploaded with a caption taken from the model's caption parameter and
@@ -126,6 +125,46 @@ facial recognition features.
126
125
 
127
126
  The gem-provided default options can not be overridden.
128
127
 
128
+ ### URL Options
129
+
130
+ One of Cloudinary's biggest draws is the ability to manipulate images
131
+ on the fly via URL parameters. You can specify the URL options in your
132
+ attachment configuration as well as in-line. See the Cloudinary
133
+ documentation for a list of all supported parameters.
134
+
135
+ #### Attachment Configuration
136
+
137
+ ```ruby
138
+ has_attached_file :image
139
+ :storage => :cloudinary,
140
+ :styles => { :avatar => '200x200>' },
141
+ :cloudinary_url_options => {
142
+ :default => {
143
+ :secure => true
144
+ },
145
+ :styles => {
146
+ :avatar => {
147
+ :resource_type => 'raw'
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ Like upload options, the default options (optional) will be used first
154
+ for all calls, then the style-specific ones, if applicable.
155
+
156
+ #### In-line Configuration
157
+
158
+ ```ruby
159
+ model.image.url(:avatar, :cloudinary => { :secure => true,
160
+ :resource_type => 'raw' }
161
+ ```
162
+
163
+ These can be use in addition to the URL options provided in the
164
+ attachment configuration, or they can be used standalone. Options
165
+ provided in-line will override any options specified in the attachment
166
+ configuration.
167
+
129
168
  ## Contributing
130
169
 
131
170
  Bug reports and pull requests are welcome on GitHub at https://github.com/GoGoCarl/paperclip-cloudinary.
@@ -1,5 +1,5 @@
1
1
  module Paperclip
2
2
  module Cloudinary
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -45,7 +45,7 @@ module Paperclip
45
45
 
46
46
  def flush_deletes
47
47
  @queued_for_delete.each do |path|
48
- ::Cloudinary::Uploader.destroy path
48
+ ::Cloudinary::Uploader.destroy path[0..-(File.extname(path).length + 1)]
49
49
  end
50
50
 
51
51
  @queued_for_delete.clear
@@ -68,7 +68,8 @@ module Paperclip
68
68
  else
69
69
  style = style_or_options
70
70
  end
71
- ::Cloudinary::Utils.cloudinary_url path(style)
71
+ inline_opts = options[:cloudinary] || {}
72
+ ::Cloudinary::Utils.cloudinary_url path(style), cloudinary_url_options(style, inline_opts)
72
73
  end
73
74
 
74
75
  def public_id style
@@ -102,6 +103,21 @@ module Paperclip
102
103
 
103
104
  private
104
105
 
106
+ def cloudinary_url_options style_name, inline_opts={}
107
+ url_opts = @options[:cloudinary_url_options] || {}
108
+ default_opts = url_opts[:default] || {}
109
+ style_opts = url_opts[:styles].try(:[], style_name) || {}
110
+
111
+ options = {}
112
+ [default_opts, style_opts, inline_opts].each do |opts|
113
+ options.deep_merge!(opts) do |key, existing_value, new_value|
114
+ new_value.try(:call, style_name, self) || new_value
115
+ end
116
+ end
117
+ options.merge! default_opts
118
+ options
119
+ end
120
+
105
121
  def find_credentials creds
106
122
  case creds
107
123
  when File
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-cloudinary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Scott
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-23 00:00:00.000000000 Z
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cloudinary