Skip to content

Instantly share code, notes, and snippets.

@dougbarth
Created May 21, 2010 19:21
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 dougbarth/409303 to your computer and use it in GitHub Desktop.
Save dougbarth/409303 to your computer and use it in GitHub Desktop.
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
defined? Rails::Initializer
end
def pick_boot
(vendor_rails? ? VendorBoot : GemBoot).new
end
def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
end
def preinitialize
load(preinitializer_path) if File.exist?(preinitializer_path)
end
def preinitializer_path
"#{RAILS_ROOT}/config/preinitializer.rb"
end
end
class Boot
def run
load_initializer
Rails::Initializer.run(:set_load_path)
end
end
class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
Rails::GemDependency.add_frozen_gem_path
end
end
class GemBoot < Boot
def load_initializer
self.class.load_rubygems
load_rails_gem
require 'initializer'
end
def load_rails_gem
if version = self.class.gem_version
gem 'rails', version
else
gem 'rails'
end
rescue Gem::LoadError => load_error
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
exit 1
end
class << self
def rubygems_version
Gem::RubyGemsVersion rescue nil
end
def gem_version
if defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION
elsif ENV.include?('RAILS_GEM_VERSION')
ENV['RAILS_GEM_VERSION']
else
parse_gem_version(read_environment_rb)
end
end
def load_rubygems
min_version = '1.3.2'
require 'rubygems'
unless rubygems_version >= min_version
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end
rescue LoadError
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end
def parse_gem_version(text)
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
end
private
def read_environment_rb
File.read("#{RAILS_ROOT}/config/environment.rb")
end
end
end
end
# Adding support for Bundler.
#
# http://gembundler.com/rails23.html
class Rails::Boot
def run
load_initializer
extend_environment
Rails::Initializer.run(:set_load_path)
end
def extend_environment
Rails::Initializer.class_eval do
old_load = instance_method(:load_environment)
define_method(:load_environment) do
Bundler.require Rails.env, :plugins
old_load.bind(self).call
end
end
end
end
# All that for this:
Rails.boot!
# Be sure to restart your web server when you modify this file.
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
#ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.4'
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
require 'hodel_3000_compliant_logger'
require Rails.root + 'vendor/plugins/app_config/lib/configuration'
require Rails.root + 'vendor/plugins/utils/lib/local_gem_dependency'
require Rails.root + 'lib/make_and_model'
def load_config(rel_path)
config_path = RAILS_ROOT + '/config/environments/' + rel_path
if File.exists?(config_path)
config = configuration
eval(IO.read(config_path), binding, config_path)
else
puts "Config file <#{config_path}> does not exist." if $DEBUG
end
end
@all_makes_loaded = false
def load_environment_config(make = app_make)
unless @all_makes_loaded
load_config "all_makes/#{app_model}_common.rb"
load_config "all_makes/#{app_model}_#{RAILS_ENV}.rb"
@all_maked_loaded = true
end
load_config "#{make}/common.rb"
load_config "#{make}/common_#{RAILS_ENV}.rb"
load_config "#{make}/#{app_model}_#{RAILS_ENV}.rb"
end
Rails::Initializer.run do |config|
include MakeAndModel
config.active_record.schema_format = :sql
config.active_record.observers = :scheduled_message_observer
# session store
config.action_controller.session_store = :active_record_store
#config.action_controller.session_store = :mem_cache_store
config.action_view.field_error_proc = Proc.new{ |html_tag, instance| "<span class=\"fieldWithErrors\">#{html_tag}</span>" }
# Change cache directory
config.action_controller.page_cache_directory = RAILS_ROOT+"/public/cache/"
config.app_config.use_ssl = true
end
# Do further application configuration in initializer files.
source :gemcutter
source Bundler::Source::GemCache.new("path" => File.expand_path("../vendor/plugins/utils/local_gems", __FILE__))
gem "rails", "2.3.4"
gem "rake", "0.8.7"
gem "mysql", "2.8.1"
# Required gems
################### couchrest ##########
# new versions of rest-client break couchrest
gem 'rest-client', '0.9.2', :require => 'restclient'
gem 'couchrest', '0.37', :require => 'couchrest'
########################################
# ############ bj #####################
# newer versions of main cause an io error when testing
gem 'fattr', '1.0.3'
gem 'main', '2.8.3'
gem 'bj', '1.0.1'
#######################################
gem 'jwood-will_paginate', '2.3.11', :require => nil
gem 'liquid', '1.9.0'
gem 'validatable', '1.6.7'
gem 'facets', '2.4.4', :require => nil
gem 'chronic', '0.2.3'
gem 'money', '2.1.4'
gem 'rmagick', :require => 'RMagick'
gem 'htmlentities', '4.0.0'
gem 'mysql'
gem 'tzinfo', '~> 0.3.8'
gem 'fastercsv', '1.4.0'
gem 'roo', '1.2.3'
gem 'eventmachine', '0.12.2'
gem 'dougbarth-sync_mq-amqp', '0.7.0', :require => 'amqp'
gem 'calendar_date_select', '1.15', :require => nil
gem 'prawn'
gem 'uuid', '1.0.4'
gem "libxml-ruby", '1.1.3', :require => "xml/libxml"
gem 'json'
gem 'validates_timeliness', '2.1.0'
gem 'admob', '1.1.1'
gem 'rubyzip2', '2.0.1', :require => 'zip/zip'
gem 'nokogiri', '1.4.1'
gem 'jwood-handsoap', '1.1.7.3', :require => 'handsoap'
#using revo-paper_trail with thread-safety fix
gem 'revo-paper_trail', '1.4.2', :require => nil
gem 'query_trace', '0.0.3', :group => [:development, :test]
gem 'gattica', '0.4.0', :path => 'vendor/gems'
group :test do
gem 'ruby-debug', '0.10.1'
gem 'mocha', '0.9.4', :require => nil
gem 'thoughtbot-shoulda', '2.10.1', :require => 'shoulda'
gem 'fakeweb', '1.2.6'
gem 'ci_reporter', '1.6.2'
end
* Locked bundle
* Bundler version 0.9.25
* ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin10.3.0]
Ruby Enterprise Edition 20090610
* rvm 0.1.32 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
$ rake routes --trace
(in /Users/doug/Code/git/textme)
** Invoke routes (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant CouchRest
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:443:in `load_missing_constant'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in `const_missing'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:92:in `const_missing'
/Users/doug/Code/git/textme/config/initializers/couchdb.rb:40
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:145:in `load'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:145:in `load'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rails-2.3.4/lib/initializer.rb:622:in `load_application_initializers'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rails-2.3.4/lib/initializer.rb:621:in `each'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rails-2.3.4/lib/initializer.rb:621:in `load_application_initializers'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rails-2.3.4/lib/initializer.rb:176:in `process'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rails-2.3.4/lib/initializer.rb:113:in `send'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rails-2.3.4/lib/initializer.rb:113:in `run'
/Users/doug/Code/git/textme/config/environment.rb:48
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rails-2.3.4/lib/tasks/misc.rake:4
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/Users/doug/.rvm/rubies/ree-1.8.6-20090610/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/Users/doug/.rvm/rubies/ree-1.8.6-20090610/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level_without_growl'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level_without_growl'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level_without_growl'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rakegrowl-0.2.0/lib/rakegrowl.rb:32:in `top_level'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/doug/.rvm/gems/ree-1.8.6-20090610/gems/rake-0.8.7/bin/rake:31
/Users/doug/.rvm/rubies/ree-1.8.6-20090610/bin/rake:24:in `load'
/Users/doug/.rvm/rubies/ree-1.8.6-20090610/bin/rake:24
begin
# Set up load paths for the locked set of pre-resolved gems.
require File.expand_path('../../.bundle/environment', __FILE__)
rescue LoadError
# Fall back on trying to resolve out of already-installed gems at runtime.
require "rubygems"
require "bundler"
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.5")
raise RuntimeError,
"Your bundler version is incompatible with Rails 2.3 " \
"and an unlocked bundle.\n" \
"Run `gem install bundler` to upgrade or `bundle lock` to lock."
end
begin
# Set up load paths for all bundled gems
Bundler.setup
# Require all gems not in a group
Bundler.require :default
rescue Bundler::GemNotFound
raise Bundler::GemNotFound, "Bundler couldn't find some gems. " \
"Did you run `bundle install`?"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment