class FrontmatterRules
Public Class Methods
dashless?(values)
click to toggle source
Returns true if there are no dashes in any of the values
# File lib/jekyll_frontmatter_tests/jekyll_frontmatter_tests_rules.rb, line 7 def dashless?(values) rules_config = RulesConfig.new rules = rules_config.rules['no-dash'] || rules_config.empty_rule exceptions = rules['exceptions'].compact if values.instance_of?(Array) no_dashes = values.map do |value| (!value.include?('-') && !value.include?('–')) || exceptions.include?(value) end # no_dashes will only have false values if there are dashes present !no_dashes.include? false elsif values.instance_of?(String) (!values.include?('-') && !values.include?('–')) || exceptions.include?(values) end end
lowercase?(values)
click to toggle source
Returns true if there are no uppercase characters in any of the values
# File lib/jekyll_frontmatter_tests/jekyll_frontmatter_tests_rules.rb, line 23 def lowercase?(values) rules_config = RulesConfig.new rules = rules_config.rules['lowercase'] || rules_config.empty_rule exceptions = rules['exceptions'].compact if values.instance_of?(Array) all_lowercase = values.map do |value| (value.downcase == value) || exceptions.include?(value) end # all_lowercase will only have false values if there are are uppercase # characters present !all_lowercase.include? false elsif values.instance_of?(String) (values.downcase === values) || exceptions.include?(values) end end