cloudinary 1.0.13 → 1.0.14

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 CHANGED
@@ -1,12 +1,13 @@
1
1
  # Copyright Cloudinary
2
2
  require "ostruct"
3
+ require "pathname"
4
+ require "yaml"
3
5
  require "cloudinary/version"
4
6
  require "cloudinary/utils"
5
7
  require "cloudinary/uploader"
6
8
  require "cloudinary/downloader"
7
9
  require "cloudinary/blob"
8
10
  require "cloudinary/static" if defined?(::ActiveSupport)
9
- require 'active_support'
10
11
  require "cloudinary/missing"
11
12
  require "cloudinary/carrier_wave" if defined?(::CarrierWave)
12
13
  require "cloudinary/helper" if defined?(::ActionView::Base)
@@ -18,7 +19,7 @@ module Cloudinary
18
19
 
19
20
  def self.config(new_config=nil)
20
21
  first_time = @@config.nil?
21
- @@config ||= OpenStruct.new((YAML.load_file(Rails.root.join("config").join("cloudinary.yml"))[Rails.env] rescue {}))
22
+ @@config ||= OpenStruct.new((YAML.load_file(config_dir.join("cloudinary.yml"))[config_env] rescue {}))
22
23
 
23
24
  # Heroku support
24
25
  if first_time && ENV["CLOUDINARY_CLOUD_NAME"]
@@ -39,6 +40,18 @@ module Cloudinary
39
40
 
40
41
  private
41
42
 
43
+ def self.config_env
44
+ return ENV["CLOUDINARY_ENV"] if ENV["CLOUDINARY_ENV"]
45
+ return Rails.env if defined?(Rails)
46
+ nil
47
+ end
48
+
49
+ def self.config_dir
50
+ return Pathname.new(ENV["CLOUDINARY_CONFIG_DIR"]) if ENV["CLOUDINARY_CONFIG_DIR"]
51
+ return Rails.root.join("config") if defined?(Rails)
52
+ Pathname.new("config")
53
+ end
54
+
42
55
  def self.set_config(new_config)
43
56
  new_config.each{|k,v| @@config.send(:"#{k}=", v) if !v.nil?}
44
57
  end
@@ -173,17 +173,21 @@ module Cloudinary::CarrierWave
173
173
  end
174
174
  end
175
175
 
176
+ def recreate_versions!
177
+ # Do nothing
178
+ end
179
+
176
180
  def process!(new_file=nil)
177
181
  # Do nothing
178
182
  end
179
183
 
180
184
  def stored_filename
181
- @stored_filename = model.read_uploader(mounted_as) if @stored_filename.blank?
182
- @stored_filename
185
+ model.read_uploader(mounted_as)
183
186
  end
184
187
 
185
188
  def my_filename
186
- @my_filename ||= stored_filename.present? ? stored_filename : ("#{self.public_id}.#{self.format}")
189
+ return stored_filename if stored_filename.present?
190
+ @my_filename ||= "#{self.public_id}.#{self.format}"
187
191
  end
188
192
 
189
193
  def public_id
@@ -1,3 +1,4 @@
1
+ require 'active_support/time'
1
2
  require 'find'
2
3
  class Cloudinary::Static
3
4
  IGNORE_FILES = [".svn", "CVS", "RCS", ".git", ".hg"]
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.0.13"
3
+ VERSION = "1.0.14"
4
4
  end
@@ -1,6 +1,7 @@
1
1
  namespace :cloudinary do
2
2
  desc "Sync static resources with cloudinary"
3
3
  task :sync_static do
4
- Cloudinary::Static.sync
4
+ delete_missing = ENV["DELETE_MISSING"] == 'true' || ENV["DELETE_MISSING"] == '1'
5
+ Cloudinary::Static.sync(:delete_missing=>delete_missing)
5
6
  end
6
7
  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.13
5
+ version: 1.0.14
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-22 00:00:00 +03:00
15
+ date: 2012-04-23 00:00:00 +03:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency