public
Description: ASCENDS Data Visualization
Homepage:
Clone URL: git://github.com/schleyfox/ascends_viz.git
ascends_viz / initialize.rb
100644 39 lines (28 sloc) 0.985 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# This file handles all the background initialization work that the programmer
# shouldn't have to worry about.
# This includes database startup, common requires, activesupport, and other
# magic. I'm not sure if this is a good idea or not.
 
# ENV works like in rails, except is :real or :test
GTRON_ENV rescue GTRON_ENV = :real
 
GTRON_ROOT = File.dirname(__FILE__)
 
require 'rubygems'
require 'rake'
 
require 'activesupport'
#set up autoload paths
Dependencies.load_paths << "#{GTRON_ROOT}/lib/"
 
require 'active_record'
 
#custom requires
require 'kml'
require 'lib/lisp'
 
def get_db_conn(env)
  env = env.to_sym
  #set up logging
  ActiveRecord::Base.logger = Logger.new("#{GTRON_ROOT}/log/#{env}.log")
  ActiveRecord::Base.logger.level = Logger::INFO
 
  #load in dbs from database.yml
  ActiveRecord::Base.establish_connection(
    YAML::load(File.read("#{GTRON_ROOT}/database.yml"))[env])
 
  #load all models
  Dir["#{GTRON_ROOT}/models/**/*.rb"].each {|r| load r }
 
  nil
end