Skip to content

Instantly share code, notes, and snippets.

@MGPalmer
Created April 7, 2011 15:38
Show Gist options
  • Save MGPalmer/908026 to your computer and use it in GitHub Desktop.
Save MGPalmer/908026 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
if load_error.message =~ /Could not find RubyGem rails/
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
else
raise
end
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
class Rails::Boot
def run
load_initializer
Rails::Initializer.class_eval do
def load_gems
@bundler_loaded ||= Bundler.setup(:default, Rails.env) && Bundler.require(:require_first) && Bundler.require(:default, Rails.env)
end
end
Rails::Initializer.run(:set_load_path)
end
end
# All that for this:
Rails.boot!
mt-xps:~/Development/traveliq/traveliq/core/development $ script/server
=> Booting Mongrel
=> Rails 2.3.11 application starting on http://0.0.0.0:3000
/usr/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:320:in `refresh!': source index not created from disk (RuntimeError)
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/rails/vendor_gem_source_index.rb:34:in `refresh!'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/rails/vendor_gem_source_index.rb:29:in `initialize'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/rails/gem_dependency.rb:21:in `new'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/initializer.rb:298:in `add_gem_load_paths'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/initializer.rb:132:in `process'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/initializer.rb:113:in `send'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/initializer.rb:113:in `run'
from /home/mt/Development/traveliq/traveliq/core/development/config/environment.rb:46
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.11/lib/active_support/dependencies.rb:182:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.11/lib/active_support/dependencies.rb:182:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.11/lib/active_support/dependencies.rb:547:in `new_constants_in'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.11/lib/active_support/dependencies.rb:182:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/commands/server.rb:84
from script/server:3:in `require'
from script/server:3
mt-xps:~/Development/traveliq/traveliq/core/development $ bundle --version
Bundler version 1.0.11
mt-xps:~/Development/traveliq/traveliq/core/development $ ruby --version
ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2009.10
mt-xps:~/Development/traveliq/traveliq/core/development $ gem --version
1.7.1
Not using RVM
mt-xps:~/Development/traveliq/traveliq/core/development $ bundle config
Settings are listed in order of priority. The top value will be used.
# Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
#RAILS_GEM_VERSION = '2.3.10' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
# Comment this in to see on stdout what gets required in Rails
#module Kernel
# def require_with_logging(string)
# puts "#{caller.reverse[0..2].map{|str| str.split(/\//).last}}: #{string}"
# require_without_logging(string)
# end
# alias_method :require_without_logging, :require
# alias_method :require, :require_with_logging
#end
CANONICAL_HOST = 'www.travel-iq.com'
FLIGHTS_PER_PAGE = 25
HOTELS_PER_PAGE = 25
# determines if searches and parser_tasks are distributed with resque or started in-process
USE_RESQUE_FOR_TASKS = ENV["USE_RESQUE_FOR_TASKS"] == "true" || ['production', 'staging'].include?(ENV["RAILS_ENV"])
# Whether or not the statistics server is asked for data
USE_REDIS_FOR_STATS = ENV["USE_REDIS_FOR_STATS"] == "true" || ['production', 'staging'].include?(ENV["RAILS_ENV"])
# define if the search should be updated in mongodb
USE_MONGODB = ENV["USE_MONGODB"] == "true" || ['production', 'staging'].include?(ENV["RAILS_ENV"])
PARSERS_ONLY = ENV["PARSERS_ONLY"] == "true"
# for flight searches, this number determines how many searches are observed by a single writer instance
SEARCHES_PER_WRITER_MAX = 5
# This string is the placeholder for an undefined parameter in an API URL
UNDEFINED_PARAMETER_PLACEHOLDER = '_'
# mail_chimp settings
MAIL_CHIMP_API_KEY = 'XXX'
MAIL_CHIMP_TRAVELIQ_LIST_ID = 'XXX'
MAIL_CHIMP_LISTS = ['traveliq', '...']
# See Rails::Configuration for more options.
Rails::Initializer.run do |config|
# Damn ar-extensions need this or explicit requiring of single files to enable the :on_duplicate_key_update functionality.
ENV['LOAD_ADAPTER_EXTENSIONS'] = 'mysql'
# config.threadsafe! if PARSERS_ONLY # this disables code reloading and code auto loading, and does thread safe thingies with AR
# Skip frameworks you're not going to use. To use Rails without a database
# you must remove the Active Record framework.
if PARSERS_ONLY
config.frameworks -= [ :active_resource, :action_controller, :action_mailer, :action_view ]
require 'erb' # normally loaded by action controller
else
config.frameworks -= [ :active_resource ]
end
# Only load the plugins named here, in the order given. By default, all
# plugins # in vendor/plugins are loaded in alphabetical order.
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
if PARSERS_ONLY
config.plugins = [
# :active_scaffold,
:acts_as_list,
:acts_as_nameable,
:acts_as_tree,
# :auto_complete,
:enum_column,
# :fast_remote_cache,
# :find_query_origin,
:"geokit-rails",
# :grouped_validations,
# :haml,
# :machinist,
# :memcache_array,
:raising_finders,
:resque_meta,
:resque_result,
# :restful_authentication,
:spawn,
:travel_iq_serializers,
# :travel_iq_words,
:travel_iq_xml,
:validates_date_time,
:workling,
:zlib_yaml_mem_cache_store
]
else
config.plugins = [:all]
end
config.active_record.schema_format = :sql
# # See http://groups.google.com/group/rubyonrails-core/browse_thread/thread/710868b1292c737f/9e39c0716569a355?lnk=gst&q=module+tree#9e39c0716569a355
# # The hoptoad helper is used a lot in parsers etc.
# only_once_paths = %W(
# #{Rails.root}/lib/hoptoad_helper.rb
# #{Rails.root}/lib/visit_tracking.rb
# #{Rails.root}/lib/display_model_names.rb
# )
# # Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/app/sweepers )
# config.load_paths += only_once_paths
# config.load_once_paths = only_once_paths
# Add additional load paths for your own custom dirs
# config.autoload_paths += %W( #{RAILS_ROOT}/extras )
# Force all environments to use the same logger level
# (by default production uses :info, the others :debug)
# config.log_level = :debug
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
config.time_zone = 'UTC'
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
if PARSERS_ONLY
module Rails
class Initializer
def prepare_dispatcher
# STFU
end
end
end
end
unless PARSERS_ONLY
# Activate observers that should always be running
# The User Observer watches for emails that need to be sent, registration etc.
config.active_record.observers = [:user_observer]
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
config.i18n.default_locale = :en
end
config.after_initialize do
Rails.logger.info "Travel IQ version #{Version::SUBVERSION_REV}"
WillPaginate.enable_activerecord if PARSERS_ONLY
ActiveSupport::XmlMini.backend = 'LibXML'
end
end
source :rubygems
source :rubyforge
source :gemcutter
source 'http://gems.github.com'
## For working on a local fork of the rails repo at the 2.3 branch, use this:
#repo = '/home/mt/Development/traveliq/rails'
#gem 'rails', :path => "#{repo}/railties"
#gem 'actionmailer', :path => "#{repo}/actionmailer"
#gem 'actionpack', :path => "#{repo}/actionpack"
#gem 'activerecord', :path => "#{repo}/activerecord"
#gem 'activesupport', :path => "#{repo}/activesupport"
gem 'rails', '2.3.11'
group :require_first do
gem 'rubyist-aasm', '2.1.1', :require => 'aasm'
gem 'geokit', '1.5'
end
if ENV["PARSERS_ONLY"] == "true"
puts "skipping non-parser gems"
else
gem 'json'
gem 'icalendar', '1.1.0'
gem 'nokogiri', '>= 1.4.0'
if RUBY_VERSION > '1.9'
# faster csv is built-in
else
gem 'fastercsv', '1.4.0'
end
gem 'gchartrb', :require => 'google_chart'
gem 'haml', '2.2.24'
gem 'validatable', '1.6.7'
gem 'BlueCloth', '>= 1.0.0', :require => 'bluecloth'
gem 'mattetti-googlecharts', :require => 'gchart'
gem 'crack', '0.1.7'
gem 'yajl-ruby', :require => 'yajl'
gem 'coderay', '0.9.6'
end
gem 'addressable', '2.2.2'
gem 'sanitize', '1.0.8'
gem 'libxml-ruby', '1.1.3', :require => 'libxml'
#gem 'savon', '0.7.9', :git => 'git://github.com/traveliq/savon.git'
# Our forked version of the savon gem (in vendor/gems), used until and if we can push back our changes into the official gem
gem 'savon', :path => 'vendor/gems/traveliq-savon-0.7.6'
#gem 'mysql2', '0.2.6'
gem 'mysql', '2.8.1'
# To compile curb: sudo apt-get install libcurl4-openssl-dev
gem 'curb', '0.7.8'
gem 'memcache-client', '1.8.5', :require => "memcache"
gem 'tzinfo', '0.3.23'
gem 'mechanize', '0.9.0'
gem 'hpricot', '0.8.2'
if RUBY_VERSION >= '1.9'
gem 'unicode_utils'
end
gem 'rubyzip', '0.9.1', :require => 'zip/zip' unless RUBY_VERSION > '1.9'
gem 'rubyist-aasm', '2.1.1', :require => 'aasm'
gem 'htmlentities', '4.0.0'
gem 'uuidtools', '1.0.7'
gem 'geokit', '1.5'
gem 'redis-namespace', '0.7.0', :require => 'redis/namespace'
gem 'redis', '2.0.1'
gem 'resque', '1.9.7', :git => 'git://github.com/traveliq/resque.git', :branch => 'traveliq-wait-time-options'
gem 'mongo', '1.2.1'
gem 'bson', '1.2.1'
gem 'bson_ext', '1.2.1', :require => 'bson_ext/cbson'
gem 'diacritics_fu', '= 1.0.3'
gem 'ar-extensions', '0.9.2'
gem 'hoptoad_notifier', '2.4.2'
gem 'will_paginate', '2.3.15'
gem 'louisville', :git => 'git://github.com/traveliq/louisville.git'
gem 'masterplan', :git => 'git://github.com/traveliq/masterplan.git'
gem 'memcache_array', :git => 'git://github.com/traveliq/memcache_array.git'
gem 'xml_data_builder', :git => 'git://github.com/traveliq/xml_data_builder.git'
group :development do
unless RUBY_VERSION > '1.9'
# those seem not to work
gem 'ruby-debug'
gem 'mongrel'
end
gem 'query_trace'
gem 'wirble'
gem 'spork'
end
gem 'hoe', '2.8.0' # actually a dependency of SyslogLogger, but we don't want automatic version bumps
group :staging do
gem "SyslogLogger", '1.4.0', :require => "syslog_logger"
end
group :test do
# The rcov should not be frozen, as it is not used from within the application on CI
# And the standard "rcov" gem leads to segmentation faults
gem 'relevance-rcov', '0.9.2.1', :require => 'rcov'
gem 'cucumber', '>= 0.9.3'
gem 'webrat', '= 0.4.4'
gem 'bmabey-email_spec', '= 0.1.3', :require => 'email_spec'
gem 'selenium-client', '1.2.16', :require => 'selenium'
end
group :dont_require_me do
if ENV["PARSERS_ONLY"] == "true"
gem 'haml', '2.2.24' # parsers need haml to render rate descriptions, but we don't want the Rails initializer of haml to run in the parsers only mode, as it uses ActionView
end
gem 'rspec', '1.3.1'
gem 'rspec-rails', '1.3.3'
end
group :production do
gem "SyslogLogger", '1.4.0', :require => "syslog_logger"
end
GIT
remote: git://github.com/traveliq/louisville.git
revision: cbab8df8fd7b01ba3cb7f3fecebaa817caf643db
specs:
louisville (0.1.1)
activesupport
i18n
GIT
remote: git://github.com/traveliq/masterplan.git
revision: c90c30f6cd89f5dd08cc238097f828a51080788a
specs:
masterplan (0.4.0)
activesupport (~> 2.3.5)
GIT
remote: git://github.com/traveliq/memcache_array.git
revision: 68a2cac7f04aec8f488fbfeddfb9c4cdd6a0de40
specs:
memcache_array (1.0)
rspec (~> 1.3.1)
GIT
remote: git://github.com/traveliq/resque.git
revision: 3917628de398a241085933ba5548621877b368fc
branch: traveliq-wait-time-options
specs:
resque (1.9.7)
json (>= 1.1.0)
redis-namespace (~> 0.7.0)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
GIT
remote: git://github.com/traveliq/xml_data_builder.git
revision: 8d84ba8806daf56812344173b2fbea6939f1eac9
specs:
xml_data_builder (1.0.0)
PATH
remote: vendor/gems/traveliq-savon-0.7.6
specs:
savon (0.7.9)
builder (>= 2.1.2)
crack (>= 0.1.4)
GEM
remote: http://rubygems.org/
remote: http://rubygems.org/
remote: http://rubygems.org/
remote: http://gems.github.com/
specs:
BlueCloth (1.0.1)
SyslogLogger (1.4.0)
hoe (>= 1.2.0)
actionmailer (2.3.11)
actionpack (= 2.3.11)
actionpack (2.3.11)
activesupport (= 2.3.11)
rack (~> 1.1.0)
activerecord (2.3.11)
activesupport (= 2.3.11)
activeresource (2.3.11)
activesupport (= 2.3.11)
activesupport (2.3.11)
addressable (2.2.2)
ar-extensions (0.9.2)
activerecord (>= 2.1.2)
bmabey-email_spec (0.1.3)
bson (1.2.1)
bson_ext (1.2.1)
builder (3.0.0)
cgi_multipart_eof_fix (2.5.0)
coderay (0.9.6)
columnize (0.3.2)
crack (0.1.7)
cucumber (0.10.2)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
gherkin (>= 2.3.5)
json (>= 1.4.6)
term-ansicolor (>= 1.0.5)
curb (0.7.8)
daemons (1.1.2)
diacritics_fu (1.0.3)
diff-lcs (1.1.2)
fastercsv (1.4.0)
fastthread (1.0.7)
gchartrb (0.8)
gem_plugin (0.2.3)
geokit (1.5.0)
gherkin (2.3.5)
json (>= 1.4.6)
haml (2.2.24)
hoe (2.8.0)
rake (>= 0.8.7)
hoptoad_notifier (2.4.2)
activesupport
builder
hpricot (0.8.2)
htmlentities (4.0.0)
i18n (0.5.0)
icalendar (1.1.0)
json (1.5.1)
libxml-ruby (1.1.3)
linecache (0.43)
mattetti-googlecharts (1.4.0)
mechanize (0.9.0)
nokogiri (>= 1.0.7)
memcache-client (1.8.5)
mongo (1.2.1)
bson (>= 1.2.1)
mongrel (1.1.5)
cgi_multipart_eof_fix (>= 2.4)
daemons (>= 1.0.3)
fastthread (>= 1.0.1)
gem_plugin (>= 0.2.3)
mysql (2.8.1)
nokogiri (1.4.4)
query_trace (0.1.1)
activerecord
rack (1.1.2)
rails (2.3.11)
actionmailer (= 2.3.11)
actionpack (= 2.3.11)
activerecord (= 2.3.11)
activeresource (= 2.3.11)
activesupport (= 2.3.11)
rake (>= 0.8.3)
rake (0.8.7)
redis (2.0.1)
redis-namespace (0.7.0)
redis (< 3.0.0)
relevance-rcov (0.9.2.1)
rspec (1.3.1)
rspec-rails (1.3.3)
rack (>= 1.0.0)
rspec (= 1.3.1)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
rubyist-aasm (2.1.1)
rubyzip (0.9.1)
sanitize (1.0.8)
hpricot (~> 0.8.1)
selenium-client (1.2.16)
sinatra (1.2.1)
rack (~> 1.1)
tilt (< 2.0, >= 1.2.2)
spork (0.8.4)
term-ansicolor (1.0.5)
tilt (1.2.2)
tzinfo (0.3.23)
uuidtools (1.0.7)
validatable (1.6.7)
vegas (0.1.8)
rack (>= 1.0.0)
webrat (0.4.4)
nokogiri (>= 1.2.0)
will_paginate (2.3.15)
wirble (0.1.3)
yajl-ruby (0.8.2)
PLATFORMS
ruby
DEPENDENCIES
BlueCloth (>= 1.0.0)
SyslogLogger (= 1.4.0)
addressable (= 2.2.2)
ar-extensions (= 0.9.2)
bmabey-email_spec (= 0.1.3)
bson (= 1.2.1)
bson_ext (= 1.2.1)
coderay (= 0.9.6)
crack (= 0.1.7)
cucumber (>= 0.9.3)
curb (= 0.7.8)
diacritics_fu (= 1.0.3)
fastercsv (= 1.4.0)
gchartrb
geokit (= 1.5)
haml (= 2.2.24)
hoe (= 2.8.0)
hoptoad_notifier (= 2.4.2)
hpricot (= 0.8.2)
htmlentities (= 4.0.0)
icalendar (= 1.1.0)
json
libxml-ruby (= 1.1.3)
louisville!
masterplan!
mattetti-googlecharts
mechanize (= 0.9.0)
memcache-client (= 1.8.5)
memcache_array!
mongo (= 1.2.1)
mongrel
mysql (= 2.8.1)
nokogiri (>= 1.4.0)
query_trace
rails (= 2.3.11)
redis (= 2.0.1)
redis-namespace (= 0.7.0)
relevance-rcov (= 0.9.2.1)
resque (= 1.9.7)!
rspec (= 1.3.1)
rspec-rails (= 1.3.3)
ruby-debug
rubyist-aasm (= 2.1.1)
rubyzip (= 0.9.1)
sanitize (= 1.0.8)
savon!
selenium-client (= 1.2.16)
spork
tzinfo (= 0.3.23)
uuidtools (= 1.0.7)
validatable (= 1.6.7)
webrat (= 0.4.4)
will_paginate (= 2.3.15)
wirble
xml_data_builder!
yajl-ruby
begin
require "rubygems"
require "bundler"
rescue LoadError
raise "Could not load the bundler gem. Install it with `gem install bundler`."
end
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
raise RuntimeError, "Your bundler version is too old." +
"Run `gem install bundler` to upgrade."
end
begin
# Set up load paths for all bundled gems
ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
Bundler.setup
rescue Bundler::GemNotFound => e
raise RuntimeError, e.message + ". Did you run `bundle install`?"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment