Class: Uniword::Validation::Rules::NumberingPreservationRule

Inherits:
Base
  • Object
show all
Defined in:
lib/uniword/validation/rules/numbering_preservation_rule.rb

Overview

Validates numbering elements are properly structured.

DOC-103: Level elements and lvlOverride are consistent Validity rules: R4, R5

Constant Summary collapse

W_NS =
"http://schemas.openxmlformats.org/wordprocessingml/2006/main"
LEVEL_CHILDREN =
%w[start numFmt suff lvlRestart lvlText lvlJc pPr ind
rPr].freeze

Instance Method Summary collapse

Methods inherited from Base

#context_type

Instance Method Details

#applicable?(context) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/uniword/validation/rules/numbering_preservation_rule.rb', line 22

def applicable?(context)
  context.part_exists?("word/numbering.xml")
end

#categoryObject



19
# File 'lib/uniword/validation/rules/numbering_preservation_rule.rb', line 19

def category = :numbering

#check(context) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/uniword/validation/rules/numbering_preservation_rule.rb', line 26

def check(context)
  issues = []
  doc = context.numbering_xml
  return issues unless doc

  check_abstract_num_integrity(doc, issues)
  check_num_instance_integrity(doc, issues)
  check_ilvl_range(doc, issues)
  check_lvl_overrides(doc, issues)

  issues
end

#codeObject



16
# File 'lib/uniword/validation/rules/numbering_preservation_rule.rb', line 16

def code = "DOC-103"

#descriptionObject



18
# File 'lib/uniword/validation/rules/numbering_preservation_rule.rb', line 18

def description = "Numbering level elements and lvlOverride/startOverride are properly structured"

#severityObject



20
# File 'lib/uniword/validation/rules/numbering_preservation_rule.rb', line 20

def severity = "warning"

#validity_ruleObject



17
# File 'lib/uniword/validation/rules/numbering_preservation_rule.rb', line 17

def validity_rule = "R4"