Class: Rspeckled::Reporting::Example
- Inherits:
-
Object
- Object
- Rspeckled::Reporting::Example
- Defined in:
- lib/rspeckled/reporting/example.rb
Constant Summary collapse
- IGNORED_QUERIES_PATTERN =
%r{ ( pg_table| pg_attribute| pg_namespace| show\stables| pragma| sqlite_master/rollback| ^TRUNCATE TABLE| ^ALTER TABLE| ^BEGIN| ^COMMIT| ^ROLLBACK| ^RELEASE| ^SAVEPOINT ) }xi
Instance Attribute Summary collapse
-
#counts ⇒ Object
Returns the value of attribute counts.
-
#example ⇒ Object
Returns the value of attribute example.
Instance Method Summary collapse
- #description ⇒ Object
- #exception ⇒ Object
- #file ⇒ Object
-
#initialize(example) ⇒ Example
constructor
A new instance of Example.
- #line_number ⇒ Object
- #log_query(query, start, finish) ⇒ Object
- #log_request(_request, start, finish) ⇒ Object
- #query_count ⇒ Object
- #query_time ⇒ Object
- #request_count ⇒ Object
- #request_time ⇒ Object
- #status ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize(example) ⇒ Example
Returns a new instance of Example.
27 28 29 30 |
# File 'lib/rspeckled/reporting/example.rb', line 27 def initialize(example) self.counts = Hash.new(0) self.example = example end |
Instance Attribute Details
#counts ⇒ Object
Returns the value of attribute counts.
24 25 26 |
# File 'lib/rspeckled/reporting/example.rb', line 24 def counts @counts end |
#example ⇒ Object
Returns the value of attribute example.
24 25 26 |
# File 'lib/rspeckled/reporting/example.rb', line 24 def example @example end |
Instance Method Details
#description ⇒ Object
48 49 50 |
# File 'lib/rspeckled/reporting/example.rb', line 48 def description [:full_description] end |
#exception ⇒ Object
52 53 54 |
# File 'lib/rspeckled/reporting/example.rb', line 52 def exception execution_result.exception end |
#file ⇒ Object
32 33 34 |
# File 'lib/rspeckled/reporting/example.rb', line 32 def file [:file_path] end |
#line_number ⇒ Object
36 37 38 |
# File 'lib/rspeckled/reporting/example.rb', line 36 def line_number [:line_number] end |
#log_query(query, start, finish) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/rspeckled/reporting/example.rb', line 72 def log_query(query, start, finish) return if query[:sql] =~ IGNORED_QUERIES_PATTERN counts[:query_count] += 1 counts[:query_time] += (finish - start) end |
#log_request(_request, start, finish) ⇒ Object
79 80 81 82 |
# File 'lib/rspeckled/reporting/example.rb', line 79 def log_request(_request, start, finish) counts[:request_count] += 1 counts[:request_time] += (finish - start) end |
#query_count ⇒ Object
56 57 58 |
# File 'lib/rspeckled/reporting/example.rb', line 56 def query_count counts[:query_count] end |
#query_time ⇒ Object
60 61 62 |
# File 'lib/rspeckled/reporting/example.rb', line 60 def query_time counts[:query_time] end |
#request_count ⇒ Object
64 65 66 |
# File 'lib/rspeckled/reporting/example.rb', line 64 def request_count counts[:request_count] end |
#request_time ⇒ Object
68 69 70 |
# File 'lib/rspeckled/reporting/example.rb', line 68 def request_time counts[:request_time] end |
#status ⇒ Object
40 41 42 |
# File 'lib/rspeckled/reporting/example.rb', line 40 def status execution_result.status end |
#time ⇒ Object
44 45 46 |
# File 'lib/rspeckled/reporting/example.rb', line 44 def time execution_result.run_time end |