Class: Uniword::Validation::Rules::HeadersFootersRule
- Inherits:
-
Base
- Object
- Base
- Uniword::Validation::Rules::HeadersFootersRule
show all
- Defined in:
- lib/uniword/validation/rules/headers_footers_rule.rb
Overview
Validates header and footer references.
DOC-030: headerReference/footerReference targets exist in ZIP
DOC-031: headerReference/footerReference type is valid
Constant Summary
collapse
- W_NS =
"http://schemas.openxmlformats.org/wordprocessingml/2006/main"
- R_NS =
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"
- VALID_TYPES =
%w[default first even].freeze
Instance Method Summary
collapse
Methods inherited from Base
#context_type, #description, #validity_rule
Instance Method Details
#applicable?(context) ⇒ Boolean
20
21
22
|
# File 'lib/uniword/validation/rules/headers_footers_rule.rb', line 20
def applicable?(context)
context.part_exists?("word/document.xml")
end
|
#category ⇒ Object
17
|
# File 'lib/uniword/validation/rules/headers_footers_rule.rb', line 17
def category = :headers_footers
|
#check(context) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/uniword/validation/rules/headers_footers_rule.rb', line 24
def check(context)
issues = []
doc = context.document_xml
return issues unless doc
rels = context.relationships
rels_by_id = rels.to_h { |r| [r[:id], r] }
doc.root.xpath(".//w:headerReference", "w" => W_NS).each do |ref|
check_reference(ref, "header", rels_by_id, context, issues)
end
doc.root.xpath(".//w:footerReference", "w" => W_NS).each do |ref|
check_reference(ref, "footer", rels_by_id, context, issues)
end
issues
end
|
#code ⇒ Object
16
|
# File 'lib/uniword/validation/rules/headers_footers_rule.rb', line 16
def code = "DOC-030"
|
#severity ⇒ Object
18
|
# File 'lib/uniword/validation/rules/headers_footers_rule.rb', line 18
def severity = "error"
|