Class: Musako::Configuration

Inherits:
Hash
  • Object
show all
Defined in:
lib/musako/configuration.rb

Constant Summary collapse

DEFAULTS =

Default options.

{
  source:      Dir.pwd,
  destination: File.join(Dir.pwd, 'target'),
  views:       'views',
  assets:      'assets',
  posts:       'posts',

  port:        '3333',
  host:        '0.0.0.0',
  verbose:     true,
  detach:      false,

  author:      'nobody',
  title:       'my notes',
  description: 'my tech notes',
  timezone:    'UTC',
  site_url:    'http://pages.github.com'
}

Instance Method Summary collapse

Instance Method Details

#read_config_fileObject

load YAML file.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/musako/configuration.rb', line 27

def read_config_file
  c = clone

  config = YAML.load_file(File.join(DEFAULTS[:source], "config.yml"))
  unless config.is_a? Hash
    raise ArgumentError.new("Configuration file: invalid #{file}")
  end
  c.merge(config)
rescue SystemCallError
  raise LoadError, "Configuration file: not found #{file}"
end

#symbolize_keysObject



39
40
41
42
43
44
45
# File 'lib/musako/configuration.rb', line 39

def symbolize_keys
  inject({}) do |options, (key, value)|
    value = value.symbolize_keys if defined?(value.symbolize_keys)
    options[(key.to_sym rescue key) || key] = value
    options
  end
end