Class: Strawman::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/strawman/proxy.rb

Overview

The general proxy class, which contains functions not specific to any type of proxy.

Direct Known Subclasses

GlypeProxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Proxy

Returns a new instance of Proxy.



10
11
12
13
14
# File 'lib/strawman/proxy.rb', line 10

def initialize(url)
  @root_url = url
  @valid = false
  @validate_response = ""
end

Instance Attribute Details

#root_urlObject (readonly)

Returns the value of attribute root_url.



7
8
9
# File 'lib/strawman/proxy.rb', line 7

def root_url
  @root_url
end

#valid=(value) ⇒ Object (writeonly)

Sets the attribute valid

Parameters:

  • value

    the value to set the attribute valid to.



8
9
10
# File 'lib/strawman/proxy.rb', line 8

def valid=(value)
  @valid = value
end

Instance Method Details

#==(other) ⇒ Object



46
47
48
# File 'lib/strawman/proxy.rb', line 46

def ==(other)
  self.class == other.class && self.root_url == other.root_url
end

#proxy_url(url) ⇒ Object

Returns the url to fetch the given url through this proxy.



26
27
28
29
# File 'lib/strawman/proxy.rb', line 26

def proxy_url(url)
  uri = URI.join @root_url, proxy_path(url)
  "#{uri.scheme}://#{uri.host}:#{uri.port}#{uri.path}?#{uri.query}"
end

#refererObject

Returns the the referer to use when making the proxied request.



19
20
21
# File 'lib/strawman/proxy.rb', line 19

def referer
  @root_url
end

#valid?Boolean

Used to determine whether this proxy is valid. This must be called from within the callback of the validate deferable.

Returns:

  • (Boolean)


35
36
37
# File 'lib/strawman/proxy.rb', line 35

def valid?
  @valid
end

#validate_responseObject

Returns the response of the validate request from the proxy.



42
43
44
# File 'lib/strawman/proxy.rb', line 42

def validate_response
  @validate_response
end