lib/imgix/client.rb in imgix-0.3.5 vs lib/imgix/client.rb in imgix-1.0.0
- old
+ new
@@ -2,42 +2,31 @@
require 'addressable/uri'
require 'zlib'
module Imgix
class Client
- DEFAULTS = { secure: false, shard_strategy: :crc }
+ DEFAULTS = { use_https: true, shard_strategy: :crc }
def initialize(options = {})
options = DEFAULTS.merge(options)
@hosts = Array(options[:host]) + Array(options[:hosts]) and validate_hosts!
- @token = options[:token]
- @secure = options[:secure]
+ @secure_url_token = options[:secure_url_token]
+ @use_https = options[:use_https]
@shard_strategy = options[:shard_strategy] and validate_strategy!
@include_library_param = options.fetch(:include_library_param, true)
@library = options.fetch(:library_param, "rb")
@version = options.fetch(:library_version, Imgix::VERSION)
end
def path(path)
- p = Path.new(prefix(path), @token, path)
+ p = Path.new(prefix(path), @secure_url_token, path)
p.ixlib("#{@library}-#{@version}") if @include_library_param
p
end
def prefix(path)
- "#{@secure ? 'https' : 'http'}://#{get_host(path)}"
- end
-
- def sign_path(path)
- uri = Addressable::URI.parse(path)
- query = (uri.query || '')
- path = "#{@secure ? 'https' : 'http'}://#{get_host(path)}#{uri.path}?#{query}"
- if @token
- signature = Digest::MD5.hexdigest(@token + uri.path + '?' + query)
- path += "&s=#{signature}"
- end
- return path
+ "#{@use_https ? 'https' : 'http'}://#{get_host(path)}"
end
def get_host(path)
host = host_for_crc(path) if @shard_strategy == :crc
host = host_for_cycle if @shard_strategy == :cycle