Class: Metanorma::Release::DocumentEntry
- Inherits:
-
Struct
- Object
- Struct
- Metanorma::Release::DocumentEntry
- Defined in:
- lib/metanorma/release/config.rb
Overview
Single routing entry — matches by any combination of pattern, source, stage, and doctype. An entry with no criteria matches everything (catch-all).
Instance Attribute Summary collapse
-
#channels ⇒ Object
Returns the value of attribute channels.
-
#doctypes ⇒ Object
Returns the value of attribute doctypes.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#source ⇒ Object
Returns the value of attribute source.
-
#stages ⇒ Object
Returns the value of attribute stages.
Instance Method Summary collapse
-
#initialize(data) ⇒ DocumentEntry
constructor
A new instance of DocumentEntry.
- #matches?(publication) ⇒ Boolean
Constructor Details
#initialize(data) ⇒ DocumentEntry
Returns a new instance of DocumentEntry.
66 67 68 69 70 71 72 73 74 |
# File 'lib/metanorma/release/config.rb', line 66 def initialize(data) super( pattern: data["pattern"], source: data["source"], stages: Array(data["stage"]).map(&:to_s), doctypes: Array(data["doctype"]).map(&:to_s), channels: Array(data["channels"]).map(&:to_s), ) end |
Instance Attribute Details
#channels ⇒ Object
Returns the value of attribute channels
65 66 67 |
# File 'lib/metanorma/release/config.rb', line 65 def channels @channels end |
#doctypes ⇒ Object
Returns the value of attribute doctypes
65 66 67 |
# File 'lib/metanorma/release/config.rb', line 65 def doctypes @doctypes end |
#pattern ⇒ Object
Returns the value of attribute pattern
65 66 67 |
# File 'lib/metanorma/release/config.rb', line 65 def pattern @pattern end |
#source ⇒ Object
Returns the value of attribute source
65 66 67 |
# File 'lib/metanorma/release/config.rb', line 65 def source @source end |
#stages ⇒ Object
Returns the value of attribute stages
65 66 67 |
# File 'lib/metanorma/release/config.rb', line 65 def stages @stages end |
Instance Method Details
#matches?(publication) ⇒ Boolean
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/metanorma/release/config.rb', line 76 def matches?(publication) return false if channels.empty? if pattern && !File.fnmatch?(pattern, publication.slug) return false end if source && !(publication.source_path&.end_with?(source) || false) return false end if !stages.empty? && !stages.include?(publication.stage.to_s) return false end if !doctypes.empty? && !doctypes.include?(publication.doctype.to_s) return false end true end |