Class: Rack::Thumb::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/rack-thumb-proxy.rb,
lib/rack-thumb-proxy/railtie.rb,
lib/rack-thumb-proxy/version.rb,
lib/rack-thumb-proxy/view_helpers.rb,
lib/rack-thumb-proxy/configuration.rb

Defined Under Namespace

Modules: ViewHelpers Classes: Configuration, Railtie

Constant Summary collapse

VERSION =
"0.0.9"

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Proxy

Returns a new instance of Proxy.



35
36
37
38
# File 'lib/rack-thumb-proxy.rb', line 35

def initialize(env)
  @env  = env
  @path = env['PATH_INFO']
end

Class Attribute Details

.configurationObject



25
26
27
# File 'lib/rack-thumb-proxy.rb', line 25

def configuration
  @configuration ||= Configuration.new
end

Class Method Details

.call(env) ⇒ Object



29
30
31
# File 'lib/rack-thumb-proxy.rb', line 29

def call(env)
  new(env).call
end

.configure(&block) ⇒ Object



20
21
22
23
# File 'lib/rack-thumb-proxy.rb', line 20

def configure(&block)
  configuration.instance_eval(&block)
  configuration
end

Instance Method Details

#callObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rack-thumb-proxy.rb', line 40

def call
  if request_matches?
    validate_signature! &&
    retreive_upstream!  &&
    transform_image!    &&
    format_response!
    response.finish
  else
    [404, {'Content-Length' => 9.to_s, 'Content-Type' => 'text/plain'}, ['Not Found']]
  end
end