Skip to content

Instantly share code, notes, and snippets.

@trevrosen
Created June 25, 2009 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevrosen/136051 to your computer and use it in GitHub Desktop.
Save trevrosen/136051 to your computer and use it in GitHub Desktop.
ZPROXY_CONFIG = Hash.new
# General config
configure do
gems = %w(activerecord logger hpricot open-uri resolv restclient net/http yaml rexml/document rack-flash mailfactory json net/smtp)
zproxy_libs = %w(submission validator webex)
(gems + zproxy_libs).each do |dependency|
begin
require dependency
rescue LoadError => e
puts
puts "You're missing some gems. Here's the trace:"
puts
puts e
end
end
# Turn on Sinatra's session support
# TODO: Ensure that Rack turns on sessions in test mode
unless test?
enable :sessions
end
# WebEx API connection stuff
WEBEX = Hash.new
if development?
#<private connection crap -- setting constants>
else
#<private connection crap -- setting constants>
end
# DB STUFF -----------------------------------------------
db = File.open File.dirname(__FILE__) + "/database.yml"
ActiveRecord::Base.configurations = YAML.load(db)
def main_app_db
config = ActiveRecord::Base.configurations
case
when development?
ZPROXY_CONFIG['env'] = "development"
when test?
ZPROXY_CONFIG['env'] = "test"
when production?
ZPROXY_CONFIG['env'] = "production"
else
ZPROXY_CONFIG['env'] = "development"
end
config[ZPROXY_CONFIG['env']].symbolize_keys
end
ActiveRecord::Base.establish_connection(main_app_db)
end
# End common config
configure :development do
require 'ruby-debug'
LOGGER = Logger.new(STDOUT)
LOGGER.level = Logger::DEBUG
REFERER_DOMAIN = "localhost"
REPOST_URL = "http://localhost/zproxy/zptest.php"
# Where a bad submission gets re-directed
DEFAULT_REDIRECT = "http://localhost/zproxy/redirected.php"
end
configure :test do
LOGGER = Logger.new('log/test.log')
LOGGER.level = Logger::WARN
REFERER_DOMAIN = "venkman.local"
REPOST_URL = "http://localhost/zproxy/zptest.php"
# Where a bad submission gets re-directed
DEFAULT_REDIRECT = "http://localhost/zproxy/redirected.php"
end
configure :production do
LOGGER = Logger.new('log/production.log')
LOGGER.level = Logger::INFO
REFERER_DOMAIN = "foo.com"
REPOST_URL = "http://foo.net/post"
# Where a bad submission gets re-directed
DEFAULT_REDIRECT = "http://www.foo.com"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment