Class: Uniword::Validation::Rules::ContentTypesCoverageRule
- Defined in:
- lib/uniword/validation/rules/content_types_coverage_rule.rb
Overview
Validates that every ZIP entry has content type coverage.
DOC-106: All ZIP entries must be covered by Content_Types Validity rule: R7
Constant Summary collapse
- CT_NS =
"http://schemas.openxmlformats.org/package/2006/content-types"
Instance Method Summary collapse
- #applicable?(context) ⇒ Boolean
- #category ⇒ Object
- #check(context) ⇒ Object
- #code ⇒ Object
- #description ⇒ Object
- #severity ⇒ Object
- #validity_rule ⇒ Object
Methods inherited from Base
Instance Method Details
#applicable?(context) ⇒ Boolean
19 20 21 |
# File 'lib/uniword/validation/rules/content_types_coverage_rule.rb', line 19 def applicable?(context) context.part_exists?("[Content_Types].xml") end |
#category ⇒ Object
16 |
# File 'lib/uniword/validation/rules/content_types_coverage_rule.rb', line 16 def category = :content_types |
#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/content_types_coverage_rule.rb', line 23 def check(context) issues = [] content_types = context.content_types override_parts, default_extensions = content_types.keys.partition do |k| k.start_with?("/") end context.zip_entries.each do |entry| next if entry.end_with?("/") next if entry.end_with?(".rels") next if entry == "[Content_Types].xml" next if covered?(entry, default_extensions, override_parts) issues << issue( "ZIP entry '#{entry}' has no content type coverage " \ "in [Content_Types].xml", part: "[Content_Types].xml", suggestion: "Add a <Default Extension=\"#{File.extname(entry).delete_prefix('.')}" \ "\" .../> or <Override PartName=\"/#{entry}\" .../> entry.", ) end issues end |
#code ⇒ Object
13 |
# File 'lib/uniword/validation/rules/content_types_coverage_rule.rb', line 13 def code = "DOC-106" |
#description ⇒ Object
15 |
# File 'lib/uniword/validation/rules/content_types_coverage_rule.rb', line 15 def description = "Every ZIP entry must have content type coverage" |
#severity ⇒ Object
17 |
# File 'lib/uniword/validation/rules/content_types_coverage_rule.rb', line 17 def severity = "error" |
#validity_rule ⇒ Object
14 |
# File 'lib/uniword/validation/rules/content_types_coverage_rule.rb', line 14 def validity_rule = "R7" |