Class: ExpressionEngine::ConfigurationReader
- Inherits:
-
Object
- Object
- ExpressionEngine::ConfigurationReader
- 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
- #control_panel ⇒ Object
- #database ⇒ Object
-
#initialize(configuration_file) ⇒ ConfigurationReader
constructor
A new instance of ConfigurationReader.
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_panel ⇒ Object
39 40 41 |
# File 'lib/vendor/configuration_reader.rb', line 39 def control_panel DEFAULTS end |
#database ⇒ Object
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 |