Class: Metanorma::Release::DocumentEntry

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

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

#channelsObject

Returns the value of attribute channels

Returns:

  • (Object)

    the current value of channels



78
79
80
# File 'lib/metanorma/release/config.rb', line 78

def channels
  @channels
end

#doctypesObject

Returns the value of attribute doctypes

Returns:

  • (Object)

    the current value of doctypes



78
79
80
# File 'lib/metanorma/release/config.rb', line 78

def doctypes
  @doctypes
end

#patternObject

Returns the value of attribute pattern

Returns:

  • (Object)

    the current value of pattern



78
79
80
# File 'lib/metanorma/release/config.rb', line 78

def pattern
  @pattern
end

#stagesObject

Returns the value of attribute stages

Returns:

  • (Object)

    the current value of stages



78
79
80
# File 'lib/metanorma/release/config.rb', line 78

def stages
  @stages
end

Instance Method Details

#matches?(publication) ⇒ Boolean

Returns:

  • (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