Class: XRay::HTML::Rule::CheckTagRule
- Inherits:
-
Object
- Object
- XRay::HTML::Rule::CheckTagRule
show all
- Includes:
- Context, Rule
- Defined in:
- lib/html/rule/check_tag_rule.rb
Constant Summary
Constants included
from Rule
Rule::KEYWORDS, Rule::RULE_PATH, Rule::STYLE_TYPES
Instance Attribute Summary collapse
Attributes included from Context
#scope
Instance Method Summary
collapse
Methods included from Rule
#add_common_rule, #clear_all_rules, #cmd_name, #common, #context, #do_check, #import, import_all, #import_all, #imported, #imported?, #method_missing, methods_to_keywords, #syntax
Methods included from Context
#in_page?, #lib?, #page_level?
Constructor Details
#initialize(opt = nil) ⇒ CheckTagRule
Returns a new instance of CheckTagRule.
17
18
19
|
# File 'lib/html/rule/check_tag_rule.rb', line 17
def initialize(opt=nil)
@imported_scripts, @imported_css = [], []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class XRay::Rule
Instance Attribute Details
#imported_css ⇒ Object
Returns the value of attribute imported_css.
15
16
17
|
# File 'lib/html/rule/check_tag_rule.rb', line 15
def imported_css
@imported_css
end
|
#imported_scripts ⇒ Object
Returns the value of attribute imported_scripts.
15
16
17
|
# File 'lib/html/rule/check_tag_rule.rb', line 15
def imported_scripts
@imported_scripts
end
|
Instance Method Details
#has_dtd? ⇒ Boolean
Also known as:
have_dtd?
70
71
72
|
# File 'lib/html/rule/check_tag_rule.rb', line 70
def has_dtd?
@have_dtd
end
|
#record_script(tag) ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/html/rule/check_tag_rule.rb', line 52
def record_script( tag )
if tag.tag_name_equal? 'script'
src = tag.prop_value(:src).to_s
unless src.empty? or script_used? src
@imported_scripts << src
end
end
end
|
#record_style(tag) ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'lib/html/rule/check_tag_rule.rb', line 61
def record_style( tag )
if tag.tag_name_equal? 'link' and tag.prop_value(:rel) =~ /stylesheet/i
src = tag.prop_value(:href).to_s
unless src.empty? or style_used? src
@imported_css << src
end
end
end
|
#script_used?(src) ⇒ Boolean
21
22
23
|
# File 'lib/html/rule/check_tag_rule.rb', line 21
def script_used?( src )
@imported_scripts.include? src
end
|
#style_used?(src) ⇒ Boolean
25
26
27
|
# File 'lib/html/rule/check_tag_rule.rb', line 25
def style_used?( src )
@imported_css.include? src
end
|
#visit_doc(html) ⇒ Object
29
30
31
|
# File 'lib/html/rule/check_tag_rule.rb', line 29
def visit_doc(html)
check_html_doc html
end
|
#visit_dtd(dtd) ⇒ Object
33
34
35
36
|
# File 'lib/html/rule/check_tag_rule.rb', line 33
def visit_dtd(dtd)
@have_dtd = true
check_html_dtd dtd
end
|
#visit_property(prop) ⇒ Object
48
49
50
|
# File 'lib/html/rule/check_tag_rule.rb', line 48
def visit_property(prop)
check_html_property prop
end
|
#visit_tag(tag) ⇒ Object
38
39
40
41
42
|
# File 'lib/html/rule/check_tag_rule.rb', line 38
def visit_tag(tag)
results = check_html_tag tag
record_script(tag) or record_style(tag)
results
end
|
#visit_text(tag) ⇒ Object
44
45
46
|
# File 'lib/html/rule/check_tag_rule.rb', line 44
def visit_text(tag)
check_html_text tag
end
|