Skip to content

Commit

Permalink
Misc. fixes to Gem activation
Browse files Browse the repository at this point in the history
  • Loading branch information
fabien committed Oct 20, 2008
1 parent 5a30de8 commit 2d81a25
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
19 changes: 10 additions & 9 deletions lib/minigems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions spec/minigems_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2d81a25

Please sign in to comment.