Class: Uniword::Validation::Rules::SettingsRule
- Inherits:
-
Base
- Object
- Base
- Uniword::Validation::Rules::SettingsRule
show all
- Defined in:
- lib/uniword/validation/rules/settings_rule.rb
Overview
Validates settings consistency.
DOC-090: Attached template path check DOC-091: Style IDs in settings match styles.xml
Constant Summary
collapse
- W_NS =
"http://schemas.openxmlformats.org/wordprocessingml/2006/main"
Instance Method Summary
collapse
Methods inherited from Base
#description, #validity_rule
Instance Method Details
#applicable?(context) ⇒ Boolean
19
20
21
|
# File 'lib/uniword/validation/rules/settings_rule.rb', line 19
def applicable?(context)
context.part_exists?("word/settings.xml")
end
|
#category ⇒ Object
16
|
# File 'lib/uniword/validation/rules/settings_rule.rb', line 16
def category = :settings
|
#check(context) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/uniword/validation/rules/settings_rule.rb', line 23
def check(context)
issues = []
settings = context.settings_xml
return issues unless settings
attached = settings.root.at_xpath(".//w:attachedTemplate/@w:val",
"w" => W_NS)
if attached && !attached.value.empty?
template_path = attached.value
if !template_path.start_with?("http") && !File.exist?(template_path)
issues << issue(
"Attached template not found: #{template_path}",
part: "word/settings.xml",
suggestion: "The template path may be local to the original " \
"machine. This is informational and usually harmless.",
)
end
end
check_settings_style_ids(context, settings, issues)
issues
end
|
#code ⇒ Object
15
|
# File 'lib/uniword/validation/rules/settings_rule.rb', line 15
def code = "DOC-090"
|
#severity ⇒ Object
17
|
# File 'lib/uniword/validation/rules/settings_rule.rb', line 17
def severity = "info"
|