Class: ExpressionEngine::ConfigurationReader

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/configuration_reader.rb

Constant Summary collapse

DEFAULTS =
{
  :hostname       => 'localhost',
  :theme_path     => 'themes',
  :template_path  => 'templates',
  :captcha_path   => 'images/captcha',
  :avatar_path    => 'images/avatars',
  :photo_path     => 'images/member_photos'
}

Instance Method Summary collapse

Constructor Details

#initialize(configuration_file) ⇒ ConfigurationReader

Returns a new instance of ConfigurationReader.



14
15
16
# File 'lib/vendor/configuration_reader.rb', line 14

def initialize(configuration_file)
  @configuration_file = configuration_file
end

Instance Method Details

#control_panelObject



39
40
41
# File 'lib/vendor/configuration_reader.rb', line 39

def control_panel
  DEFAULTS
end

#databaseObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vendor/configuration_reader.rb', line 18

def database
    database = {}
    pattern = /^\$conf\['([^']+)'\]\s+=\s+"([^"]+)";$/
    mapping = {
      'db_hostname' => :host, 
      'db_username' => :username, 
      'db_password' => :password, 
      'db_name'     => :database,
      'db_type'     => :adapter
    }
  
    matches = File.read(@configuration_file).scan(pattern)
  
    matches.each do |match|
      key = match[0]
      database[mapping[key]] = match[1] if mapping.has_key?(key)
    end
    
    database
end