Class: SiteFuel::Configuration

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/sitefuel/Configuration.rb

Overview

exception which represents that a configuration could not be found

Constant Summary

DEFAULT_CONFIGURATION_FILE =
'deployment.yml'

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

#debug, #error, #fatal, #info, #logger=, #warn

Constructor Details

#initialize(runtime, yaml_config) ⇒ Configuration

builds a sitefuel configuration from a parsed YAML file



52
53
54
55
56
57
# File 'lib/sitefuel/Configuration.rb', line 52

def initialize(runtime, yaml_config)
  @processor_configurations = Hash.new([])
  @runtime = runtime

  load_yaml_config(yaml_config)
end

Class Method Details

.find_configuration(path, filename = DEFAULT_CONFIGURATION_FILE) ⇒ Object

given a directory path will attempt to location a configuration file



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sitefuel/Configuration.rb', line 22

def self.find_configuration(path, filename = DEFAULT_CONFIGURATION_FILE)
  files = Dir["**/"+filename]

  if files.length < 0
    return nil
  elsif files.length > 1
    warn("Multiple  possible configuration files found: #{files.join(', ')}; using #{files.first}")
    return files.first
  else
    return files.first
  end
end

.load_configuration(runtime, path, filename = DEFAULT_CONFIGURATION_FILE) ⇒ Object

given a directory path will attempt to find and load a configuration file



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/sitefuel/Configuration.rb', line 38

def self.load_configuration(runtime, path, filename = DEFAULT_CONFIGURATION_FILE)
  configuration_file = find_configuration(path, filename)

  if configuration_file == nil
    warn('No deployment configuration file found. Using defaults.')
    return Configuration.new(runtime, nil)
  else
    yaml = YAML::load_file(configuration_file)
    return Configuration.new(runtime, yaml)
  end
end

Instance Method Details

#load_yaml_config(yaml_config) ⇒ Object

loads a yaml configuration



61
62
63
# File 'lib/sitefuel/Configuration.rb', line 61

def load_yaml_config(yaml_config)
  
end

#processor_configuration(processor) ⇒ Object

gives an array of configuration options for the processor



67
68
69
# File 'lib/sitefuel/Configuration.rb', line 67

def processor_configuration(processor)
  @processor_configurations[processor]
end