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
#context_type, #description, #validity_rule
Instance Method Details
#applicable?(context) ⇒ Boolean
17
18
19
|
# File 'lib/uniword/validation/rules/settings_rule.rb', line 17
def applicable?(context)
context.part_exists?("word/settings.xml")
end
|
#category ⇒ Object
14
|
# File 'lib/uniword/validation/rules/settings_rule.rb', line 14
def category = :settings
|
#check(context) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/uniword/validation/rules/settings_rule.rb', line 21
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
13
|
# File 'lib/uniword/validation/rules/settings_rule.rb', line 13
def code = "DOC-090"
|
#severity ⇒ Object
15
|
# File 'lib/uniword/validation/rules/settings_rule.rb', line 15
def severity = "info"
|