Permalink
Browse files

Misc. fixes to Gem activation

  • Loading branch information...
1 parent 5a30de8 commit 2d81a25e2a42ee6519c9c4f4c6eb6a1683245c42 @fabien committed Oct 20, 2008
Showing with 19 additions and 16 deletions.
  1. +2 −0 CHANGELOG
  2. +1 −1 Rakefile
  3. +10 −9 lib/minigems.rb
  4. +6 −6 spec/minigems_spec.rb
View
@@ -1,3 +1,5 @@
+0.9.8 - 10/20/2008:
+* Misc. fixes to Gem activation.
0.9.7 - 10/13/2008:
* MiniGems is now compatible with dynamically created code from RubyInline.
0.9.6 - 10/13/2008:
View
@@ -15,7 +15,7 @@ GEM_EMAIL = "info@atelierfabien.be"
GEM_NAME = "minigems"
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
-GEM_VERSION = (Gem::MiniGems::VERSION || "0.9.7") + PKG_BUILD
+GEM_VERSION = (Gem::MiniGems::VERSION || "0.9.8") + PKG_BUILD
RELEASE_NAME = "REL #{GEM_VERSION}"
View
@@ -2,7 +2,7 @@ module Gem
unless const_defined?(:MiniGems)
module MiniGems
- VERSION = "0.9.7"
+ VERSION = "0.9.8"
# The next line needs to be kept exactly as shown; it's being replaced
# during minigems installation.
@@ -64,8 +64,7 @@ def require(path) # :nodoc:
elsif path == 'Win32API' && !Gem.win_platform?
raise load_error
elsif load_error.message =~ /#{Regexp.escape path}\z/
- if !path.include?('/') && (match = Gem.find_name(path))
- Gem.activate_gem_from_path(match.first)
+ if !path.include?('/') && Gem.activate(path)
return gem_original_require(path)
elsif $MINIGEMS_SKIPPABLE.include?(path)
raise load_error
@@ -123,7 +122,7 @@ def self.activate(gem, *version_requirements)
if match = find_name(gem, *version_requirements)
activate_gem_from_path(match.first)
elsif gem.is_a?(String) &&
- match = find_name(MiniGems.camel_case(gem), *version_requirements)
+ (match = find_name(MiniGems.camel_case(gem), *version_requirements))
activate_gem_from_path(match.first)
else
unless gem.respond_to?(:name) && gem.respond_to?(:version_requirements)
@@ -283,16 +282,18 @@ def self.find_in_source_index(path)
# Find the best (highest) matching gem version.
def self.find_name(gem, *version_requirements)
version_requirements = Gem::Requirement.default if version_requirements.empty?
- unless gem.respond_to?(:name) && gem.respond_to?(:version_requirements)
- gem = Gem::Dependency.new(gem, version_requirements)
+ if gem.respond_to?(:name) && gem.respond_to?(:version_requirements)
+ dependency = gem
+ else
+ dependency = Gem::Dependency.new(gem.to_s, version_requirements)
end
-
- gemspec_sets = self.path.map { |path| [path, Dir["#{path}/specifications/#{gem.name}-*.gemspec"]] }
+
+ gemspec_sets = self.path.map { |path| [path, Dir["#{path}/specifications/#{dependency.name}-*.gemspec"]] }
versions = gemspec_sets.inject([]) do |versions, (root_path, gems)|
unless gems.empty?
gems.each do |gemspec_path|
if (version_no = gemspec_path[/-([\d\.]+)\.gemspec$/, 1]) &&
- gem.version_requirements.satisfied_by?(version = Gem::Version.new(version_no))
+ dependency.version_requirements.satisfied_by?(version = Gem::Version.new(version_no))
versions << [gemspec_path, version]
end
end
View
@@ -94,12 +94,12 @@
AwesomeGem::VERSION.should == "0.0.2"
end
- # it "for gems with a CamelCased package name" do
- # require("camel_cased_gem").should be_true
- # lambda { CamelCasedGem::Awesome }.should_not raise_error(NameError)
- # CamelCasedGem::VERSION.should == "0.0.1"
- # end
- #
+ it "for gems with a CamelCased package name" do
+ require("camel_cased_gem").should be_true
+ lambda { CamelCasedGem::Awesome }.should_not raise_error(NameError)
+ CamelCasedGem::VERSION.should == "0.0.1"
+ end
+
# it "for files in a gems' load path" do
# require("super_sonic").should be_true
# lambda { AwesomeGem::SuperSonic }.should_not raise_error(NameError)

0 comments on commit 2d81a25

Please sign in to comment.