-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvironment.rb
More file actions
40 lines (31 loc) · 999 Bytes
/
environment.rb
File metadata and controls
40 lines (31 loc) · 999 Bytes
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
40
# Setup the environment for the application.
# Rack environment
RACK_ENV = ENV['RACK_ENV'] || 'development' unless defined?(RACK_ENV)
root_dir = File.expand_path(File.dirname(__FILE__))
# Load dependencies
require File.join(root_dir, 'vendor/gems/environment')
Bundler.require_env RACK_ENV
# Load standard libs
require 'json'
# Setup loas path
$LOAD_PATH[0, 0] = %w[. models lib].map { |d| File.join(root_dir, d) }
# Encoding
# Rack need its input is ASCII-8BIT encoded
Encoding.default_external = Encoding::ASCII_8BIT if defined?(Encoding)
# Load libraries
Dir[root_dir + '/lib/*.rb'].each { |lib| require lib }
# Connect DB
if RACK_ENV == 'test'
DataMapper.setup :default, 'sqlite3::memory:'
else
DataMapper.setup(:default, {
:adapter => 'mysql',
:encoding => 'UTF-8',
:soket => '/tmp/mysql.sock',
:database => "recruitment_#{RACK_ENV}",
:username => 'root',
:password => nil
})
end
# Load models
Dir[root_dir + '/models/**/*.rb'].each { |m| require m }