Module: Cloudinary

Defined in:
lib/cloudinary/version.rb,
lib/cloudinary.rb,
lib/cloudinary/cache.rb,
lib/cloudinary/config.rb,
lib/cloudinary/analytics.rb,
lib/cloudinary/auth_token.rb,
lib/cloudinary/base_config.rb,
lib/cloudinary/account_config.rb

Overview

Copyright Cloudinary

Defined Under Namespace

Modules: AccountConfig, Analytics, AuthToken, BaseApi, BaseConfig, Cache, CarrierWave, CloudinaryController, Config, FormBuilder Classes: AccountApi, Api, Blob, Downloader, Engine, Migrator, PreloadedFile, Railtie, Search, SearchFolders, Static, Uploader, Utils

Constant Summary collapse

SHARED_CDN =
"res.cloudinary.com"
USER_AGENT =
"CloudinaryRuby/#{VERSION} (Ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL})"
FORMAT_ALIASES =
{
  "jpeg" => "jpg",
  "jpe"  => "jpg",
  "tif"  => "tiff",
  "ps"   => "eps",
  "ept"  => "eps"
}
VERSION =
"2.2.0"
@@user_platform =
defined?(Rails.version) ? "Rails/#{Rails.version}" : ""

Class Method Summary collapse

Class Method Details

.account_config(new_config = nil) {|Account| ... } ⇒ OpenStruct

Cloudinary account config

Parameters:

  • new_config (Hash) (defaults to: nil)

    If new_config is passed, Account Config will be updated with it

Yield Parameters:

  • Account (OpenStruct)

    config can be updated in the block

Returns:

  • (OpenStruct)


82
83
84
85
86
87
88
89
# File 'lib/cloudinary.rb', line 82

def self.(new_config=nil)
  @@account_config ||= make_new_config(AccountConfig)

  @@account_config.update(new_config) if new_config
  yield @@account_config if block_given?

  @@account_config
end

.app_rootObject



99
100
101
102
103
104
105
106
# File 'lib/cloudinary.rb', line 99

def self.app_root
  if defined? Rails::root
    # Rails 2.2 return String for Rails.root
    Rails.root.is_a?(Pathname) ? Rails.root : Pathname.new(Rails.root)
  else
    Pathname.new(".")
  end
end

.config(new_config = nil) {|Config| ... } ⇒ OpenStruct

Cloudinary config

Parameters:

  • new_config (Hash) (defaults to: nil)

    If new_config is passed, Config will be updated with it

Yield Parameters:

  • Config (OpenStruct)

    can be updated in the block

Returns:

  • (OpenStruct)


67
68
69
70
71
72
73
74
# File 'lib/cloudinary.rb', line 67

def self.config(new_config=nil)
  @@config ||= make_new_config(Config)

  @@config.update(new_config) if new_config
  yield @@config if block_given?

  @@config
end

.config_from_account_url(url) ⇒ Object



95
96
97
# File 'lib/cloudinary.rb', line 95

def self.(url)
  .load_from_url(url)
end

.config_from_url(url) ⇒ Object



91
92
93
# File 'lib/cloudinary.rb', line 91

def self.config_from_url(url)
  config.load_from_url(url)
end

.USER_AGENTObject



45
46
47
48
49
50
51
# File 'lib/cloudinary.rb', line 45

def self.USER_AGENT
  if @@user_platform.empty?
    USER_AGENT
  else
    "#{@@user_platform} #{USER_AGENT}"
  end
end

.user_platformObject



41
42
43
# File 'lib/cloudinary.rb', line 41

def self.user_platform
  @@user_platform
end

.user_platform=(value) ⇒ Object

Add platform information to the USER_AGENT header This is intended for platform information and not individual applications!



37
38
39
# File 'lib/cloudinary.rb', line 37

def self.user_platform=(value)
  @@user_platform= value
end