Class: Messiah::Supports::CodeIgniter

Inherits:
Object
  • Object
show all
Defined in:
lib/messiah/supports/code_igniter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ CodeIgniter

Returns a new instance of CodeIgniter.



6
7
8
9
10
# File 'lib/messiah/supports/code_igniter.rb', line 6

def initialize(config)
  @config = config
  configure!
  configure_database!
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



4
5
6
# File 'lib/messiah/supports/code_igniter.rb', line 4

def config
  @config
end

Instance Method Details

#configure!Object



12
13
14
15
# File 'lib/messiah/supports/code_igniter.rb', line 12

def configure!
  config.script 'index.php'
  config.database_file File.join(config.app_root, 'config', 'database.php')
end

#configure_database!Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/messiah/supports/code_igniter.rb', line 17

def configure_database!
  reader = File.join(File.dirname(__FILE__), 'code_igniter.php')
  json = %x|php #{reader} #{config.database_file}|
  ci_hash = JSON.load(json)

  config.database = {
    :adapter    => ci_hash['dbdriver'],
    :host       => ci_hash['hostname'],
    :database   => ci_hash['database'],
    :port       => ci_hash['port'] && ci_hash['port'].to_i,
    :username   => ci_hash['username'],
    :password   => ci_hash['password']
  }
rescue
  # swallow everything, leave the database unconfigured
end