rubygems-update 0.8.6 → 0.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data/ChangeLog +134 -0
- data/Rakefile +41 -17
- data/bin/gemwhich +61 -0
- data/examples/application/an-app.gemspec +1 -0
- data/lib/gemconfigure.rb +18 -0
- data/lib/rubygems.rb +65 -47
- data/lib/rubygems/cmd_manager.rb +3 -1
- data/lib/rubygems/command.rb +4 -0
- data/lib/rubygems/config_file.rb +2 -6
- data/lib/rubygems/custom_require.rb +2 -2
- data/lib/rubygems/dependency_list.rb +131 -0
- data/lib/rubygems/deployment.rb +265 -0
- data/lib/rubygems/doc_manager.rb +1 -0
- data/lib/rubygems/gem_commands.rb +216 -15
- data/lib/rubygems/installer.rb +111 -286
- data/lib/rubygems/remote_installer.rb +16 -6
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/source_index.rb +11 -5
- data/lib/rubygems/specification.rb +5 -0
- data/lib/rubygems/version.rb +146 -129
- data/test/test_configfile.rb +1 -1
- data/test/test_dependency_list.rb +163 -0
- data/test/test_deployment.rb +93 -0
- data/test/test_remote_fetcher.rb +38 -36
- metadata +23 -47
- data/test/data/a-0.0.1.gem +0 -0
- data/test/data/a-0.0.2.gem +0 -0
- data/test/data/b-0.0.2.gem +0 -0
- data/test/data/c-1.2.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/c-1.2.gem +0 -0
- data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
- data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
- data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
- data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
- data/test/data/one/one-0.0.1.gem +0 -0
data/ChangeLog
CHANGED
@@ -1,3 +1,137 @@
|
|
1
|
+
2005-03-13 Gavin Sinclair <gsinclair@soyabean.com.au>
|
2
|
+
|
3
|
+
* lib/rubygems/installer.rb: Removed all code relating to library
|
4
|
+
stubs as we haven't generated them for ages.
|
5
|
+
|
6
|
+
2005-03-13 Gavin Sinclair <gsinclair@soyabean.com.au>
|
7
|
+
|
8
|
+
* lib/rubygems/installer.rb (Gem::Installer#shebang): Refactored and
|
9
|
+
stripped result to avoid ^M issues.
|
10
|
+
|
11
|
+
2005-03-11 Jim Weirich <jim@weirichhouse.org>
|
12
|
+
|
13
|
+
* lib/rubygems/gem_commands.rb (Gem::DependencyCommand): Added a
|
14
|
+
new command "gem dependency" to show the dependencies of an
|
15
|
+
installed gem.
|
16
|
+
|
17
|
+
* lib/rubygems/cmd_manager.rb (Gem::CommandManager::initialize):
|
18
|
+
Added DependencyCommand to the command manager registrar.
|
19
|
+
|
20
|
+
* lib/rubygems/version.rb (Gem::Requirement): Unnested Requirement
|
21
|
+
from the Version class. There was no benefit to having it nested.
|
22
|
+
Gem::Version::Requirement is set to point to the new class so to
|
23
|
+
be compatible with old gems.
|
24
|
+
|
25
|
+
* lib/rubygems/installer.rb (Gem::Uninstaller::ask_if_ok): Changed
|
26
|
+
uninstaller confirm message to read 'Continue with uninstall'.
|
27
|
+
Its clearer that way.
|
28
|
+
|
29
|
+
* lib/rubygems.rb (Gem::Exception::required_location): Switch to
|
30
|
+
use SourceIndex#find_name rather than search. Made sure a nil
|
31
|
+
value is returned with a path is not found.
|
32
|
+
|
33
|
+
* lib/rubygems/source_index.rb (Gem::SourceIndex::search): Changed
|
34
|
+
parameter name to gem_pattern to emphasize using Regex in search.
|
35
|
+
(Gem::SourceIndex::find_name): Added find_name to handle the
|
36
|
+
common case of searching for an exact match on the short name.
|
37
|
+
|
38
|
+
* lib/rubygems.rb (Gem::Exception::activate): Make sure that
|
39
|
+
activate more closely adheres to honoring the auto_require=>false
|
40
|
+
request.
|
41
|
+
(Gem::Exception::report_activate_error): Out of line error
|
42
|
+
reporting for activate.
|
43
|
+
|
44
|
+
* lib/rubygems/remote_installer.rb
|
45
|
+
(Gem::RemoteInstaller::find_dependencies_not_installed): Found
|
46
|
+
another location that was using require_gem with auto_require.
|
47
|
+
Fixed to use :auto_require=>false.
|
48
|
+
|
49
|
+
* lib/rubygems/gem_commands.rb
|
50
|
+
(Gem::InstallUpdateOptions::add_install_update_options): Added
|
51
|
+
--ignore-dependencies option. Still needs to be wired to logic.
|
52
|
+
|
53
|
+
* lib/rubygems/installer.rb (Gem::Installer::install): Added call
|
54
|
+
to require_gem_with_options.
|
55
|
+
|
56
|
+
* lib/rubygems.rb (Kernel::require_gem_with_options): Added to
|
57
|
+
allow easier specification of the autorequire flag for
|
58
|
+
Gem.activate.
|
59
|
+
|
60
|
+
2005-03-10 Jim Weirich <jim@weirichhouse.org>
|
61
|
+
|
62
|
+
* lib/rubygems/remote_installer.rb
|
63
|
+
(Gem::RemoteSourceFetcher::normalize_uri): Normialize a URI to
|
64
|
+
start with http:// if it does not already.
|
65
|
+
|
66
|
+
* test/test_deployment.rb (TestDeployment::xtest_deploy_sources):
|
67
|
+
Disabled this test. It is part of the new deployment software and
|
68
|
+
is not working yet.
|
69
|
+
|
70
|
+
2005-03-09 Jim Weirich <jim@weirichhouse.org>
|
71
|
+
|
72
|
+
* lib/gemconfigure.rb (Gem::self): Added to aid dynamic
|
73
|
+
versioning.
|
74
|
+
|
75
|
+
* lib/rubygems/command.rb (Gem::Command::command_manager): Moved
|
76
|
+
command_manager to base class.
|
77
|
+
|
78
|
+
* lib/rubygems/gem_commands.rb (Gem::CleanupCommand::execute):
|
79
|
+
Both implicit and explicit gems now work with cleanup.
|
80
|
+
|
81
|
+
2005-03-08 Jim Weirich <jim@weirichhouse.org>
|
82
|
+
|
83
|
+
* lib/rubygems/installer.rb (Gem::Uninstaller::ok_to_remove):
|
84
|
+
Fixed source index to be loaded from the installed gems when doing
|
85
|
+
an "OK TO REMOVE" dependency check.
|
86
|
+
|
87
|
+
2005-03-06 Rich Kilmer <rich@infoether.com>
|
88
|
+
* lib/rubygems/deployment.rb: beginning of a deployment capability
|
89
|
+
|
90
|
+
* test/test_deployment.rb: first tests of new deployment system
|
91
|
+
|
92
|
+
2005-03-04 Chad Fowler <chad@chadfowler.com>
|
93
|
+
* lib/rubygems/gem_commands.rb: Small bugfix for the case when you
|
94
|
+
pass in a gem name (or more) to cleanup for the cleanup command.
|
95
|
+
|
96
|
+
2005-03-04 Jim Weirich <jim@weirichhouse.org>
|
97
|
+
|
98
|
+
* lib/rubygems/installer.rb (Gem::Uninstaller::ok_to_remove):
|
99
|
+
Reworked logic in uninstall to be intelligent about dependencies.
|
100
|
+
We only complain about dependencies if removing a gem will cause a
|
101
|
+
dependency error. The uninstaller now checks for :ignore, :all
|
102
|
+
and :executables options.
|
103
|
+
|
104
|
+
* lib/rubygems/cmd_manager.rb (Gem::CommandManager::initialize):
|
105
|
+
Registered Cleanup command.
|
106
|
+
|
107
|
+
* lib/rubygems/gem_commands.rb (Gem::CleanupCommand): Added
|
108
|
+
Cleanup command to gem.
|
109
|
+
(Gem::UninstallCommand::initialize): Added --all, --ignore and
|
110
|
+
--executables options to uninstall. This helps to avoid excessive
|
111
|
+
YESes all the time.
|
112
|
+
|
113
|
+
2005-02-28 Jim Weirich <jim@weirichhouse.org>
|
114
|
+
|
115
|
+
* lib/rubygems/remote_installer.rb
|
116
|
+
(Gem::LocalSourceInfoCache::write_cache): Open cache file in
|
117
|
+
binary mode.
|
118
|
+
|
119
|
+
2005-02-28 Chad Fowler <chad@chadfowler.com>
|
120
|
+
* lib/rubygems/config_file.rb: don't warn about not being able to
|
121
|
+
find config file.
|
122
|
+
* lib/rubygems/doc_manager.rb: (for DHH) don't install rdoc docs for
|
123
|
+
* lib/rubygems/gem_commands.rb: Print which gems are updated on 'gem
|
124
|
+
update'. If --system is used, report that the rubygems system
|
125
|
+
software has been updated.
|
126
|
+
* lib/rubygems/installer.rb: Cleaned up the uninstall has_dependents
|
127
|
+
logic and output. It was misleading and buggy before.
|
128
|
+
|
129
|
+
2005-02-27 Jim Weirich <jim@weirichhouse.org>
|
130
|
+
|
131
|
+
* lib/rubygems/config_file.rb
|
132
|
+
(Gem::ConfigFile::default_config_file_name): Fixed bug in finding
|
133
|
+
home directory for the .gemrc file.
|
134
|
+
|
1
135
|
2005-02-27 Chad Fowler <chad@chadfowler.com>
|
2
136
|
|
3
137
|
* Released 0.8.6
|
data/Rakefile
CHANGED
@@ -7,8 +7,22 @@ require 'rake/packagetask'
|
|
7
7
|
require 'rake/gempackagetask'
|
8
8
|
require 'rake/rdoctask'
|
9
9
|
|
10
|
+
def announce(msg='')
|
11
|
+
STDERR.puts msg
|
12
|
+
end
|
13
|
+
|
10
14
|
PKG_NAME = 'rubygems'
|
11
|
-
|
15
|
+
def package_version
|
16
|
+
`ruby -Ilib bin/gem environment packageversion`.chomp
|
17
|
+
end
|
18
|
+
|
19
|
+
if ENV['REL']
|
20
|
+
PKG_VERSION = ENV['REL']
|
21
|
+
CURRENT_VERSION = package_version
|
22
|
+
else
|
23
|
+
PKG_VERSION = package_version
|
24
|
+
CURRENT_VERSION = PKG_VERSION
|
25
|
+
end
|
12
26
|
|
13
27
|
CLEAN.include("COMMENTS")
|
14
28
|
CLOBBER.include(
|
@@ -68,10 +82,6 @@ end
|
|
68
82
|
# --------------------------------------------------------------------
|
69
83
|
# Creating a release
|
70
84
|
|
71
|
-
def announce(msg='')
|
72
|
-
STDERR.puts msg
|
73
|
-
end
|
74
|
-
|
75
85
|
desc "Make a new release"
|
76
86
|
task :release => [
|
77
87
|
:prerelease,
|
@@ -83,7 +93,7 @@ task :release => [
|
|
83
93
|
|
84
94
|
announce
|
85
95
|
announce "**************************************************************"
|
86
|
-
announce "* Release #{
|
96
|
+
announce "* Release #{PKG_VERSION} Complete."
|
87
97
|
announce "* Packages ready to upload."
|
88
98
|
announce "**************************************************************"
|
89
99
|
announce
|
@@ -93,8 +103,8 @@ end
|
|
93
103
|
task :prerelease do
|
94
104
|
announce
|
95
105
|
announce "**************************************************************"
|
96
|
-
announce "* Making RubyGem Release #{
|
97
|
-
announce "* (current version #{
|
106
|
+
announce "* Making RubyGem Release #{PKG_VERSION}"
|
107
|
+
announce "* (current version #{CURRENT_VERSION})"
|
98
108
|
announce "**************************************************************"
|
99
109
|
announce
|
100
110
|
|
@@ -105,7 +115,7 @@ task :prerelease do
|
|
105
115
|
|
106
116
|
# Is the release different than the current release.
|
107
117
|
# (or is REUSE set?)
|
108
|
-
if PKG_VERSION ==
|
118
|
+
if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE']
|
109
119
|
fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version"
|
110
120
|
end
|
111
121
|
|
@@ -123,27 +133,35 @@ task :prerelease do
|
|
123
133
|
end
|
124
134
|
|
125
135
|
task :update_version => [:prerelease] do
|
126
|
-
if PKG_VERSION ==
|
136
|
+
if PKG_VERSION == CURRENT_VERSION
|
127
137
|
announce "No version change ... skipping version update"
|
128
138
|
else
|
129
|
-
announce "Updating RubyGem version to #{
|
139
|
+
announce "Updating RubyGem version to #{PKG_VERSION}"
|
130
140
|
open("lib/rubygems/rubygems_version.rb", "w") do |f|
|
131
141
|
f.puts "# DO NOT EDIT"
|
132
142
|
f.puts "# This file is auto-generated by build scripts."
|
133
143
|
f.puts "# See: rake update_version"
|
134
144
|
f.puts "module Gem"
|
135
|
-
f.puts " RubyGemsVersion = '#{
|
145
|
+
f.puts " RubyGemsVersion = '#{PKG_VERSION}'"
|
136
146
|
f.puts "end"
|
137
147
|
end
|
138
|
-
|
148
|
+
if ENV['RELTEST']
|
149
|
+
announce "Release Task Testing, skipping commiting of new version"
|
150
|
+
else
|
151
|
+
sh %{cvs commit -m "Updated to version #{PKG_VERSION}" lib/rubygems/rubygems_version.rb}
|
152
|
+
end
|
139
153
|
end
|
140
154
|
end
|
141
155
|
|
142
156
|
task :tag => [:prerelease] do
|
143
|
-
reltag = "REL_#{
|
157
|
+
reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}"
|
144
158
|
reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE']
|
145
159
|
announce "Tagging CVS with [#{reltag}]"
|
146
|
-
|
160
|
+
if ENV['RELTEST']
|
161
|
+
announce "Release Task Testing, skipping CVS tagging"
|
162
|
+
else
|
163
|
+
sh %{cvs tag #{reltag}}
|
164
|
+
end
|
147
165
|
end
|
148
166
|
|
149
167
|
# --------------------------------------------------------------------
|
@@ -214,7 +232,7 @@ Rake::PackageTask.new("package") do |p|
|
|
214
232
|
p.package_files = PKG_FILES
|
215
233
|
end
|
216
234
|
|
217
|
-
|
235
|
+
Spec = Gem::Specification.new do |s|
|
218
236
|
s.name = PKG_NAME + "-update"
|
219
237
|
s.version = PKG_VERSION
|
220
238
|
s.summary = "RubyGems Update GEM"
|
@@ -232,7 +250,13 @@ installation of RubyGems before this update can be applied.
|
|
232
250
|
s.executables = ["update_rubygems"]
|
233
251
|
end
|
234
252
|
|
235
|
-
Rake::GemPackageTask.new(
|
253
|
+
Rake::GemPackageTask.new(Spec) do |p| end
|
254
|
+
|
255
|
+
desc "Build the Gem spec file for the rubygems-update package"
|
256
|
+
task :gemspec => "pkg/rubygems-update.gemspec"
|
257
|
+
file "pkg/rubygems-update.gemspec" => ["pkg", "Rakefile"] do |t|
|
258
|
+
open(t.name, "w") do |f| f.puts Spec.to_yaml end
|
259
|
+
end
|
236
260
|
|
237
261
|
# Install RubyGems
|
238
262
|
|
data/bin/gemwhich
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
EXT = %w( .rb .rbw .so .dll )
|
7
|
+
|
8
|
+
options = OptionParser.new
|
9
|
+
options.banner = "gemwhich -- Find the location of a library module."
|
10
|
+
options.separator("")
|
11
|
+
options.separator("Usage: gemwhich [options] libname...")
|
12
|
+
options.on_tail('-v', '--verbose',
|
13
|
+
"Enable verbose output"
|
14
|
+
) do |value|
|
15
|
+
$verbose = value
|
16
|
+
end
|
17
|
+
options.on_tail('-h', '--help',
|
18
|
+
"Display this help message"
|
19
|
+
) do |value|
|
20
|
+
puts options
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
ARGV << '-h' if ARGV.empty?
|
24
|
+
|
25
|
+
begin
|
26
|
+
options.parse!(ARGV)
|
27
|
+
rescue OptionParser::InvalidOption => ex
|
28
|
+
puts "Error: #{ex.message}"
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
|
32
|
+
def find_path(package_name, dirs)
|
33
|
+
dirs.each do |dir|
|
34
|
+
EXT.each do |ext|
|
35
|
+
full_path = File.join(dir, "#{package_name}#{ext}")
|
36
|
+
if File.exist?(full_path)
|
37
|
+
return full_path
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
searcher = Gem::GemPathSearcher.new
|
45
|
+
ARGV.each do |arg|
|
46
|
+
dirs = $LOAD_PATH
|
47
|
+
spec = searcher.find(arg)
|
48
|
+
if spec
|
49
|
+
dirs =
|
50
|
+
spec.require_paths.collect { |d|
|
51
|
+
File.join(spec.full_gem_path,d)
|
52
|
+
} + $LOAD_PATH
|
53
|
+
puts "(checking gem #{spec.full_name} for #{arg})" if $verbose
|
54
|
+
end
|
55
|
+
path = find_path(arg, dirs)
|
56
|
+
if path
|
57
|
+
puts path
|
58
|
+
else
|
59
|
+
puts "Can't find #{arg}"
|
60
|
+
end
|
61
|
+
end
|
data/lib/gemconfigure.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Gem
|
2
|
+
|
3
|
+
# Activate the gems specfied by the gem_pairs list.
|
4
|
+
#
|
5
|
+
# gem_pairs ::
|
6
|
+
# List of gem/version pairs.
|
7
|
+
# Eg. [['rake', '= 0.8.15'], ['RedCloth', '~> 3.0']]
|
8
|
+
# options ::
|
9
|
+
# options[:verbose] => print gems as they are required.
|
10
|
+
#
|
11
|
+
def self.configure(gem_pairs, options={})
|
12
|
+
gem_pairs.each do |name, version|
|
13
|
+
require 'rubygems'
|
14
|
+
puts "Requiring gem #{name} (version #{version})" if options[:verbose]
|
15
|
+
require_gem name, version
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/rubygems.rb
CHANGED
@@ -29,9 +29,13 @@ module Kernel
|
|
29
29
|
# raises:: [Gem::LoadError] if Gem cannot be found, is listed in GEM_SKIP, or version requirement not met.
|
30
30
|
#
|
31
31
|
def require_gem(gem, *version_requirements)
|
32
|
+
require_gem_with_options(gem, version_requirements, :auto_require=>true)
|
33
|
+
end
|
34
|
+
|
35
|
+
def require_gem_with_options(gem, version_requirements, options={})
|
32
36
|
skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
|
33
37
|
raise Gem::LoadError, "skipping #{gem}" if skip_list.include? gem
|
34
|
-
Gem.activate(gem,
|
38
|
+
Gem.activate(gem, options[:auto_require], *version_requirements)
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
@@ -64,12 +68,13 @@ module Gem
|
|
64
68
|
require 'rubygems/cmd_manager'
|
65
69
|
require 'rubygems/gem_runner'
|
66
70
|
require 'rubygems/config_file'
|
71
|
+
require 'rubygems/deployment'
|
67
72
|
end
|
68
73
|
|
69
74
|
##
|
70
75
|
# Returns an Cache of specifications that are in the Gem.path
|
71
76
|
#
|
72
|
-
# return:: [Gem::
|
77
|
+
# return:: [Gem::SourceIndex] Index of installed Gem::Specifications
|
73
78
|
#
|
74
79
|
def source_index
|
75
80
|
@@source_index ||= SourceIndex.from_installed_gems
|
@@ -105,13 +110,21 @@ module Gem
|
|
105
110
|
def user_home
|
106
111
|
@user_home ||= find_home
|
107
112
|
end
|
108
|
-
|
113
|
+
|
114
|
+
# Return the path to standard location of the users .gemrc file.
|
115
|
+
def config_file
|
116
|
+
File.join(Gem.user_home, '.gemrc')
|
117
|
+
end
|
118
|
+
|
109
119
|
##
|
110
120
|
# Activate a gem (i.e. add it to the Ruby load path). The gem
|
111
121
|
# must satisfy all the specified version constraints. If
|
112
122
|
# +autorequire+ is true, then automatically require the specified
|
113
123
|
# autorequire file in the gem spec.
|
114
124
|
#
|
125
|
+
# Returns true if the gem is loaded by this call, false if it is
|
126
|
+
# already loaded, or an exception otherwise.
|
127
|
+
#
|
115
128
|
def activate(gem, autorequire, *version_requirements)
|
116
129
|
unless version_requirements.size > 0
|
117
130
|
version_requirements = ["> 0.0.0"]
|
@@ -120,53 +133,57 @@ module Gem
|
|
120
133
|
gem = Gem::Dependency.new(gem, version_requirements)
|
121
134
|
end
|
122
135
|
|
123
|
-
|
124
|
-
|
125
|
-
if matches.size==0
|
126
|
-
matches = Gem.source_index.search(gem_name_pattern)
|
127
|
-
if matches.size==0
|
128
|
-
error = Gem::LoadError.new("\nCould not find RubyGem #{gem.name} (#{gem.version_requirements})\n")
|
129
|
-
error.name = gem.name
|
130
|
-
error.version_requirement = gem.version_requirements
|
131
|
-
raise error
|
132
|
-
else
|
133
|
-
error = Gem::LoadError.new("\nRubyGem version error: #{gem.name}(#{matches.first.version} not #{gem.version_requirements})\n")
|
134
|
-
error.name = gem.name
|
135
|
-
error.version_requirement = gem.version_requirements
|
136
|
-
raise error
|
137
|
-
end
|
138
|
-
else
|
139
|
-
# Get highest matching version
|
140
|
-
spec = matches.last
|
141
|
-
if spec.loaded?
|
142
|
-
result = spec.autorequire ? require(spec.autorequire) : false
|
143
|
-
return result || false
|
144
|
-
end
|
145
|
-
|
146
|
-
spec.loaded = true
|
147
|
-
|
148
|
-
# Load dependent gems first
|
149
|
-
spec.dependencies.each do |dep_gem|
|
150
|
-
activate(dep_gem, autorequire)
|
151
|
-
end
|
152
|
-
|
153
|
-
# add bin dir to require_path
|
154
|
-
if(spec.bindir) then
|
155
|
-
spec.require_paths << spec.bindir
|
156
|
-
end
|
136
|
+
matches = Gem.source_index.find_name(gem.name, gem.version_requirements)
|
137
|
+
report_activate_error(gem) if matches.empty?
|
157
138
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
return true
|
139
|
+
# Get highest matching version
|
140
|
+
spec = matches.last
|
141
|
+
if spec.loaded?
|
142
|
+
return false unless autorequire
|
143
|
+
result = spec.autorequire ? require(spec.autorequire) : false
|
144
|
+
return result || false
|
165
145
|
end
|
166
|
-
|
146
|
+
|
147
|
+
spec.loaded = true
|
148
|
+
|
149
|
+
# Load dependent gems first
|
150
|
+
spec.dependencies.each do |dep_gem|
|
151
|
+
activate(dep_gem, autorequire)
|
152
|
+
end
|
153
|
+
|
154
|
+
# add bin dir to require_path
|
155
|
+
if(spec.bindir) then
|
156
|
+
spec.require_paths << spec.bindir
|
157
|
+
end
|
158
|
+
|
159
|
+
# Now add the require_paths to the LOAD_PATH
|
160
|
+
spec.require_paths.each do |path|
|
161
|
+
$:.unshift File.join(spec.full_gem_path, path)
|
162
|
+
end
|
163
|
+
|
164
|
+
require spec.autorequire if autorequire && spec.autorequire
|
165
|
+
return true
|
167
166
|
end
|
168
167
|
|
169
|
-
|
168
|
+
# Report a load error during activation. The message of load
|
169
|
+
# error depends on whether it was a version mismatch or if there
|
170
|
+
# are not gems of any version by the requested name.
|
171
|
+
def report_activate_error(gem)
|
172
|
+
matches = Gem.source_index.find_name(gem.name)
|
173
|
+
if matches.size==0
|
174
|
+
error = Gem::LoadError.new(
|
175
|
+
"Could not find RubyGem #{gem.name} (#{gem.version_requirements})\n")
|
176
|
+
else
|
177
|
+
error = Gem::LoadError.new(
|
178
|
+
"RubyGem version error: " +
|
179
|
+
"#{gem.name}(#{matches.first.version} not #{gem.version_requirements})\n")
|
180
|
+
end
|
181
|
+
error.name = gem.name
|
182
|
+
error.version_requirement = gem.version_requirements
|
183
|
+
raise error
|
184
|
+
end
|
185
|
+
private :report_activate_error
|
186
|
+
|
170
187
|
# Reset the +dir+ and +path+ values. The next time +dir+ or +path+
|
171
188
|
# is requested, the values will be calculated from scratch. This is
|
172
189
|
# mainly used by the unit tests to provide test isolation.
|
@@ -213,13 +230,14 @@ module Gem
|
|
213
230
|
|
214
231
|
def required_location(gemname, libfile, *version_constraints)
|
215
232
|
version_constraints = [">0"] if version_constraints.empty?
|
216
|
-
matches = Gem.source_index.
|
233
|
+
matches = Gem.source_index.find_name(gemname, version_constraints)
|
217
234
|
return nil if matches.empty?
|
218
235
|
spec = matches.last
|
219
236
|
spec.require_paths.each do |path|
|
220
237
|
result = File.join(spec.full_gem_path, path, libfile)
|
221
238
|
return result if File.exists?(result)
|
222
239
|
end
|
240
|
+
nil
|
223
241
|
end
|
224
242
|
|
225
243
|
|