Module: Jekyll::AgentMarkdown::Configuration::CollectionNames
- Defined in:
- lib/jekyll/agent_markdown/configuration.rb
Class Method Summary collapse
- .normalize(value) ⇒ Object
- .normalized_name!(name) ⇒ Object
- .validate_array!(value) ⇒ Object
- .validate_reserved!(names) ⇒ Object
- .validate_unique!(names) ⇒ Object
Class Method Details
.normalize(value) ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/jekyll/agent_markdown/configuration.rb', line 125 def normalize(value) validate_array!(value) names = value.map { |name| normalized_name!(name) } validate_unique!(names) validate_reserved!(names) names end |
.normalized_name!(name) ⇒ Object
141 142 143 144 145 146 |
# File 'lib/jekyll/agent_markdown/configuration.rb', line 141 def normalized_name!(name) return name.strip if name.is_a?(String) && !name.strip.empty? raise Jekyll::Errors::FatalException, "agent_markdown.collections must contain only non-empty collection names; got #{name.inspect}" end |
.validate_array!(value) ⇒ Object
133 134 135 136 137 138 139 |
# File 'lib/jekyll/agent_markdown/configuration.rb', line 133 def validate_array!(value) return if value.is_a?(Array) raise Jekyll::Errors::FatalException, "agent_markdown.collections must be an Array of unique, non-empty collection names; " \ "got #{value.inspect}" end |
.validate_reserved!(names) ⇒ Object
154 155 156 157 158 159 |
# File 'lib/jekyll/agent_markdown/configuration.rb', line 154 def validate_reserved!(names) return unless names.include?("posts") raise Jekyll::Errors::FatalException, "agent_markdown.collections cannot include \"posts\"; use agent_markdown.posts instead" end |
.validate_unique!(names) ⇒ Object
148 149 150 151 152 |
# File 'lib/jekyll/agent_markdown/configuration.rb', line 148 def validate_unique!(names) return if names.uniq.length == names.length raise Jekyll::Errors::FatalException, "agent_markdown.collections must contain unique collection names" end |