Class: Billy::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/billy/config.rb

Constant Summary collapse

DEFAULT_WHITELIST =
['127.0.0.1', 'localhost']
RANDOM_AVAILABLE_PORT =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



16
17
18
19
# File 'lib/billy/config.rb', line 16

def initialize
  @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
  reset
end

Instance Attribute Details

#after_cache_handles_requestObject

Returns the value of attribute after_cache_handles_request.



9
10
11
# File 'lib/billy/config.rb', line 9

def after_cache_handles_request
  @after_cache_handles_request
end

#cacheObject

Returns the value of attribute cache.



9
10
11
# File 'lib/billy/config.rb', line 9

def cache
  @cache
end

#cache_pathObject

Returns the value of attribute cache_path.



9
10
11
# File 'lib/billy/config.rb', line 9

def cache_path
  @cache_path
end

#cache_request_body_methodsObject

Returns the value of attribute cache_request_body_methods.



9
10
11
# File 'lib/billy/config.rb', line 9

def cache_request_body_methods
  @cache_request_body_methods
end

#cache_request_headersObject

Returns the value of attribute cache_request_headers.



9
10
11
# File 'lib/billy/config.rb', line 9

def cache_request_headers
  @cache_request_headers
end

#dynamic_jsonpObject

Returns the value of attribute dynamic_jsonp.



9
10
11
# File 'lib/billy/config.rb', line 9

def dynamic_jsonp
  @dynamic_jsonp
end

#dynamic_jsonp_keysObject

Returns the value of attribute dynamic_jsonp_keys.



9
10
11
# File 'lib/billy/config.rb', line 9

def dynamic_jsonp_keys
  @dynamic_jsonp_keys
end

#ignore_cache_portObject

Returns the value of attribute ignore_cache_port.



9
10
11
# File 'lib/billy/config.rb', line 9

def ignore_cache_port
  @ignore_cache_port
end

#ignore_paramsObject

Returns the value of attribute ignore_params.



9
10
11
# File 'lib/billy/config.rb', line 9

def ignore_params
  @ignore_params
end

#loggerObject

Returns the value of attribute logger.



9
10
11
# File 'lib/billy/config.rb', line 9

def logger
  @logger
end

#merge_cached_responses_whitelistObject

Returns the value of attribute merge_cached_responses_whitelist.



9
10
11
# File 'lib/billy/config.rb', line 9

def merge_cached_responses_whitelist
  @merge_cached_responses_whitelist
end

#non_successful_cache_disabledObject

Returns the value of attribute non_successful_cache_disabled.



9
10
11
# File 'lib/billy/config.rb', line 9

def non_successful_cache_disabled
  @non_successful_cache_disabled
end

#non_successful_error_levelObject

Returns the value of attribute non_successful_error_level.



9
10
11
# File 'lib/billy/config.rb', line 9

def non_successful_error_level
  @non_successful_error_level
end

#non_whitelisted_requests_disabledObject

Returns the value of attribute non_whitelisted_requests_disabled.



9
10
11
# File 'lib/billy/config.rb', line 9

def non_whitelisted_requests_disabled
  @non_whitelisted_requests_disabled
end

#path_blacklistObject

Returns the value of attribute path_blacklist.



9
10
11
# File 'lib/billy/config.rb', line 9

def path_blacklist
  @path_blacklist
end

#persist_cacheObject

Returns the value of attribute persist_cache.



9
10
11
# File 'lib/billy/config.rb', line 9

def persist_cache
  @persist_cache
end

#proxied_request_connect_timeoutObject

Returns the value of attribute proxied_request_connect_timeout.



9
10
11
# File 'lib/billy/config.rb', line 9

def proxied_request_connect_timeout
  @proxied_request_connect_timeout
end

#proxied_request_hostObject

Returns the value of attribute proxied_request_host.



9
10
11
# File 'lib/billy/config.rb', line 9

def proxied_request_host
  @proxied_request_host
end

#proxied_request_inactivity_timeoutObject

Returns the value of attribute proxied_request_inactivity_timeout.



9
10
11
# File 'lib/billy/config.rb', line 9

def proxied_request_inactivity_timeout
  @proxied_request_inactivity_timeout
end

#proxied_request_portObject

Returns the value of attribute proxied_request_port.



9
10
11
# File 'lib/billy/config.rb', line 9

def proxied_request_port
  @proxied_request_port
end

#proxy_hostObject

Returns the value of attribute proxy_host.



9
10
11
# File 'lib/billy/config.rb', line 9

def proxy_host
  @proxy_host
end

#proxy_portObject

Returns the value of attribute proxy_port.



9
10
11
# File 'lib/billy/config.rb', line 9

def proxy_port
  @proxy_port
end

#record_stub_requestsObject

Returns the value of attribute record_stub_requests.



9
10
11
# File 'lib/billy/config.rb', line 9

def record_stub_requests
  @record_stub_requests
end

#strip_query_paramsObject

Returns the value of attribute strip_query_params.



9
10
11
# File 'lib/billy/config.rb', line 9

def strip_query_params
  @strip_query_params
end

#whitelistObject

Returns the value of attribute whitelist.



9
10
11
# File 'lib/billy/config.rb', line 9

def whitelist
  @whitelist
end

Instance Method Details

#resetObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/billy/config.rb', line 21

def reset
  @cache = true
  @cache_request_headers = false
  @whitelist = DEFAULT_WHITELIST
  @path_blacklist = []
  @merge_cached_responses_whitelist = []
  @ignore_params = []
  @persist_cache = false
  @dynamic_jsonp = false
  @dynamic_jsonp_keys = ['callback']
  @ignore_cache_port = true
  @non_successful_cache_disabled = false
  @non_successful_error_level = :warn
  @non_whitelisted_requests_disabled = false
  @cache_path = File.join(Dir.tmpdir, 'puffing-billy')
  @proxy_host = 'localhost'
  @proxy_port = RANDOM_AVAILABLE_PORT
  @proxied_request_inactivity_timeout = 10 # defaults from https://github.com/igrigorik/em-http-request/wiki/Redirects-and-Timeouts
  @proxied_request_connect_timeout = 5
  @strip_query_params = true
  @proxied_request_host = nil
  @proxied_request_port = 80
  @cache_request_body_methods = ['post']
  @after_cache_handles_request = nil
  @record_stub_requests = false
end