-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.rb
47 lines (40 loc) · 1.35 KB
/
setup.rb
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
41
42
43
44
45
46
47
require 'sinatra'
# The code below will automatically require all the gems listed in our Gemfile,
# so we don't have to manually require gems a la
#
# require 'data_mapper'
# require 'dotenv'
#
# See: http://bundler.io/sinatra.html
require 'rubygems'
require 'bundler/setup'
# This requires all gems necessary regardless of environment (:default)
# and any environment-specific gems.
Bundler.require(:default, Sinatra::Application.environment)
# *Note*
# Sinatra::Application.environment is set to the value of ENV['RACK_ENV']
# if RACK_ENV is set. Otherwise, it defaults to :development.
# Load the .env file if it exists
if File.exists?('.env')
Dotenv.load('.env')
end
# Yell at the user (and exit) if DATABASE_URL isn't set
unless ENV.has_key?('DATABASE_URL')
puts "ENV['DATABASE_URL'] is undefined. Make sure your .env file is correct."
puts "To use the example file env.example, run"
puts ""
puts " rake setup:dotenv"
puts ""
puts "or"
puts ""
puts " cp env.example .env"
puts ""
exit 1
end
# In development, the DATABASE_URL environment variable should be defined in the
# '.env' file. In production, Heroku will set this environment variable for you.
DataMapper.setup(:default, ENV['DATABASE_URL'])
# Display DataMapper debugging information in development
if Sinatra::Application.development?
DataMapper::Logger.new($stdout, :debug)
end