diff options
author | David Dollar <ddollar@gmail.com> | 2009-04-29 01:22:54 -0400 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-04-28 23:16:47 -0700 |
commit | 599f2cfb4a0e0ec4135265bf5c56b83f1450beea (patch) | |
tree | 6fc10537aff67cb2b38f431e027a5ddc02fefef2 /railties/lib/rails/gem_dependency.rb | |
parent | acd5db300b755d5abae2748f239441fb865c6b62 (diff) | |
download | rails-599f2cfb4a0e0ec4135265bf5c56b83f1450beea.tar.gz rails-599f2cfb4a0e0ec4135265bf5c56b83f1450beea.tar.bz2 rails-599f2cfb4a0e0ec4135265bf5c56b83f1450beea.zip |
Attempt to deal with more cases of gems with native components.
This commit adds a rudimentary check for 'unbuilt' gems, so that we can abort
the application load if there are any gems that have native components that
have not yet been built.
The rake task gems:build has now only builds 'unbuilt' gems as a result.
The rake task gems:build:force has been added to deal with cases of incomplete
builds, or any case where you need to force the build of all of your gems.
Changes the gems:build task to get its gem list by parsing directory entries
in vendor/gems, which sidesteps the chicken/egg issues involved with having a
gem unpacked into vendor/gems without before its native bits are compiled.
[#2266 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'railties/lib/rails/gem_dependency.rb')
-rw-r--r-- | railties/lib/rails/gem_dependency.rb | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb index 3062a77104..ee3d0d81ba 100644 --- a/railties/lib/rails/gem_dependency.rb +++ b/railties/lib/rails/gem_dependency.rb @@ -29,6 +29,15 @@ module Rails end end + def self.from_directory_name(directory_name) + directory_name_parts = File.basename(directory_name).split('-') + name = directory_name_parts[0..-2].join('-') + version = directory_name_parts.last + self.new(name, :version => version) + 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) @@ -101,8 +110,12 @@ module Rails end def built? - # TODO: If Rubygems ever gives us a way to detect this, we should use it - false + return false unless frozen? + specification.extensions.each do |ext| + makefile = File.join(unpacked_gem_directory, File.dirname(ext), 'Makefile') + return false unless File.exists?(makefile) + end + true end def framework_gem? @@ -155,9 +168,9 @@ module Rails specification && File.exists?(unpacked_gem_directory) end - def build + def build(options={}) require 'rails/gem_builder' - unless built? + 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 |