Skip to content
Browse files

Remove config.gem in favor of using the bundler. This makes config/bo…

…ot.rb obsolete.

	The bundler library is at: http://github.com/wycats/bundler/ and is a rubygem.
  • Loading branch information...
1 parent 29ba9c0 commit e1fdc8bba3e427435927685e77937b3a478aa416 Carl Lerche committed Oct 16, 2009
View
16 railties/lib/rails/application.rb
@@ -57,13 +57,6 @@ def new
$LOAD_PATH.uniq!
end
- # Bail if boot.rb is outdated
- initializer :freak_out_if_boot_rb_is_outdated do
- unless defined?(Rails::BOOTSTRAP_VERSION)
- abort %{Your config/boot.rb is outdated: Run "rake rails:update".}
- end
- end
-
# Requires all frameworks specified by the Configuration#frameworks
# list. By default, all frameworks (Active Record, Active Support,
# Action Pack, Action Mailer, and Active Resource) are loaded.
@@ -133,15 +126,6 @@ def new
end
end
- initializer :add_gem_load_paths do
- require 'rails/gem_dependency'
- Rails::GemDependency.add_frozen_gem_path
- unless config.gems.empty?
- require "rubygems"
- config.gems.each { |gem| gem.add_load_paths }
- end
- end
-
# Preload all frameworks specified by the Configuration#frameworks.
# Used by Passenger to ensure everything's loaded before forking and
# to avoid autoload race conditions in JRuby.
View
4 railties/lib/rails/backtrace_cleaner.rb
@@ -1,5 +1,4 @@
require 'active_support/backtrace_cleaner'
-require 'rails/gem_dependency'
module Rails
class BacktraceCleaner < ActiveSupport::BacktraceCleaner
@@ -36,9 +35,6 @@ def add_gem_filters
# http://gist.github.com/30430
add_filter { |line| line.sub(/(#{path})\/gems\/([a-z]+)-([0-9.]+)\/(.*)/, '\2 (\3) \4')}
end
-
- vendor_gems_path = Rails::GemDependency.unpacked_path.sub("#{Rails.root}/",'')
- add_filter { |line| line.sub(/(#{vendor_gems_path})\/([a-z]+)-([0-9.]+)\/(.*)/, '\2 (\3) [v] \4')}
end
end
View
21 railties/lib/rails/gem_builder.rb
@@ -1,21 +0,0 @@
-require 'rubygems'
-require 'rubygems/installer'
-
-module Rails
-
- # this class hijacks the functionality of Gem::Installer by overloading its
- # initializer to only provide the information needed by
- # Gem::Installer#build_extensions (which happens to be what we have)
- class GemBuilder < Gem::Installer
-
- def initialize(spec, gem_dir)
- @spec = spec
- @gem_dir = gem_dir
- end
-
- # silence the underlying builder
- def say(message)
- end
-
- end
-end
View
311 railties/lib/rails/gem_dependency.rb
@@ -1,311 +0,0 @@
-require 'rails/vendor_gem_source_index'
-
-module Gem
- def self.source_index=(index)
- @@source_index = index
- end
-end
-
-module Rails
- class GemDependency < Gem::Dependency
- attr_accessor :lib, :source, :dep
-
- def self.unpacked_path
- @unpacked_path ||= File.join(Rails.root, 'vendor', 'gems')
- end
-
- @@framework_gems = {}
-
- def self.add_frozen_gem_path
- @@paths_loaded ||= begin
- source_index = Rails::VendorGemSourceIndex.new(Gem.source_index)
- Gem.clear_paths
- Gem.source_index = source_index
- # loaded before us - we can't change them, so mark them
- Gem.loaded_specs.each do |name, spec|
- @@framework_gems[name] = spec
- end
- true
- end
- end
-
- def self.from_directory_name(directory_name, load_spec=true)
- directory_name_parts = File.basename(directory_name).split('-')
- name = directory_name_parts[0..-2].join('-')
- version = directory_name_parts.last
- result = self.new(name, :version => version)
- spec_filename = File.join(directory_name, '.specification')
- if load_spec
- raise "Missing specification file in #{File.dirname(spec_filename)}. Perhaps you need to do a 'rake gems:refresh_specs'?" unless File.exists?(spec_filename)
- spec = YAML::load_file(spec_filename)
- result.specification = spec
- end
- result
- rescue ArgumentError => e
- raise "Unable to determine gem name and version from '#{directory_name}'"
- end
-
- def initialize(name, options = {})
- require 'rubygems' unless Object.const_defined?(:Gem)
-
- if options[:requirement]
- req = options[:requirement]
- elsif options[:version]
- req = Gem::Requirement.create(options[:version])
- else
- req = Gem::Requirement.default
- end
-
- @lib = options[:lib]
- @source = options[:source]
- @loaded = @frozen = @load_paths_added = false
-
- super(name, req)
- end
-
- def add_load_paths
- self.class.add_frozen_gem_path
- return if @loaded || @load_paths_added
- if framework_gem?
- @load_paths_added = @loaded = @frozen = true
- return
- end
- gem self
- @spec = Gem.loaded_specs[name]
- @frozen = @spec.loaded_from.include?(self.class.unpacked_path) if @spec
- @load_paths_added = true
- rescue Gem::LoadError
- end
-
- def dependencies
- return [] if framework_gem?
- return [] unless installed?
- specification.dependencies.reject do |dependency|
- dependency.type == :development
- end.map do |dependency|
- GemDependency.new(dependency.name, :requirement => dependency.version_requirements)
- end
- end
-
- def specification
- # code repeated from Gem.activate. Find a matching spec, or the currently loaded version.
- # error out if loaded version and requested version are incompatible.
- @spec ||= begin
- matches = Gem.source_index.search(self)
- matches << @@framework_gems[name] if framework_gem?
- if Gem.loaded_specs[name] then
- # This gem is already loaded. If the currently loaded gem is not in the
- # list of candidate gems, then we have a version conflict.
- existing_spec = Gem.loaded_specs[name]
- unless matches.any? { |spec| spec.version == existing_spec.version } then
- raise Gem::Exception,
- "can't activate #{@dep}, already activated #{existing_spec.full_name}"
- end
- # we're stuck with it, so change to match
- version_requirements = Gem::Requirement.create("=#{existing_spec.version}")
- existing_spec
- else
- # new load
- matches.last
- end
- end
- end
-
- def specification=(s)
- @spec = s
- end
-
- def requirement
- r = version_requirements
- (r == Gem::Requirement.default) ? nil : r
- end
-
- def built?
- return false unless frozen?
-
- if vendor_gem?
- specification.extensions.each do |ext|
- makefile = File.join(unpacked_gem_directory, File.dirname(ext), 'Makefile')
- return false unless File.exists?(makefile)
- end
- end
-
- true
- end
-
- def framework_gem?
- @@framework_gems.has_key?(name)
- end
-
- def frozen?
- @frozen ||= vendor_rails? || vendor_gem?
- end
-
- def installed?
- Gem.loaded_specs.keys.include?(name)
- end
-
- def load_paths_added?
- # always try to add load paths - even if a gem is loaded, it may not
- # be a compatible version (ie random_gem 0.4 is loaded and a later spec
- # needs >= 0.5 - gem 'random_gem' will catch this and error out)
- @load_paths_added
- end
-
- def loaded?
- @loaded ||= begin
- if vendor_rails?
- true
- elsif specification.nil?
- false
- else
- # check if the gem is loaded by inspecting $"
- # specification.files lists all the files contained in the gem
- gem_files = specification.files
- # select only the files contained in require_paths - typically in bin and lib
- require_paths_regexp = Regexp.new("^(#{specification.require_paths*'|'})/")
- gem_lib_files = gem_files.select { |f| require_paths_regexp.match(f) }
- # chop the leading directory off - a typical file might be in
- # lib/gem_name/file_name.rb, but it will be 'require'd as gem_name/file_name.rb
- gem_lib_files.map! { |f| f.split('/', 2)[1] }
- # if any of the files from the above list appear in $", the gem is assumed to
- # have been loaded
- !(gem_lib_files & $").empty?
- end
- end
- end
-
- def vendor_rails?
- Gem.loaded_specs.has_key?(name) && Gem.loaded_specs[name].loaded_from.empty?
- end
-
- def vendor_gem?
- specification && File.exists?(unpacked_gem_directory)
- end
-
- def build(options={})
- require 'rails/gem_builder'
- return if specification.nil?
- if options[:force] || !built?
- return unless File.exists?(unpacked_specification_filename)
- spec = YAML::load_file(unpacked_specification_filename)
- Rails::GemBuilder.new(spec, unpacked_gem_directory).build_extensions
- puts "Built gem: '#{unpacked_gem_directory}'"
- end
- dependencies.each { |dep| dep.build(options) }
- end
-
- def install
- unless installed?
- cmd = "#{gem_command} #{install_command.join(' ')}"
- puts cmd
- puts %x(#{cmd})
- end
- end
-
- def load
- return if @loaded || @load_paths_added == false
- require(@lib || name) unless @lib == false
- @loaded = true
- rescue LoadError
- puts $!.to_s
- $!.backtrace.each { |b| puts b }
- end
-
- def refresh
- Rails::VendorGemSourceIndex.silence_spec_warnings = true
- real_gems = Gem.source_index.installed_source_index
- exact_dep = Gem::Dependency.new(name, "= #{specification.version}")
- matches = real_gems.search(exact_dep)
- installed_spec = matches.first
- if frozen?
- if installed_spec
- # we have a real copy
- # get a fresh spec - matches should only have one element
- # note that there is no reliable method to check that the loaded
- # spec is the same as the copy from real_gems - Gem.activate changes
- # some of the fields
- real_spec = Gem::Specification.load(matches.first.loaded_from)
- write_specification(real_spec)
- puts "Reloaded specification for #{name} from installed gems."
- else
- # the gem isn't installed locally - write out our current specs
- write_specification(specification)
- puts "Gem #{name} not loaded locally - writing out current spec."
- end
- else
- if framework_gem?
- puts "Gem directory for #{name} not found - check if it's loading before rails."
- else
- puts "Something bad is going on - gem directory not found for #{name}."
- end
- end
- end
-
- def unpack(options={})
- unless frozen? || framework_gem?
- FileUtils.mkdir_p unpack_base
- Dir.chdir unpack_base do
- Gem::GemRunner.new.run(unpack_command)
- end
- # Gem.activate changes the spec - get the original
- real_spec = Gem::Specification.load(specification.loaded_from)
- write_specification(real_spec)
- end
- dependencies.each { |dep| dep.unpack(options) } if options[:recursive]
- end
-
- def write_specification(spec)
- # copy the gem's specification into GEMDIR/.specification so that
- # we can access information about the gem on deployment systems
- # without having the gem installed
- File.open(unpacked_specification_filename, 'w') do |file|
- file.puts spec.to_yaml
- end
- end
-
- def ==(other)
- self.name == other.name && self.requirement == other.requirement
- end
- alias_method :"eql?", :"=="
-
- private
-
- def gem_command
- case RUBY_PLATFORM
- when /win32/
- 'gem.bat'
- when /java/
- 'jruby -S gem'
- else
- 'gem'
- end
- end
-
- def install_command
- cmd = %w(install) << name
- cmd << "--version" << %("#{requirement.to_s}") if requirement
- cmd << "--source" << @source if @source
- cmd
- end
-
- def unpack_command
- cmd = %w(unpack) << name
- cmd << "--version" << "= "+specification.version.to_s if requirement
- cmd
- end
-
- def unpack_base
- Rails::GemDependency.unpacked_path
- end
-
- def unpacked_gem_directory
- File.join(unpack_base, specification.full_name)
- end
-
- def unpacked_specification_filename
- File.join(unpacked_gem_directory, '.specification')
- end
-
- end
-end
View
2 railties/lib/rails/generators.rb
@@ -92,8 +92,6 @@ def self.gems_generators_paths
generator_path = File.join(spec.full_gem_path, "lib/generators")
paths << generator_path if File.exist?(generator_path)
end
- elsif defined?(Rails.root)
- paths += Dir[File.join(Rails.root, "vendor", "gems", "gems", "*", "lib", "generators")]
end
paths
View
4 railties/lib/rails/generators/rails/app/app_generator.rb
@@ -75,10 +75,6 @@ def create_config_files
end
end
- def create_boot_file
- copy_file "config/boot.rb"
- end
-
def create_activerecord_files
return if options[:skip_activerecord]
template "config/databases/#{options[:database]}.yml", "config/database.yml"
View
17 railties/lib/rails/generators/rails/app/templates/Gemfile
@@ -5,6 +5,17 @@ gem "rails", "<%= Rails::VERSION::STRING %>"
# Bundling edge rails:
# gem "rails", "<%= Rails::VERSION::STRING %>", :git => "git://github.com/rails/rails.git"
-# You can list more dependencies here
-# gem "nokogiri"
-# gem "merb" # ;)
+# Specify gemcutter as a gem source
+# source "http://gemcutter.org"
+
+# Specify gems that this application depends on and have them installed with rake gems:install
+# gem "bj"
+# gem "hpricot", "0.6"
+# gem "sqlite3-ruby", :require_as => "sqlite3"
+# gem "aws-s3", :require_as => "aws/s3"
+
+# Specify gems that should only be required in certain environments
+# gem "rspec", :only => :test
+# only :test do
+# gem "webrat"
+# end
View
11 railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -1,5 +1,12 @@
-# Bootstrap the Rails environment, frameworks, and default configuration
-require File.expand_path(File.join(File.dirname(__FILE__), 'boot'))
+begin
+ # Use Bundler
+ require File.expand_path("../../vendor/gems/environment", __FILE__)
+rescue LoadError
+ # Use Rubygems
+ require 'rubygems'
+end
+
+require 'rails'
Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those specified here.
View
138 railties/lib/rails/generators/rails/app/templates/config/boot.rb
@@ -1,138 +0,0 @@
-# Don't change this file!
-# Configure your app in config/environment.rb and config/environments/*.rb
-
-module Rails
- # Mark the version of Rails that generated the boot.rb file. This is
- # a temporary solution and will most likely be removed as Rails 3.0
- # comes closer.
- BOOTSTRAP_VERSION = "3.0"
-
- class << self
- def boot!
- unless booted?
- root = File.expand_path('../..', __FILE__)
- booter = File.exist?("#{root}/vendor/rails") ? VendorBoot : GemBoot
- booter.new(root).run
- end
- end
-
- def booted?
- defined? Rails::Initializer
- end
- end
-
- class Boot
- def initialize(root)
- @root = root
- end
-
- def run
- preinitialize
- set_load_paths
- load_initializer
- end
-
- def preinitialize
- path = "#{@root}/config/preinitializer.rb"
- load(path) if File.exist?(path)
- end
-
- def set_load_paths
- %w(
- actionmailer/lib
- actionpack/lib
- activemodel/lib
- activerecord/lib
- activeresource/lib
- activesupport/lib
- railties/lib
- railties
- ).reverse_each do |path|
- path = "#{framework_root_path}/#{path}"
- $LOAD_PATH.unshift(path) if File.directory?(path)
- $LOAD_PATH.uniq!
- end
- end
-
- def framework_root_path
- defined?(::RAILS_FRAMEWORK_ROOT) ? ::RAILS_FRAMEWORK_ROOT : "#{@root}/vendor/rails"
- end
- end
-
- class VendorBoot < Boot
- def load_initializer
- require "rails"
- install_gem_spec_stubs
- end
-
- def install_gem_spec_stubs
- begin; require "rubygems"; rescue LoadError; return; end
-
- %w(rails activesupport activerecord actionpack actionmailer activeresource).each do |stub|
- Gem.loaded_specs[stub] ||= Gem::Specification.new do |s|
- s.name = stub
- s.version = Rails::VERSION::STRING
- s.loaded_from = ""
- end
- end
- end
- end
-
- class GemBoot < Boot
- def load_initializer
- load_rubygems
- load_rails_gem
- require 'rails'
- end
-
- def load_rails_gem
- if version = 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
-
- 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("#{@root}/config/environment.rb")
- end
- end
-end
-
-# All that for this:
-Rails.boot!
View
1 railties/lib/rails/initializer.rb
@@ -4,7 +4,6 @@
require 'rails/application'
require 'rails/railties_path'
require 'rails/version'
-require 'rails/gem_dependency'
require 'rails/rack'
require 'rails/paths'
require 'rails/core'
View
1 railties/lib/rails/tasks.rb
@@ -6,7 +6,6 @@
databases
documentation
framework
- gems
log
middleware
misc
View
5 railties/lib/rails/tasks/framework.rake
@@ -100,11 +100,6 @@ namespace :rails do
generator.invoke(method)
end
- desc "Update config/boot.rb from your current rails install"
- task :configs do
- invoke_from_app_generator :create_boot_file
- end
-
desc "Update Prototype javascripts from your current rails install"
task :javascripts do
invoke_from_app_generator :create_prototype_files
View
78 railties/lib/rails/tasks/gems.rake
@@ -1,78 +0,0 @@
-desc "List the gems that this rails application depends on"
-task :gems => 'gems:base' do
- Rails.configuration.gems.each do |gem|
- print_gem_status(gem)
- end
- puts
- puts "I = Installed"
- puts "F = Frozen"
- puts "R = Framework (loaded before rails starts)"
-end
-
-namespace :gems do
- task :base do
- $gems_rake_task = true
- require 'rubygems'
- require 'rubygems/gem_runner'
- Rake::Task[:environment].invoke
- end
-
- desc "Build any native extensions for unpacked gems"
- task :build do
- $gems_build_rake_task = true
- frozen_gems.each { |gem| gem.build }
- end
-
- namespace :build do
- desc "Force the build of all gems"
- task :force do
- $gems_build_rake_task = true
- frozen_gems.each { |gem| gem.build(:force => true) }
- end
- end
-
- desc "Installs all required gems."
- task :install => :base do
- current_gems.each { |gem| gem.install }
- end
-
- desc "Unpacks all required gems into vendor/gems."
- task :unpack => :install do
- current_gems.each { |gem| gem.unpack }
- end
-
- namespace :unpack do
- desc "Unpacks all required gems and their dependencies into vendor/gems."
- task :dependencies => :install do
- current_gems.each { |gem| gem.unpack(:recursive => true) }
- end
- end
-
- desc "Regenerate gem specifications in correct format."
- task :refresh_specs do
- frozen_gems(false).each { |gem| gem.refresh }
- end
-end
-
-def current_gems
- gems = Rails.configuration.gems
- gems = gems.select { |gem| gem.name == ENV['GEM'] } unless ENV['GEM'].blank?
- gems
-end
-
-def frozen_gems(load_specs=true)
- Dir[File.join(Rails.root, 'vendor', 'gems', '*-*')].map do |gem_dir|
- Rails::GemDependency.from_directory_name(gem_dir, load_specs)
- end
-end
-
-def print_gem_status(gem, indent=1)
- code = case
- when gem.framework_gem? then 'R'
- when gem.frozen? then 'F'
- when gem.installed? then 'I'
- else ' '
- end
- puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}"
- gem.dependencies.each { |g| print_gem_status(g, indent+1) }
-end
View
140 railties/lib/rails/vendor_gem_source_index.rb
@@ -1,140 +0,0 @@
-require 'rubygems'
-require 'yaml'
-
-module Rails
-
- class VendorGemSourceIndex
- # VendorGemSourceIndex acts as a proxy for the Gem source index, allowing
- # gems to be loaded from vendor/gems. Rather than the standard gem repository format,
- # vendor/gems contains unpacked gems, with YAML specifications in .specification in
- # each gem directory.
- include Enumerable
-
- attr_reader :installed_source_index
- attr_reader :vendor_source_index
-
- @@silence_spec_warnings = false
-
- def self.silence_spec_warnings
- @@silence_spec_warnings
- end
-
- def self.silence_spec_warnings=(v)
- @@silence_spec_warnings = v
- end
-
- def initialize(installed_index, vendor_dir=Rails::GemDependency.unpacked_path)
- @installed_source_index = installed_index
- @vendor_dir = vendor_dir
- refresh!
- end
-
- def refresh!
- # reload the installed gems
- @installed_source_index.refresh!
- vendor_gems = {}
-
- # handle vendor Rails gems - they are identified by having loaded_from set to ""
- # we add them manually to the list, so that other gems can find them via dependencies
- Gem.loaded_specs.each do |n, s|
- next unless s.loaded_from.empty?
- vendor_gems[s.full_name] = s
- end
-
- # load specifications from vendor/gems
- Dir[File.join(Rails::GemDependency.unpacked_path, '*')].each do |d|
- dir_name = File.basename(d)
- dir_version = version_for_dir(dir_name)
- spec = load_specification(d)
- if spec
- if spec.full_name != dir_name
- # mismatched directory name and gem spec - produced by 2.1.0-era unpack code
- if dir_version
- # fix the spec version - this is not optimal (spec.files may be wrong)
- # but it's better than breaking apps. Complain to remind users to get correct specs.
- # use ActiveSupport::Deprecation.warn, as the logger is not set yet
- $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems has a mismatched specification file."+
- " Run 'rake gems:refresh_specs' to fix this.") unless @@silence_spec_warnings
- spec.version = dir_version
- else
- $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems is not in a versioned directory"+
- "(should be #{spec.full_name}).") unless @@silence_spec_warnings
- # continue, assume everything is OK
- end
- end
- else
- # no spec - produced by early-2008 unpack code
- # emulate old behavior, and complain.
- $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems has no specification file."+
- " Run 'rake gems:refresh_specs' to fix this.") unless @@silence_spec_warnings
- if dir_version
- spec = Gem::Specification.new
- spec.version = dir_version
- spec.require_paths = ['lib']
- ext_path = File.join(d, 'ext')
- spec.require_paths << 'ext' if File.exist?(ext_path)
- spec.name = /^(.*)-[^-]+$/.match(dir_name)[1]
- files = ['lib']
- # set files to everything in lib/
- files += Dir[File.join(d, 'lib', '*')].map { |v| v.gsub(/^#{d}\//, '') }
- files += Dir[File.join(d, 'ext', '*')].map { |v| v.gsub(/^#{d}\//, '') } if ext_path
- spec.files = files
- else
- $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems not in a versioned directory."+
- " Giving up.") unless @@silence_spec_warnings
- next
- end
- end
- spec.loaded_from = File.join(d, '.specification')
- # finally, swap out full_gem_path
- # it would be better to use a Gem::Specification subclass, but the YAML loads an explicit class
- class << spec
- def full_gem_path
- path = File.join installation_path, full_name
- return path if File.directory? path
- File.join installation_path, original_name
- end
- end
- vendor_gems[File.basename(d)] = spec
- end
- @vendor_source_index = Gem::SourceIndex.new(vendor_gems)
- end
-
- def version_for_dir(d)
- matches = /-([^-]+)$/.match(d)
- Gem::Version.new(matches[1]) if matches
- end
-
- def load_specification(gem_dir)
- spec_file = File.join(gem_dir, '.specification')
- YAML.load_file(spec_file) if File.exist?(spec_file)
- end
-
- def find_name(*args)
- @installed_source_index.find_name(*args) + @vendor_source_index.find_name(*args)
- end
-
- def search(*args)
- # look for vendor gems, and then installed gems - later elements take priority
- @installed_source_index.search(*args) + @vendor_source_index.search(*args)
- end
-
- def each(&block)
- @vendor_source_index.each(&block)
- @installed_source_index.each(&block)
- end
-
- def add_spec(spec)
- @vendor_source_index.add_spec spec
- end
-
- def remove_spec(spec)
- @vendor_source_index.remove_spec spec
- end
-
- def size
- @vendor_source_index.size + @installed_source_index.size
- end
-
- end
-end
View
1 railties/test/application/configuration_test.rb
@@ -7,7 +7,6 @@ class InitializerTest < Test::Unit::TestCase
def setup
build_app
boot_rails
- Object.send(:remove_const, :RAILS_ROOT)
end
test "the application root is set correctly" do
View
1 railties/test/application/generators_test.rb
@@ -7,6 +7,7 @@ class GeneratorsTest < Test::Unit::TestCase
def setup
build_app
boot_rails
+ require "rails"
require "rails/generators"
end
View
1 railties/test/application/initializer_test.rb
@@ -7,6 +7,7 @@ class InitializerTest < Test::Unit::TestCase
def setup
build_app
boot_rails
+ require "rails"
end
test "initializing an application initializes rails" do
View
2 railties/test/application/notifications_test.rb
@@ -24,7 +24,7 @@ def subscribe(pattern=nil, &block)
def setup
build_app
boot_rails
-
+ require "rails"
require "active_support/notifications"
Rails::Initializer.run do |c|
c.notifications.queue = MyQueue.new
View
1 railties/test/application/plugins_test.rb
@@ -11,6 +11,7 @@ def assert_plugins(list_of_names, array_of_plugins, message=nil)
def setup
build_app
boot_rails
+ require "rails"
@failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
# Tmp hax to get tests working
FileUtils.cp_r "#{File.dirname(__FILE__)}/../fixtures/plugins", "#{app_path}/vendor"
View
6 railties/test/backtrace_cleaner_test.rb
@@ -50,10 +50,4 @@ def setup
end
end
- test "should format vendor gems correctly" do
- @backtrace = [ "#{Rails::GemDependency.unpacked_path}/nosuchgem-1.2.3/lib/foo.rb" ]
- @result = @cleaner.clean(@backtrace)
- assert_equal "nosuchgem (1.2.3) [v] lib/foo.rb", @result[0]
- end
-
end
View
3 railties/test/generators_test.rb
@@ -101,10 +101,11 @@ def test_rails_generators_help_with_builtin_information
def test_rails_generators_with_others_information
output = capture(:stdout){ Rails::Generators.help }.split("\n").last
- assert_equal "Others: active_record:fixjour, fixjour, mspec, rails:javascripts, wrong.", output
+ assert_equal "Others: active_record:fixjour, fixjour, mspec, rails:javascripts.", output
end
def test_warning_is_shown_if_generator_cant_be_loaded
+ Rails::Generators.load_paths << File.expand_path("../fixtures/vendor/gems/gems/wrong", __FILE__)
output = capture(:stderr){ Rails::Generators.find_by_namespace(:wrong) }
assert_match /\[WARNING\] Could not load generator at/, output
assert_match /Error: uninitialized constant Rails::Generator/, output
View
1 railties/test/initializer/check_ruby_version_test.rb
@@ -7,6 +7,7 @@ class PathsTest < Test::Unit::TestCase
def setup
build_app
boot_rails
+ require "rails"
end
test "rails does not initialize with ruby version 1.8.1" do
View
1 railties/test/initializer/initialize_i18n_test.rb
@@ -7,6 +7,7 @@ class InitializeI18nTest < Test::Unit::TestCase
def setup
build_app
boot_rails
+ require "rails"
end
# test_config_defaults_and_settings_should_be_added_to_i18n_defaults
View
1 railties/test/initializer/path_test.rb
@@ -6,6 +6,7 @@ class PathsTest < Test::Unit::TestCase
def setup
build_app
boot_rails
+ require "rails"
Rails::Initializer.run do |config|
config.root = app_path
config.frameworks = [:action_controller, :action_view, :action_mailer, :active_record]
View
23 railties/test/isolation/abstract_unit.rb
@@ -114,16 +114,19 @@ def controller(name, contents)
end
def boot_rails
- # TMP mega hax to prevent boot.rb from actually booting
- Object.class_eval <<-RUBY, __FILE__, __LINE__+1
- module Rails
- Initializer = 'lol'
- require "#{app_path}/config/boot"
- remove_const(:Initializer)
- booter = VendorBoot.new('#{app_path}')
- booter.run
- end
- RUBY
+ %w(
+ actionmailer/lib
+ actionpack/lib
+ activemodel/lib
+ activerecord/lib
+ activeresource/lib
+ activesupport/lib
+ railties/lib
+ railties
+ ).reverse_each do |path|
+ path = File.expand_path("../../../../#{path}", __FILE__)
+ $:.unshift(path)
+ end
end
end
end

9 comments on commit e1fdc8b

@masterkain

interesting. I suspect that it's better to remove also the config.gem comments in railties/lib/rails/generators/rails/app/templates/config/application.rb

@mislav
Ruby on Rails member
mislav commented on e1fdc8b Oct 17, 2009

Wohoo!

@dpickett

nice work!

@dstrelau

We currently use the config.gem system to manage gems dependencies, but just install everything to the machine (rake gems:install); we don't vendor/bundle them. Is this possible with the new system?

@qrush
qrush commented on e1fdc8b Oct 17, 2009

viva la bundler!

@hashrocket

Here is the error you get when you try running without bundler installed:

uninitialized constant Rails::GemDependency
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2503:in const_missing'
/Users/obie/hashrocket/test/vendor/rails/railties/lib/rails/configuration.rb:245:in
gem'

@mutle
mutle commented on e1fdc8b Oct 18, 2009

How can I install the current Rails master (it's in vendor/rails right now) as a gem through bundler? It seems that right now vendor/rails is not in the load path:

/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require': no such file to load -- rails (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
require'
from ./config/environment.rb:9

@carllerche

@hashrocket: config.gem should not be used. I removed more stray bits in a later commit.

@carllerche

@mutle: I believe that josh added this back, but generate a new app and look at Gemfile in the root. Install the bundler gem and do gem bundle after modifying your Gemfile to pull from master.

Please sign in to comment.
Something went wrong with that request. Please try again.