Class: TxpAdmin::Config

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



64
65
66
# File 'lib/txp_admin.rb', line 64

def initialize
  @options = self.class.parse_config_file      
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



62
63
64
# File 'lib/txp_admin.rb', line 62

def options
  @options
end

Class Method Details

.parse_config_file(path = ".") ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/txp_admin.rb', line 68

def self.parse_config_file(path=".")          
  config_file = "#{path}/textpattern/config.php"      
  raise TxpAdmin::ConfigNotFound unless File.exists?(config_file)            
  
  config_lines = File.readlines(config_file)
  config_to_eval = String.new 
  
  config_lines.each do |line|
     config_to_eval << line if (line.include? "$txpcfg" and !line.include? "define")
  end
        
  config_to_eval.gsub!("$txpcfg", "txpcfg") 
  txpcfg = {}
  eval(config_to_eval)            
  txpcfg.each do |key,value|
    txpcfg[key.to_sym] = value
  end  
        
  # puts txpcfg.inspect
  return txpcfg      
end