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, 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.
-
#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.
80 81 82 83 84 85 86 87 |
# File 'lib/metanorma/release/config.rb', line 80 def initialize(data) super( pattern: data["pattern"], 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
78 79 80 |
# File 'lib/metanorma/release/config.rb', line 78 def channels @channels end |
#doctypes ⇒ Object
Returns the value of attribute doctypes
78 79 80 |
# File 'lib/metanorma/release/config.rb', line 78 def doctypes @doctypes end |
#pattern ⇒ Object
Returns the value of attribute pattern
78 79 80 |
# File 'lib/metanorma/release/config.rb', line 78 def pattern @pattern end |
#stages ⇒ Object
Returns the value of attribute stages
78 79 80 |
# File 'lib/metanorma/release/config.rb', line 78 def stages @stages end |
Instance Method Details
#matches?(publication) ⇒ Boolean
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/metanorma/release/config.rb', line 89 def matches?(publication) return false if channels.empty? if pattern && !File.fnmatch?(pattern, publication.slug) 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 |