Sha256: 9c24eaac9ea140a9d6db61c7354c80b3a1733303896376c18561ba3fedbbb62b

Contents?: true

Size: 399 Bytes

Versions: 30

Compression:

Stored size: 399 Bytes

Contents

module Alula
  class Edgecast < CDN
    THRESHOLD = 300 * 1024 # 300kB
    
    def url_for(name, opts)
      file = opts.delete(:file)
      
      hosts = File.size(file) < THRESHOLD ? self.options.small : self.options.large
      
      host = hosts[Digest::MD5.hexdigest(name).to_i(16) % hosts.count]
      File.join(host, name)
    end
  end
end

Alula::CDN.register :edgecast, Alula::Edgecast

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
alula-0.4.27 lib/alula/cdns/edgecast.rb
alula-0.4.26 lib/alula/cdns/edgecast.rb
alula-0.4.25 lib/alula/cdns/edgecast.rb
alula-0.4.24 lib/alula/cdns/edgecast.rb
alula-0.4.23 lib/alula/cdns/edgecast.rb
alula-0.4.22 lib/alula/cdns/edgecast.rb
alula-0.4.21 lib/alula/cdns/edgecast.rb
alula-0.4.20 lib/alula/cdns/edgecast.rb
alula-0.4.19 lib/alula/cdns/edgecast.rb
alula-0.4.18 lib/alula/cdns/edgecast.rb
alula-0.4.17 lib/alula/cdns/edgecast.rb
alula-0.4.16 lib/alula/cdns/edgecast.rb
alula-0.4.15 lib/alula/cdns/edgecast.rb
alula-0.4.14 lib/alula/cdns/edgecast.rb
alula-0.4.13 lib/alula/cdns/edgecast.rb
alula-0.4.12 lib/alula/cdns/edgecast.rb
alula-0.4.11 lib/alula/cdns/edgecast.rb
alula-0.4.11a lib/alula/cdns/edgecast.rb
alula-0.4.10 lib/alula/cdns/edgecast.rb
alula-0.4.9 lib/alula/cdns/edgecast.rb