Class: Bookbinder::Config::Checkers::SubnavsChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/bookbinder/config/checkers/subnavs_checker.rb

Constant Summary collapse

MissingRequiredKeyError =
Class.new(RuntimeError)
MissingSubnavsKeyError =
Class.new(RuntimeError)
MissingSubnavNameError =
Class.new(RuntimeError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject (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 section_subnav_names.count > 0
    if config.subnavs.empty?
       MissingSubnavsKeyError.new("You must specify at least one subnav under the subnavs key in config.yml")
    elsif missing_subnavs.count != 0
      MissingSubnavNameError.new("Your config.yml is missing required subnav names under the subnavs key. Required subnav names are #{missing_subnavs.join(", ")}.")
    elsif invalid_subnavs.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