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
58
59
60
|
# File 'lib/relevance/tarantula/result.rb', line 58
def allow_errors_for
@allow_errors_for
end
|
.next_number ⇒ Object
Returns the value of attribute next_number.
42
43
44
|
# File 'lib/relevance/tarantula/result.rb', line 42
def next_number
@next_number
end
|
Class Method Details
.can_skip_error?(result) ⇒ Boolean
59
60
61
62
63
|
# File 'lib/relevance/tarantula/result.rb', line 59
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
44
45
46
47
48
49
|
# File 'lib/relevance/tarantula/result.rb', line 44
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
69
70
71
72
|
# File 'lib/relevance/tarantula/result.rb', line 69
def method_missing(meth, *args)
super unless ALLOW_NNN_FOR =~ meth.to_s
(allow_errors_for[$1] ||= []).push(*args)
end
|
.success_codes ⇒ Object
51
52
53
|
# File 'lib/relevance/tarantula/result.rb', line 51
def success_codes
%w{200 201 302 401}
end
|
.successful?(response) ⇒ Boolean
65
66
67
|
# File 'lib/relevance/tarantula/result.rb', line 65
def successful?(response)
success_codes.member?(response.code)
end
|
Instance Method Details
31
32
33
|
# File 'lib/relevance/tarantula/result.rb', line 31
def body
response && response.body
end
|
27
28
29
|
# File 'lib/relevance/tarantula/result.rb', line 27
def code
response && response.code
end
|
#file_name ⇒ Object
23
24
25
|
# File 'lib/relevance/tarantula/result.rb', line 23
def file_name
"#{sequence_number}.html"
end
|
35
36
37
|
# File 'lib/relevance/tarantula/result.rb', line 35
def full_url
"#{DEFAULT_LOCALHOST}#{url}"
end
|
#sequence_number ⇒ Object
19
20
21
|
# File 'lib/relevance/tarantula/result.rb', line 19
def sequence_number
@sequence_number ||= (self.class.next_number += 1)
end
|
#short_description ⇒ Object
15
16
17
|
# File 'lib/relevance/tarantula/result.rb', line 15
def short_description
[method,url].join(" ")
end
|