Class: WhatWeb::Matcher::Base
- Inherits:
-
Object
- #Object
- Object
- WhatWeb::Matcher::Base
show all
- Defined in:
- lib/whatweb/matcher/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(target, match) ⇒ Base
Returns a new instance of Base.
7
8
9
10
|
# File 'lib/whatweb/matcher/base.rb', line 7
def initialize(target, match)
@target = target
@match = match
end
|
Instance Attribute Details
#match ⇒ Object
Returns the value of attribute match.
6
7
8
|
# File 'lib/whatweb/matcher/base.rb', line 6
def match
@match
end
|
#target ⇒ Object
Returns the value of attribute target.
6
7
8
|
# File 'lib/whatweb/matcher/base.rb', line 6
def target
@target
end
|
Class Method Details
.match?(target, match) ⇒ Boolean
39
40
41
|
# File 'lib/whatweb/matcher/base.rb', line 39
def self.match?(target, match)
new(target, match).match?
end
|
Instance Method Details
#compiled_regexp ⇒ Object
35
36
37
|
# File 'lib/whatweb/matcher/base.rb', line 35
def compiled_regexp
raise NotImplementedError, "You must implement #{self.class}##{__method__}"
end
|
#match? ⇒ Boolean
12
13
14
15
16
|
# File 'lib/whatweb/matcher/base.rb', line 12
def match?
compiled_regexp.match? search_context
rescue NoHeaderError => _
false
end
|
#search_context ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/whatweb/matcher/base.rb', line 18
def search_context
search = match[:search]
context = target.body
case search
when "all"
context = target.raw_response
when "header"
context = target.
when /headers\[(.*)\]/
k = $1.downcase
= target.[k]
raise NoHeaderError, "There is no #{k} header in the response" unless
context =
end
context.to_s
end
|