Class: Aladdin::Config

Inherits:
Hash
  • Object
show all
Defined in:
lib/aladdin/config.rb

Overview

Configuration options for Aladdin. Gets all of its values from Spirit::MANIFEST. Values in this file should not be trusted because they are given by the user.

Constant Summary collapse

DEFAULTS =

Default configuration options.

{
  verify: {
    'bin' => 'make',
    'arg_prefix' => ''
   },
  title: 'Lesson X',
  description: 'This is a placeholder description. You should provide your own',
  categories: [],
  static_paths: %w(images)
}

Instance Method Summary collapse

Methods inherited from Hash

#to_struct

Constructor Details

#initialize(root) ⇒ Config

Creates a new configuration from the file at the given path. Merges the configuration hash parsed from the file with DEFAULTS. Raises Aladdin::ConfigError if the file could not be read or parsed.

Parameters:

  • root (String)

    path to lesson root



32
33
34
35
36
37
38
39
# File 'lib/aladdin/config.rb', line 32

def initialize(root)
  super nil
  @path = File.join root, Spirit::MANIFEST
  ensure_readable
  merge! DEFAULTS.deep_merge Spirit::Manifest.load_file @path
rescue Spirit::Error => e
  not_parseable e
end