Skip to content
Snippets Groups Projects
Commit fd00b922 authored by Tyler Lemburg's avatar Tyler Lemburg
Browse files

configs and gitignore

parent 5cf434e2
No related branches found
No related tags found
No related merge requests found
*.gem
*.rbc
/config/server.json
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/test/tmp/
/test/version_tmp/
/tmp/
/public/wdn/
/db/scripts/private/
## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/
## Environment normalisation:
/.bundle/
/lib/bundler/man/
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
# On Mac
*.DS_Store
Rakefile 0 → 100644
require './utils/language'
ENV['RACK_ENV'] = ENV['RACK_ENV'] || 'development'
require './utils/config_loader'
require 'active_record'
task :default => :migrate
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
task :migrate => :environment do
ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
end
task :environment do
# set up the database
require 'utils/database'
end
{
"database" : {
"adapter" : "mysql",
"host" : "localhost",
"username" : "root",
"password" : "",
"database" : "reservations"
}
}
\ No newline at end of file
ROOT = File.expand_path(File.dirname(__FILE__)) << '/..'
$LOAD_PATH.unshift(ROOT)
require 'json'
config = Hash.new
# read a base config file
config.merge!(JSON.parse(File.read("#{ROOT}/config/config.json")))
# read a server/env-specific config file if one exists
if File.exist?("#{ROOT}/config/server.json")
config.merge!(JSON.parse(File.read("#{ROOT}/config/server.json")))
end
CONFIG = config
\ No newline at end of file
require 'active_record'
ActiveRecord::Base.establish_connection({
:adapter => CONFIG['database']['adapter'],
:host => CONFIG['database']['host'],
:username => CONFIG['database']['username'],
:password => CONFIG['database']['password'],
:database => CONFIG['database']['database']
})
class Hash
def checked?(key)
self.has_key?(key) && self[key] == 'on'
end
end
class Integer
def seconds
self
end
def minutes
seconds * 60
end
def hours
minutes * 60
end
def days
hours * 24
end
def weeks
days * 7
end
def amount_display
# assumes this amount is in cents
"$#{self / 100.0}"
end
alias_method :second, :seconds
alias_method :minute, :minutes
alias_method :hour, :hours
alias_method :day, :days
alias_method :week, :weeks
end
class String
alias_method :trim, :strip
alias_method :trim!, :strip!
def capitalize_all
self.split('_').map(&:capitalize).join(' ').split(' ').map(&:capitalize).join(' ')
end
def nl2br
self.gsub("\n\r","<br>").gsub("\r", "").gsub("\n", "<br />")
end
def self.token
return (1..20).to_a.map{(Random.rand(26) + 65).chr}.join
end
end
class Time
def midnight
Time.new(self.year, self.month, self.day)
end
def minutes_after_midnight
((self - self.midnight).to_f / 60).to_i
end
def week_start
time = self
until time.sunday?
time = time - 1.day
end
time.midnight
end
def month_start
Time.new(self.year, self.month, 1)
end
def self.from_minutes(minutes)
Time.now.midnight + minutes.minutes
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment