Module: SWD

Defined in:
lib/swd.rb,
lib/swd/cache.rb,
lib/swd/resource.rb,
lib/swd/response.rb,
lib/swd/exception.rb,
lib/swd/debugger/request_filter.rb

Defined Under Namespace

Modules: Debugger Classes: BadRequest, Cache, Exception, Forbidden, HttpError, NotFound, Resource, Response, Unauthorized

Constant Summary collapse

VERSION =
::File.read(
  ::File.join(::File.dirname(__FILE__), '../VERSION')
).strip

Class Method Summary collapse

Class Method Details

.cacheObject



18
19
20
# File 'lib/swd.rb', line 18

def self.cache
  @@cache
end

.cache=(cache) ⇒ Object



15
16
17
# File 'lib/swd.rb', line 15

def self.cache=(cache)
  @@cache = cache
end

.debug(&block) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/swd.rb', line 44

def self.debug(&block)
  original = self.debugging?
  self.debugging = true
  yield
ensure
  self.debugging = original
end

.debug!Object



41
42
43
# File 'lib/swd.rb', line 41

def self.debug!
  self.debugging = true
end

.debugging=(boolean) ⇒ Object



38
39
40
# File 'lib/swd.rb', line 38

def self.debugging=(boolean)
  @@debugging = boolean
end

.debugging?Boolean

Returns:

  • (Boolean)


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

def self.debugging?
  @@debugging
end

.discover!(attributes = {}) ⇒ Object



22
23
24
# File 'lib/swd.rb', line 22

def self.discover!(attributes = {})
  Resource.new(attributes).discover!(attributes[:cache])
end

.http_clientObject



53
54
55
56
57
58
59
60
# File 'lib/swd.rb', line 53

def self.http_client
  _http_client_ = HTTPClient.new(
    :agent_name => "SWD (#{VERSION})"
  )
  _http_client_.request_filter << Debugger::RequestFilter.new if debugging?
  http_config.try(:call, _http_client_)
  _http_client_
end

.http_config(&block) ⇒ Object



61
62
63
# File 'lib/swd.rb', line 61

def self.http_config(&block)
  @@http_config ||= block
end

.loggerObject



26
27
28
# File 'lib/swd.rb', line 26

def self.logger
  @@logger
end

.logger=(logger) ⇒ Object



29
30
31
# File 'lib/swd.rb', line 29

def self.logger=(logger)
  @@logger = logger
end

.url_builderObject



65
66
67
# File 'lib/swd.rb', line 65

def self.url_builder
  @@url_builder ||= URI::HTTPS
end

.url_builder=(builder) ⇒ Object



68
69
70
# File 'lib/swd.rb', line 68

def self.url_builder=(builder)
  @@url_builder = builder
end