Class: Uniword::Quality::DocumentChecker
- Inherits:
-
Object
- Object
- Uniword::Quality::DocumentChecker
- Defined in:
- lib/uniword/quality/document_checker.rb
Overview
Coordinates document quality checking using configured rules.
Responsibility: Load rules from configuration and orchestrate quality checks. Single Responsibility - only coordinates rule execution and report generation.
Follows Open/Closed Principle - new rules can be added via configuration without modifying this class.
Constant Summary collapse
- RULE_CLASSES =
Rule class registry Maps rule names to their class implementations
{ heading_hierarchy: "HeadingHierarchyRule", table_headers: "TableHeaderRule", paragraph_length: "ParagraphLengthRule", image_alt_text: "ImageAltTextRule", link_validation: "LinkValidationRule", style_consistency: "StyleConsistencyRule", }.freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
-
#check(document) ⇒ QualityReport
Check document for quality violations.
-
#disabled_rules ⇒ Array<String>
Get list of disabled rule names.
-
#enabled_rules ⇒ Array<String>
Get list of enabled rule names.
-
#initialize(rules_file: nil, config: nil) ⇒ DocumentChecker
constructor
Initialize document checker.
Constructor Details
#initialize(rules_file: nil, config: nil) ⇒ DocumentChecker
Initialize document checker
42 43 44 45 |
# File 'lib/uniword/quality/document_checker.rb', line 42 def initialize(rules_file: nil, config: nil) @config = load_configuration(rules_file, config) @rules = load_rules end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
25 26 27 |
# File 'lib/uniword/quality/document_checker.rb', line 25 def config @config end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
25 26 27 |
# File 'lib/uniword/quality/document_checker.rb', line 25 def rules @rules end |
Instance Method Details
#check(document) ⇒ QualityReport
Check document for quality violations
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/uniword/quality/document_checker.rb', line 51 def check(document) validate_document!(document) report = QualityReport.new # Execute each enabled rule rules.each do |rule| next unless rule.enabled? violations = rule.check(document) report.add_violations(violations) end report end |
#disabled_rules ⇒ Array<String>
Get list of disabled rule names
77 78 79 |
# File 'lib/uniword/quality/document_checker.rb', line 77 def disabled_rules rules.reject(&:enabled?).map(&:name) end |
#enabled_rules ⇒ Array<String>
Get list of enabled rule names
70 71 72 |
# File 'lib/uniword/quality/document_checker.rb', line 70 def enabled_rules rules.select(&:enabled?).map(&:name) end |