Class: Glossarist::Validation::Rules::SourceUrnFormatRule
- Defined in:
- lib/glossarist/validation/rules/source_urn_format_rule.rb
Overview
Validates that every URN-format source in citations and references follows a recognized scheme (iso, iec, itu, etc).
Constant Summary collapse
- URN_RE =
%r{\Aurn:([a-z0-9][a-z0-9-]{0,31}):(.+)\z}i.freeze
- KNOWN_SCHEMES =
%w[ iso iec itu iso:std:iso iso:std:iec ].freeze
Instance Method Summary collapse
- #applicable?(context) ⇒ Boolean
- #category ⇒ Object
- #check(context) ⇒ Object
- #code ⇒ Object
- #scope ⇒ Object
- #severity ⇒ Object
Methods inherited from Base
Instance Method Details
#applicable?(context) ⇒ Boolean
20 21 22 |
# File 'lib/glossarist/validation/rules/source_urn_format_rule.rb', line 20 def applicable?(context) context.concept.localizations&.any? end |
#category ⇒ Object
16 |
# File 'lib/glossarist/validation/rules/source_urn_format_rule.rb', line 16 def category = :quality |
#check(context) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/glossarist/validation/rules/source_urn_format_rule.rb', line 24 def check(context) concept = context.concept fname = context.file_name issues = [] all_refs(concept).each_with_index do |ref_str, idx| next unless ref_str && ref_str.start_with?("urn:") match = URN_RE.match(ref_str) unless match issues << issue( "source #{idx + 1} has malformed URN '#{ref_str}'", location: fname, suggestion: "Fix the URN to follow RFC 8141 format", ) end end issues end |
#code ⇒ Object
15 |
# File 'lib/glossarist/validation/rules/source_urn_format_rule.rb', line 15 def code = "GLS-310" |
#scope ⇒ Object
18 |
# File 'lib/glossarist/validation/rules/source_urn_format_rule.rb', line 18 def scope = :concept |
#severity ⇒ Object
17 |
# File 'lib/glossarist/validation/rules/source_urn_format_rule.rb', line 17 def severity = "warning" |