Class: Auger::Request
- Inherits:
-
Object
- Object
- Auger::Request
- Defined in:
- lib/auger/request.rb
Direct Known Subclasses
DnsDomainRequest, DnsQueryRequest, HttpRequest, RedisDbsize, RedisExists, RedisGet, RedisInfo, RedisPing, SocketRequest, TelnetRequest
Instance Attribute Summary collapse
-
#arg ⇒ Object
Returns the value of attribute arg.
-
#before_request_proc ⇒ Object
Returns the value of attribute before_request_proc.
-
#before_tests_proc ⇒ Object
Returns the value of attribute before_tests_proc.
-
#tests ⇒ Object
Returns the value of attribute tests.
Class Method Summary collapse
Instance Method Summary collapse
- #before_request(&block) ⇒ Object
-
#before_tests(&block) ⇒ Object
callback to be run after request, but before tests.
-
#initialize(arg) ⇒ Request
constructor
A new instance of Request.
-
#Result(*args) ⇒ Object
called within test block to return a Result object.
-
#Status(*args) ⇒ Object
called within test block to return a Status object.
- #test(name, &block) ⇒ Object
-
#try_run(conn) ⇒ Object
call plugin run() and return plugin-specfic response object or exception.
Constructor Details
#initialize(arg) ⇒ Request
Returns a new instance of Request.
12 13 14 15 |
# File 'lib/auger/request.rb', line 12 def initialize(arg) @arg = arg @tests = [] end |
Instance Attribute Details
#arg ⇒ Object
Returns the value of attribute arg.
4 5 6 |
# File 'lib/auger/request.rb', line 4 def arg @arg end |
#before_request_proc ⇒ Object
Returns the value of attribute before_request_proc.
4 5 6 |
# File 'lib/auger/request.rb', line 4 def before_request_proc @before_request_proc end |
#before_tests_proc ⇒ Object
Returns the value of attribute before_tests_proc.
4 5 6 |
# File 'lib/auger/request.rb', line 4 def before_tests_proc @before_tests_proc end |
#tests ⇒ Object
Returns the value of attribute tests.
4 5 6 |
# File 'lib/auger/request.rb', line 4 def tests @tests end |
Class Method Details
.load(arg, &block) ⇒ Object
6 7 8 9 10 |
# File 'lib/auger/request.rb', line 6 def self.load(arg, &block) request = new(arg) request.instance_eval(&block) request end |
Instance Method Details
#before_request(&block) ⇒ Object
31 32 33 |
# File 'lib/auger/request.rb', line 31 def before_request(&block) @before_request_proc = block end |
#before_tests(&block) ⇒ Object
callback to be run after request, but before tests
36 37 38 |
# File 'lib/auger/request.rb', line 36 def before_tests(&block) @before_tests_proc = block end |
#Result(*args) ⇒ Object
called within test block to return a Result object
22 23 24 |
# File 'lib/auger/request.rb', line 22 def Result(*args) Auger::Result.new(*args) end |
#Status(*args) ⇒ Object
called within test block to return a Status object
27 28 29 |
# File 'lib/auger/request.rb', line 27 def Status(*args) Auger::Status.new(*args) end |
#test(name, &block) ⇒ Object
17 18 19 |
# File 'lib/auger/request.rb', line 17 def test(name, &block) @tests << Test.new(name, block) end |
#try_run(conn) ⇒ Object
call plugin run() and return plugin-specfic response object or exception
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/auger/request.rb', line 41 def try_run(conn) return conn if conn.is_a? Exception begin arg = @arg arg = self.before_request_proc.call(conn) if self.before_request_proc start = Time.now response = self.run(conn, arg) time = Time.now - start response = self.before_tests_proc.call(response) if self.before_tests_proc return response, time rescue => e e end end |