Sha256: 3ecee546809ef251ed7826dfd24d983040186e97719fc17d057ffd4725a0ec40

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module ExpressionEngine
  
  class ConfigurationReader

    DEFAULTS = {
      :hostname       => 'localhost',
      :theme_path     => 'themes',
      :template_path  => 'templates',
      :captcha_path   => 'images/captcha',
      :avatar_path    => 'images/avatars',
      :photo_path     => 'images/member_photos'
    }
    
    def initialize(configuration_file)
      @configuration_file = configuration_file
    end
    
    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
    
    def control_panel
      DEFAULTS
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbee-0.1.0 lib/vendor/configuration_reader.rb