Class: Uniword::Validation::Rules::StyleReferencesRule

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

Overview

Validates style references exist in styles.xml.

DOC-001: Style IDs referenced in document.xml exist in styles.xml DOC-002: Default paragraph style exists DOC-003: Style references in numbering.xml exist in styles.xml

Constant Summary collapse

W_NS =
"http://schemas.openxmlformats.org/wordprocessingml/2006/main"

Instance Method Summary collapse

Methods inherited from Base

#context_type, #description, #validity_rule

Instance Method Details

#applicable?(context) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/uniword/validation/rules/style_references_rule.rb', line 18

def applicable?(context)
  context.part_exists?("word/document.xml") &&
    context.part_exists?("word/styles.xml")
end

#categoryObject



15
# File 'lib/uniword/validation/rules/style_references_rule.rb', line 15

def category = :styles

#check(context) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/uniword/validation/rules/style_references_rule.rb', line 23

def check(context)
  issues = []
  defined_ids = context.style_ids
  check_document_refs(context, defined_ids, issues)
  check_default_style(context, defined_ids, issues)
  check_numbering_refs(context, defined_ids, issues)
  issues
end

#codeObject



14
# File 'lib/uniword/validation/rules/style_references_rule.rb', line 14

def code = "DOC-001"

#severityObject



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

def severity = "error"