Class: Alula::CDN

Inherits:
Object
  • Object
show all
Defined in:
lib/alula/cdn.rb

Direct Known Subclasses

Edgecast, Hosts

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, opts) ⇒ CDN

Returns a new instance of CDN.



23
24
25
26
# File 'lib/alula/cdn.rb', line 23

def initialize(options, opts)
  @site = opts.delete(:site)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/alula/cdn.rb', line 21

def options
  @options
end

#siteObject (readonly)

Returns the value of attribute site.



20
21
22
# File 'lib/alula/cdn.rb', line 20

def site
  @site
end

Class Method Details

.cdnsObject



4
# File 'lib/alula/cdn.rb', line 4

def self.cdns; @@cdns ||= {}; end

.load(opts) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/alula/cdn.rb', line 7

def self.load(opts)
  site = opts[:site]
  
  # Check if we have environment related
  site.config.cdn.reverse_each do |cdn, opts|
    if cdns.has_key?(cdn)
      return cdns[cdn].new(opts, site: site)
    end
  end
  
  raise "Cannot find CDN Provider(s): #{site.config.cdn.keys}"
end

.register(name, klass) ⇒ Object



3
# File 'lib/alula/cdn.rb', line 3

def self.register(name, klass); cdns[name.to_s] = klass; end

Instance Method Details

#cdnsObject



5
# File 'lib/alula/cdn.rb', line 5

def cdns; self.class.cdns; end