Class: Relevance::Tarantula::Result
Constant Summary
collapse
- HASHABLE_ATTRS =
[:success, :method, :url, :response, :referrer, :data, :description, :log, :test_name]
- DEFAULT_LOCALHOST =
"http://localhost:3000"
- ALLOW_NNN_FOR =
/^allow_(\d\d\d)_for$/
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#textmate_url, #wrap_in_line_number_table_row, #wrap_stack_trace_line
#log, #rails_root, #tarantula_home, #verbose
Constructor Details
#initialize(hash) ⇒ Result
Returns a new instance of Result.
8
9
10
11
12
13
|
# File 'lib/relevance/tarantula/result.rb', line 8
def initialize(hash)
hash.each do |k,v|
raise ArgumentError, k unless HASHABLE_ATTRS.member?(k)
self.instance_variable_set("@#{k}", v)
end
end
|
Class Attribute Details
.allow_errors_for ⇒ Object
allow_errors_for is a hash
k=error code,
v=array of matchers for urls that can skip said error
48
49
50
|
# File 'lib/relevance/tarantula/result.rb', line 48
def allow_errors_for
@allow_errors_for
end
|
.next_number ⇒ Object
Returns the value of attribute next_number.
34
35
36
|
# File 'lib/relevance/tarantula/result.rb', line 34
def next_number
@next_number
end
|
Class Method Details
.can_skip_error?(result) ⇒ Boolean
49
50
51
52
53
|
# File 'lib/relevance/tarantula/result.rb', line 49
def can_skip_error?(result)
coll = allow_errors_for[result.code]
return false unless coll
coll.any? {|item| item === result.url}
end
|
.handle(result) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/relevance/tarantula/result.rb', line 35
def handle(result)
retval = result.dup
retval.success = successful?(result.response) || can_skip_error?(result)
retval.description = "Bad HTTP Response" unless retval.success
retval
end
|
.method_missing(meth, *args) ⇒ Object
57
58
59
60
|
# File 'lib/relevance/tarantula/result.rb', line 57
def method_missing(meth, *args)
super unless ALLOW_NNN_FOR =~ meth.to_s
(allow_errors_for[$1] ||= []).push(*args)
end
|
.success_codes ⇒ Object
41
42
43
|
# File 'lib/relevance/tarantula/result.rb', line 41
def success_codes
%w{200 201 302 401}
end
|
.successful?(response) ⇒ Boolean
54
55
56
|
# File 'lib/relevance/tarantula/result.rb', line 54
def successful?(response)
success_codes.member?(response.code)
end
|
Instance Method Details
26
27
28
|
# File 'lib/relevance/tarantula/result.rb', line 26
def body
response && response.body
end
|
23
24
25
|
# File 'lib/relevance/tarantula/result.rb', line 23
def code
response && response.code
end
|
#file_name ⇒ Object
20
21
22
|
# File 'lib/relevance/tarantula/result.rb', line 20
def file_name
"#{sequence_number}.html"
end
|
29
30
31
|
# File 'lib/relevance/tarantula/result.rb', line 29
def full_url
"#{DEFAULT_LOCALHOST}#{url}"
end
|
#sequence_number ⇒ Object
17
18
19
|
# File 'lib/relevance/tarantula/result.rb', line 17
def sequence_number
@sequence_number ||= (self.class.next_number += 1)
end
|
#short_description ⇒ Object
14
15
16
|
# File 'lib/relevance/tarantula/result.rb', line 14
def short_description
[method,url].join(" ")
end
|