Class: Rspeckled::Reporting::Example

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#countsObject

Returns the value of attribute counts.



24
25
26
# File 'lib/rspeckled/reporting/example.rb', line 24

def counts
  @counts
end

#exampleObject

Returns the value of attribute example.



24
25
26
# File 'lib/rspeckled/reporting/example.rb', line 24

def example
  @example
end

Instance Method Details

#descriptionObject



48
49
50
# File 'lib/rspeckled/reporting/example.rb', line 48

def description
  [:full_description]
end

#exceptionObject



52
53
54
# File 'lib/rspeckled/reporting/example.rb', line 52

def exception
  execution_result.exception
end

#fileObject



32
33
34
# File 'lib/rspeckled/reporting/example.rb', line 32

def file
  [:file_path]
end

#line_numberObject



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_countObject



56
57
58
# File 'lib/rspeckled/reporting/example.rb', line 56

def query_count
  counts[:query_count]
end

#query_timeObject



60
61
62
# File 'lib/rspeckled/reporting/example.rb', line 60

def query_time
  counts[:query_time]
end

#request_countObject



64
65
66
# File 'lib/rspeckled/reporting/example.rb', line 64

def request_count
  counts[:request_count]
end

#request_timeObject



68
69
70
# File 'lib/rspeckled/reporting/example.rb', line 68

def request_time
  counts[:request_time]
end

#statusObject



40
41
42
# File 'lib/rspeckled/reporting/example.rb', line 40

def status
  execution_result.status
end

#timeObject



44
45
46
# File 'lib/rspeckled/reporting/example.rb', line 44

def time
  execution_result.run_time
end