Class: Bookbinder::Config::Checkers::SubnavsChecker
- Inherits:
-
Object
- Object
- Bookbinder::Config::Checkers::SubnavsChecker
- Defined in:
- lib/bookbinder/config/checkers/subnavs_checker.rb
Constant Summary collapse
- MissingRequiredKeyError =
Class.new(RuntimeError)
Class.new(RuntimeError)
Class.new(RuntimeError)
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
23 24 25 |
# File 'lib/bookbinder/config/checkers/subnavs_checker.rb', line 23 def config @config end |
Instance Method Details
#check(config) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bookbinder/config/checkers/subnavs_checker.rb', line 9 def check(config) @config = config if .count > 0 if config..empty? MissingSubnavsKeyError.new("You must specify at least one subnav under the subnavs key in config.yml") elsif .count != 0 MissingSubnavNameError.new("Your config.yml is missing required subnav names under the subnavs key. Required subnav names are #{missing_subnavs.join(", ")}.") elsif .any? MissingRequiredKeyError.new("Your config.yml is missing required key(s) for subnavs #{invalid_subnav_names}. Required keys are #{required_subnav_keys.join(", ")}.") end end end |