slimgems 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5811 -0
- data/History.txt +887 -0
- data/LICENSE.txt +51 -0
- data/README.md +87 -0
- data/Rakefile +120 -0
- data/bin/gem +25 -0
- data/bin/update_slimgems +35 -0
- data/bootstrap/Rakefile +4 -0
- data/hide_lib_for_update/note.txt +5 -0
- data/lib/gauntlet_rubygems.rb +50 -0
- data/lib/rbconfig/datadir.rb +20 -0
- data/lib/rubygems.rb +1220 -0
- data/lib/rubygems/builder.rb +102 -0
- data/lib/rubygems/command.rb +534 -0
- data/lib/rubygems/command_manager.rb +182 -0
- data/lib/rubygems/commands/build_command.rb +53 -0
- data/lib/rubygems/commands/cert_command.rb +86 -0
- data/lib/rubygems/commands/check_command.rb +80 -0
- data/lib/rubygems/commands/cleanup_command.rb +106 -0
- data/lib/rubygems/commands/contents_command.rb +98 -0
- data/lib/rubygems/commands/dependency_command.rb +195 -0
- data/lib/rubygems/commands/environment_command.rb +132 -0
- data/lib/rubygems/commands/fetch_command.rb +67 -0
- data/lib/rubygems/commands/generate_index_command.rb +133 -0
- data/lib/rubygems/commands/help_command.rb +172 -0
- data/lib/rubygems/commands/install_command.rb +178 -0
- data/lib/rubygems/commands/list_command.rb +35 -0
- data/lib/rubygems/commands/lock_command.rb +110 -0
- data/lib/rubygems/commands/mirror_command.rb +111 -0
- data/lib/rubygems/commands/outdated_command.rb +33 -0
- data/lib/rubygems/commands/owner_command.rb +75 -0
- data/lib/rubygems/commands/pristine_command.rb +93 -0
- data/lib/rubygems/commands/push_command.rb +56 -0
- data/lib/rubygems/commands/query_command.rb +280 -0
- data/lib/rubygems/commands/rdoc_command.rb +91 -0
- data/lib/rubygems/commands/search_command.rb +31 -0
- data/lib/rubygems/commands/server_command.rb +86 -0
- data/lib/rubygems/commands/setup_command.rb +387 -0
- data/lib/rubygems/commands/sources_command.rb +157 -0
- data/lib/rubygems/commands/specification_command.rb +125 -0
- data/lib/rubygems/commands/stale_command.rb +27 -0
- data/lib/rubygems/commands/uninstall_command.rb +83 -0
- data/lib/rubygems/commands/unpack_command.rb +121 -0
- data/lib/rubygems/commands/update_command.rb +212 -0
- data/lib/rubygems/commands/which_command.rb +86 -0
- data/lib/rubygems/config_file.rb +345 -0
- data/lib/rubygems/custom_require.rb +44 -0
- data/lib/rubygems/defaults.rb +101 -0
- data/lib/rubygems/dependency.rb +227 -0
- data/lib/rubygems/dependency_installer.rb +286 -0
- data/lib/rubygems/dependency_list.rb +208 -0
- data/lib/rubygems/doc_manager.rb +242 -0
- data/lib/rubygems/errors.rb +35 -0
- data/lib/rubygems/exceptions.rb +91 -0
- data/lib/rubygems/ext.rb +18 -0
- data/lib/rubygems/ext/builder.rb +56 -0
- data/lib/rubygems/ext/configure_builder.rb +25 -0
- data/lib/rubygems/ext/ext_conf_builder.rb +24 -0
- data/lib/rubygems/ext/rake_builder.rb +39 -0
- data/lib/rubygems/format.rb +81 -0
- data/lib/rubygems/gem_openssl.rb +92 -0
- data/lib/rubygems/gem_path_searcher.rb +100 -0
- data/lib/rubygems/gem_runner.rb +79 -0
- data/lib/rubygems/gemcutter_utilities.rb +49 -0
- data/lib/rubygems/indexer.rb +720 -0
- data/lib/rubygems/install_update_options.rb +125 -0
- data/lib/rubygems/installer.rb +604 -0
- data/lib/rubygems/local_remote_options.rb +135 -0
- data/lib/rubygems/old_format.rb +153 -0
- data/lib/rubygems/package.rb +97 -0
- data/lib/rubygems/package/f_sync_dir.rb +23 -0
- data/lib/rubygems/package/tar_header.rb +266 -0
- data/lib/rubygems/package/tar_input.rb +222 -0
- data/lib/rubygems/package/tar_output.rb +144 -0
- data/lib/rubygems/package/tar_reader.rb +106 -0
- data/lib/rubygems/package/tar_reader/entry.rb +141 -0
- data/lib/rubygems/package/tar_writer.rb +241 -0
- data/lib/rubygems/package_task.rb +126 -0
- data/lib/rubygems/platform.rb +183 -0
- data/lib/rubygems/remote_fetcher.rb +414 -0
- data/lib/rubygems/require_paths_builder.rb +18 -0
- data/lib/rubygems/requirement.rb +153 -0
- data/lib/rubygems/security.rb +814 -0
- data/lib/rubygems/server.rb +872 -0
- data/lib/rubygems/source_index.rb +597 -0
- data/lib/rubygems/source_info_cache.rb +395 -0
- data/lib/rubygems/source_info_cache_entry.rb +56 -0
- data/lib/rubygems/spec_fetcher.rb +337 -0
- data/lib/rubygems/specification.rb +1486 -0
- data/lib/rubygems/test_utilities.rb +147 -0
- data/lib/rubygems/text.rb +65 -0
- data/lib/rubygems/uninstaller.rb +278 -0
- data/lib/rubygems/user_interaction.rb +527 -0
- data/lib/rubygems/validator.rb +240 -0
- data/lib/rubygems/version.rb +316 -0
- data/lib/rubygems/version_option.rb +65 -0
- data/lib/ubygems.rb +10 -0
- data/setup.rb +42 -0
- data/test/bogussources.rb +8 -0
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/fake_certlib/openssl.rb +7 -0
- data/test/foo/discover.rb +0 -0
- data/test/functional.rb +92 -0
- data/test/gem_installer_test_case.rb +97 -0
- data/test/gem_package_tar_test_case.rb +132 -0
- data/test/gemutilities.rb +605 -0
- data/test/insure_session.rb +43 -0
- data/test/mockgemui.rb +56 -0
- data/test/plugin/exception/rubygems_plugin.rb +2 -0
- data/test/plugin/load/rubygems_plugin.rb +1 -0
- data/test/plugin/standarderror/rubygems_plugin.rb +2 -0
- data/test/private_key.pem +27 -0
- data/test/public_cert.pem +20 -0
- data/test/rubygems_plugin.rb +21 -0
- data/test/simple_gem.rb +66 -0
- data/test/test_config.rb +12 -0
- data/test/test_gem.rb +766 -0
- data/test/test_gem_builder.rb +27 -0
- data/test/test_gem_command.rb +178 -0
- data/test/test_gem_command_manager.rb +207 -0
- data/test/test_gem_commands_build_command.rb +74 -0
- data/test/test_gem_commands_cert_command.rb +124 -0
- data/test/test_gem_commands_check_command.rb +18 -0
- data/test/test_gem_commands_contents_command.rb +156 -0
- data/test/test_gem_commands_dependency_command.rb +216 -0
- data/test/test_gem_commands_environment_command.rb +144 -0
- data/test/test_gem_commands_fetch_command.rb +76 -0
- data/test/test_gem_commands_generate_index_command.rb +135 -0
- data/test/test_gem_commands_install_command.rb +315 -0
- data/test/test_gem_commands_list_command.rb +36 -0
- data/test/test_gem_commands_lock_command.rb +68 -0
- data/test/test_gem_commands_mirror_command.rb +60 -0
- data/test/test_gem_commands_outdated_command.rb +40 -0
- data/test/test_gem_commands_owner_command.rb +105 -0
- data/test/test_gem_commands_pristine_command.rb +108 -0
- data/test/test_gem_commands_push_command.rb +81 -0
- data/test/test_gem_commands_query_command.rb +426 -0
- data/test/test_gem_commands_server_command.rb +59 -0
- data/test/test_gem_commands_sources_command.rb +209 -0
- data/test/test_gem_commands_specification_command.rb +139 -0
- data/test/test_gem_commands_stale_command.rb +38 -0
- data/test/test_gem_commands_uninstall_command.rb +83 -0
- data/test/test_gem_commands_unpack_command.rb +199 -0
- data/test/test_gem_commands_update_command.rb +353 -0
- data/test/test_gem_commands_which_command.rb +66 -0
- data/test/test_gem_config_file.rb +287 -0
- data/test/test_gem_dependency.rb +149 -0
- data/test/test_gem_dependency_installer.rb +661 -0
- data/test/test_gem_dependency_list.rb +230 -0
- data/test/test_gem_doc_manager.rb +31 -0
- data/test/test_gem_ext_configure_builder.rb +84 -0
- data/test/test_gem_ext_ext_conf_builder.rb +173 -0
- data/test/test_gem_ext_rake_builder.rb +81 -0
- data/test/test_gem_format.rb +70 -0
- data/test/test_gem_gem_path_searcher.rb +78 -0
- data/test/test_gem_gem_runner.rb +45 -0
- data/test/test_gem_gemcutter_utilities.rb +103 -0
- data/test/test_gem_indexer.rb +673 -0
- data/test/test_gem_install_update_options.rb +68 -0
- data/test/test_gem_installer.rb +857 -0
- data/test/test_gem_local_remote_options.rb +97 -0
- data/test/test_gem_package_tar_header.rb +130 -0
- data/test/test_gem_package_tar_input.rb +112 -0
- data/test/test_gem_package_tar_output.rb +97 -0
- data/test/test_gem_package_tar_reader.rb +46 -0
- data/test/test_gem_package_tar_reader_entry.rb +109 -0
- data/test/test_gem_package_tar_writer.rb +144 -0
- data/test/test_gem_package_task.rb +59 -0
- data/test/test_gem_platform.rb +264 -0
- data/test/test_gem_remote_fetcher.rb +740 -0
- data/test/test_gem_requirement.rb +292 -0
- data/test/test_gem_server.rb +356 -0
- data/test/test_gem_silent_ui.rb +113 -0
- data/test/test_gem_source_index.rb +461 -0
- data/test/test_gem_spec_fetcher.rb +410 -0
- data/test/test_gem_specification.rb +1291 -0
- data/test/test_gem_stream_ui.rb +218 -0
- data/test/test_gem_text.rb +43 -0
- data/test/test_gem_uninstaller.rb +146 -0
- data/test/test_gem_validator.rb +63 -0
- data/test/test_gem_version.rb +181 -0
- data/test/test_gem_version_option.rb +89 -0
- data/test/test_kernel.rb +59 -0
- metadata +413 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
RubyGems (and SlimGems) is copyrighted free software by Chad Fowler, Rich Kilmer,
|
2
|
+
Jim Weirich and others. You can redistribute it under the conditions below:
|
3
|
+
|
4
|
+
1. You may make and give away verbatim copies of the source form of the
|
5
|
+
software without restriction, provided that you duplicate all of the
|
6
|
+
original copyright notices and associated disclaimers.
|
7
|
+
|
8
|
+
2. You may modify your copy of the software in any way, provided that
|
9
|
+
you do at least ONE of the following:
|
10
|
+
|
11
|
+
a) place your modifications in the Public Domain or otherwise
|
12
|
+
make them Freely Available, such as by posting said
|
13
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
14
|
+
the author to include your modifications in the software.
|
15
|
+
|
16
|
+
b) use the modified software only within your corporation or
|
17
|
+
organization.
|
18
|
+
|
19
|
+
c) rename any non-standard executables so the names do not conflict
|
20
|
+
with standard executables, which must also be provided.
|
21
|
+
|
22
|
+
d) make other distribution arrangements with the author.
|
23
|
+
|
24
|
+
3. You may distribute the software in object code or executable
|
25
|
+
form, provided that you do at least ONE of the following:
|
26
|
+
|
27
|
+
a) distribute the executables and library files of the software,
|
28
|
+
together with instructions (in the manual page or equivalent)
|
29
|
+
on where to get the original distribution.
|
30
|
+
|
31
|
+
b) accompany the distribution with the machine-readable source of
|
32
|
+
the software.
|
33
|
+
|
34
|
+
c) give non-standard executables non-standard names, with
|
35
|
+
instructions on where to get the original software distribution.
|
36
|
+
|
37
|
+
d) make other distribution arrangements with the author.
|
38
|
+
|
39
|
+
4. You may modify and include the part of the software into any other
|
40
|
+
software (possibly commercial).
|
41
|
+
|
42
|
+
5. The scripts and library files supplied as input to or produced as
|
43
|
+
output from the software do not automatically fall under the
|
44
|
+
copyright of the software, but belong to whomever generated them,
|
45
|
+
and may be sold commercially, and may be aggregated with this
|
46
|
+
software.
|
47
|
+
|
48
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
49
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
50
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
51
|
+
PURPOSE.
|
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# SlimGems
|
2
|
+
|
3
|
+
* Website: http://slimgems.github.com/
|
4
|
+
* Github: http://github.com/slimgems/slimgems
|
5
|
+
* Get gems from: http://rubygems.org
|
6
|
+
|
7
|
+
## Description
|
8
|
+
|
9
|
+
SlimGems is a drop-in replacement for RubyGems, a package management framework
|
10
|
+
for Ruby. We forked the project at 1.3.7, which was a great stable release.
|
11
|
+
|
12
|
+
SlimGems focuses on maintaining a sane and stable API. We believe that the
|
13
|
+
project has been put through enough stress testing by the community to lock
|
14
|
+
into the current API functionality for the forseeable future. We will also
|
15
|
+
continue to improve the runtime performance over time; we can do this
|
16
|
+
without changing the API.
|
17
|
+
|
18
|
+
## Project Goals
|
19
|
+
|
20
|
+
1. A fast package manager that "Just Works". We will attempt to make SlimGems
|
21
|
+
as fast as possible and believe it can be done without breaking the existing
|
22
|
+
API.
|
23
|
+
|
24
|
+
2. A consistent and stable API. Deprecations will not occur without ample
|
25
|
+
warning to library developers *before* a release. Deprecations will not
|
26
|
+
necessarily mean removed methods or runtime warnings, and we will consult
|
27
|
+
with the community if widely used APIs ever need to be removed.
|
28
|
+
|
29
|
+
3. Receptive and friendly project maintainers. We will listen to your bugs
|
30
|
+
and suggestions without deriding you. We believe the community deserves
|
31
|
+
a voice in matters that affect package management tools, and we respect
|
32
|
+
that voice.
|
33
|
+
|
34
|
+
4. Improved communication with the community about future plans. We believe
|
35
|
+
it's important to keep the community informed about major changes. We will
|
36
|
+
discuss our rationale for any changes that might cause problems for other
|
37
|
+
library developers.
|
38
|
+
|
39
|
+
## What Do I Have to do Differently to Use SlimGems?
|
40
|
+
|
41
|
+
Nothing. We maintain the same install paths, APIs and overall runtime environment
|
42
|
+
that RubyGems had. The only difference is that we have no intention on changing
|
43
|
+
this environment in future upgrades. You can upgrade safely knowing that the
|
44
|
+
newer versions of SlimGems will still be compatible with all of your code.
|
45
|
+
|
46
|
+
In short, yes, "require 'rubygems'" still works.
|
47
|
+
|
48
|
+
## Installing and Upgrading
|
49
|
+
|
50
|
+
If you're on RubyGems, you can easily upgrade to SlimGems by typing:
|
51
|
+
|
52
|
+
$ gem install slimgems
|
53
|
+
|
54
|
+
You can do this from SlimGems too, but if you have SlimGems already, upgrading
|
55
|
+
works better with:
|
56
|
+
|
57
|
+
$ gem update --system
|
58
|
+
|
59
|
+
If you don't have any RubyGems or SlimGems install, there is still the pre-gem
|
60
|
+
approach to getting software, doing it manually:
|
61
|
+
|
62
|
+
1. Download from: http://github.com/slimgems/slimgems
|
63
|
+
2. Unpack into a directory and cd there
|
64
|
+
3. Install with: ruby setup.rb # you may need admin/root privilege
|
65
|
+
|
66
|
+
For more details and other options, see:
|
67
|
+
|
68
|
+
ruby setup.rb --help
|
69
|
+
|
70
|
+
## Uninstalling
|
71
|
+
|
72
|
+
If SlimGems isn't for you, you can downgrade back to RubyGems by performing
|
73
|
+
the following intuitive command:
|
74
|
+
|
75
|
+
$ gem uninstall slimgems
|
76
|
+
|
77
|
+
Again, you might need to have administrator privileges (sudo) to run these
|
78
|
+
commands.
|
79
|
+
|
80
|
+
## Notes about this SlimGems Fork
|
81
|
+
|
82
|
+
SlimGems is a RubyGems fork of RubyGems 1.3.7 and a limited set of backports
|
83
|
+
from 1.5.2. SlimGems is maintained by Loren Segal and others. SlimGems will
|
84
|
+
provide continual improvements with a stable API.
|
85
|
+
|
86
|
+
You can download the original RubyGems project at
|
87
|
+
http://rubyforge.org/projects/rubygems
|
data/Rakefile
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
$:.unshift 'lib'
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'rubygems/package_task'
|
7
|
+
require 'rake/testtask'
|
8
|
+
|
9
|
+
task :default => :test
|
10
|
+
desc "Run just the functional tests"
|
11
|
+
Rake::TestTask.new(:test_functional) do |t|
|
12
|
+
t.options = '--seed=1'
|
13
|
+
t.ruby_opts = ['--disable-gems'] if RUBY_VERSION >= "1.9.1"
|
14
|
+
t.test_files = FileList['test/functional*.rb']
|
15
|
+
end
|
16
|
+
|
17
|
+
Rake::TestTask.new(:test) do |t|
|
18
|
+
t.options = '--seed=1'
|
19
|
+
t.ruby_opts = ['--disable-gems'] if RUBY_VERSION >= "1.9.1"
|
20
|
+
t.test_files = FileList['test/test_*.rb']
|
21
|
+
end
|
22
|
+
|
23
|
+
# These tasks expect to have the following directory structure:
|
24
|
+
#
|
25
|
+
# git/git.rubini.us/code # Rubinius git HEAD checkout
|
26
|
+
# svn/ruby/trunk # ruby subversion HEAD checkout
|
27
|
+
# svn/rubygems/trunk # SlimGems subversion HEAD checkout
|
28
|
+
#
|
29
|
+
# If you don't have this directory structure, set RUBY_PATH and/or
|
30
|
+
# RUBINIUS_PATH.
|
31
|
+
|
32
|
+
def rsync_with dir
|
33
|
+
rsync_options = "-avP --exclude '*svn*' --exclude '*swp' --exclude '*rbc'" +
|
34
|
+
" --exclude '*.rej' --exclude '*.orig' --exclude 'lib/rubygems/defaults/*'"
|
35
|
+
sh "rsync #{rsync_options} bin/gem #{dir}/bin/gem"
|
36
|
+
sh "rsync #{rsync_options} lib/ #{dir}/lib"
|
37
|
+
sh "rsync #{rsync_options} test/ #{dir}/test/rubygems"
|
38
|
+
sh "rsync #{rsync_options} util/gem_prelude.rb #{dir}/gem_prelude.rb"
|
39
|
+
end
|
40
|
+
|
41
|
+
def diff_with dir
|
42
|
+
diff_options = "-urpN --exclude '*svn*' --exclude '*swp' --exclude '*rbc'"
|
43
|
+
sh "diff #{diff_options} bin/gem #{dir}/bin/gem; true"
|
44
|
+
sh "diff #{diff_options} lib/ubygems.rb #{dir}/lib/ubygems.rb; true"
|
45
|
+
sh "diff #{diff_options} lib/rubygems.rb #{dir}/lib/rubygems.rb; true"
|
46
|
+
sh "diff #{diff_options} lib/rubygems #{dir}/lib/rubygems; true"
|
47
|
+
sh "diff #{diff_options} lib/rbconfig #{dir}/lib/rbconfig; true"
|
48
|
+
sh "diff #{diff_options} test #{dir}/test/rubygems; true"
|
49
|
+
sh "diff #{diff_options} util/gem_prelude.rb #{dir}/gem_prelude.rb; true"
|
50
|
+
end
|
51
|
+
|
52
|
+
rubinius_dir = ENV['RUBINIUS_PATH'] || '../../../git/git.rubini.us/code'
|
53
|
+
ruby_dir = ENV['RUBY_PATH'] || '../../ruby/trunk'
|
54
|
+
|
55
|
+
desc "Updates Ruby HEAD with the currently checked-out copy."
|
56
|
+
task :update_ruby do
|
57
|
+
rsync_with ruby_dir
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Updates Rubinius HEAD with the currently checked-out copy."
|
61
|
+
task :update_rubinius do
|
62
|
+
rsync_with rubinius_dir
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Diffs Ruby HEAD with the currently checked-out copy."
|
66
|
+
task :diff_ruby do
|
67
|
+
diff_with ruby_dir
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Diffs Rubinius HEAD with the currently checked-out copy."
|
71
|
+
task :diff_rubinius do
|
72
|
+
diff_with rubinius_dir
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Get coverage for a specific test."
|
76
|
+
task "rcov:for", [:test] do |task, args|
|
77
|
+
mgem = Gem.source_index.find_name("minitest").first rescue nil
|
78
|
+
rgem = Gem.source_index.find_name(/rcov/).first
|
79
|
+
libs = rgem.require_paths.map { |p| File.join rgem.full_gem_path, p }
|
80
|
+
rcov = File.join rgem.full_gem_path, rgem.bindir, rgem.default_executable
|
81
|
+
|
82
|
+
if mgem
|
83
|
+
libs << mgem.require_paths.map { |p| File.join mgem.full_gem_path, p }
|
84
|
+
end
|
85
|
+
|
86
|
+
libs << "lib:test"
|
87
|
+
|
88
|
+
flags = []
|
89
|
+
flags << "-I" << libs.flatten.join(":")
|
90
|
+
|
91
|
+
rflags = []
|
92
|
+
rflags << "-i" << "lib/rubygems"
|
93
|
+
|
94
|
+
ruby "#{flags.join ' '} #{rcov} #{rflags.join ' '} #{args[:test]}"
|
95
|
+
end
|
96
|
+
|
97
|
+
task :graph do
|
98
|
+
$: << File.expand_path("~/Work/p4/zss/src/graph/dev/lib")
|
99
|
+
require 'graph'
|
100
|
+
deps = Graph.new
|
101
|
+
deps.rotate
|
102
|
+
|
103
|
+
current = nil
|
104
|
+
`rake -P -s`.each_line do |line|
|
105
|
+
case line
|
106
|
+
when /^rake (.+)/
|
107
|
+
current = $1
|
108
|
+
deps[current] if current # force the node to exist, in case of a leaf
|
109
|
+
when /^\s+(.+)/
|
110
|
+
deps[current] << $1 if current
|
111
|
+
else
|
112
|
+
warn "unparsed: #{line.chomp}"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
deps.boxes
|
118
|
+
deps.save "graph", nil
|
119
|
+
end
|
120
|
+
|
data/bin/gem
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#--
|
3
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
4
|
+
# All rights reserved.
|
5
|
+
# See LICENSE.txt for permissions.
|
6
|
+
#++
|
7
|
+
|
8
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib/')
|
9
|
+
require 'rubygems'
|
10
|
+
require 'rubygems/gem_runner'
|
11
|
+
|
12
|
+
required_version = Gem::Requirement.new ">= 1.8.6"
|
13
|
+
|
14
|
+
unless required_version.satisfied_by? Gem.ruby_version then
|
15
|
+
abort "Expected Ruby Version #{required_version}, is #{Gem.ruby_version}"
|
16
|
+
end
|
17
|
+
|
18
|
+
args = ARGV.clone
|
19
|
+
|
20
|
+
begin
|
21
|
+
Gem::GemRunner.new.run args
|
22
|
+
rescue Gem::SystemExitException => e
|
23
|
+
exit e.exit_code
|
24
|
+
end
|
25
|
+
|
data/bin/update_slimgems
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#--
|
3
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
4
|
+
# All rights reserved.
|
5
|
+
# See LICENSE.txt for permissions.
|
6
|
+
#++
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
|
10
|
+
if ARGV.include? '-h' or ARGV.include? '--help' then
|
11
|
+
$stderr.puts "#{Gem::GEM_NAME}_update [options]"
|
12
|
+
$stderr.puts
|
13
|
+
$stderr.puts "This will install the latest version of #{Gem::NAME}."
|
14
|
+
$stderr.puts
|
15
|
+
$stderr.puts "\t--version=X.Y\tUpdate #{Gem::GEM_NAME} from the X.Y version."
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
|
19
|
+
unless ARGV.grep(/--version=([\d\.]*)/).empty? then
|
20
|
+
exec Gem.ruby, '-S', $PROGRAM_NAME, "_#{$1}_"
|
21
|
+
end
|
22
|
+
|
23
|
+
update_specs = Gem.source_index.find_name('Gem::GEM_NAME')
|
24
|
+
update_spec = update_specs.sort_by {|s| s.version.to_s }.last
|
25
|
+
if update_spec.nil?
|
26
|
+
puts "Error: Cannot find #{Gem::NAME} Update Path!"
|
27
|
+
puts
|
28
|
+
puts "#{Gem::NAME} has already been updated."
|
29
|
+
puts "The #{Gem::GEM_NAME} gem may now be uninstalled."
|
30
|
+
puts "E.g. gem uninstall #{Gem::GEM_NAME}"
|
31
|
+
else
|
32
|
+
Dir.chdir update_spec.full_gem_path
|
33
|
+
system(Gem.ruby, 'setup.rb', *ARGV)
|
34
|
+
end
|
35
|
+
|
data/bootstrap/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'gauntlet'
|
3
|
+
|
4
|
+
##
|
5
|
+
# GemGauntlet validates all current gems. Currently these packages are
|
6
|
+
# borked:
|
7
|
+
#
|
8
|
+
# Asami-0.04 : No such file or directory - bin/Asami.rb
|
9
|
+
# ObjectGraph-1.0.1 : No such file or directory - bin/objectgraph
|
10
|
+
# evil-ruby-0.1.0 : authors must be Array of Strings
|
11
|
+
# fresh_cookies-1.0.0 : authors must be Array of Strings
|
12
|
+
# plugems_deploy-0.2.0 : authors must be Array of Strings
|
13
|
+
# pmsrb-0.2.0 : authors must be Array of Strings
|
14
|
+
# pqa-1.6 : authors must be Array of Strings
|
15
|
+
# rant-0.5.7 : authors must be Array of Strings
|
16
|
+
# rvsh-0.4.5 : No such file or directory - bin/rvsh
|
17
|
+
# xen-0.1.2.1 : authors must be Array of Strings
|
18
|
+
|
19
|
+
class GemGauntlet < Gauntlet
|
20
|
+
def run(name)
|
21
|
+
warn name
|
22
|
+
|
23
|
+
spec = begin
|
24
|
+
Gem::Specification.load 'gemspec'
|
25
|
+
rescue SyntaxError
|
26
|
+
Gem::Specification.from_yaml File.read('gemspec')
|
27
|
+
end
|
28
|
+
spec.validate
|
29
|
+
|
30
|
+
self.data[name] = false
|
31
|
+
self.dirty = true
|
32
|
+
rescue SystemCallError, Gem::InvalidSpecificationException => e
|
33
|
+
self.data[name] = e.message
|
34
|
+
self.dirty = true
|
35
|
+
end
|
36
|
+
|
37
|
+
def should_skip?(name)
|
38
|
+
self.data[name] == false
|
39
|
+
end
|
40
|
+
|
41
|
+
def report
|
42
|
+
self.data.sort.reject { |k,v| !v }.each do |k,v|
|
43
|
+
puts "%-21s: %s" % [k, v]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
gauntlet = GemGauntlet.new
|
49
|
+
gauntlet.run_the_gauntlet ARGV.shift
|
50
|
+
gauntlet.report
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#++
|
6
|
+
|
7
|
+
module RbConfig
|
8
|
+
|
9
|
+
##
|
10
|
+
# Return the path to the data directory associated with the given package
|
11
|
+
# name. Normally this is just
|
12
|
+
# "#{RbConfig::CONFIG['datadir']}/#{package_name}", but may be modified by
|
13
|
+
# packages like SlimGems to handle versioned data directories.
|
14
|
+
|
15
|
+
def self.datadir(package_name)
|
16
|
+
File.join(CONFIG['datadir'], package_name)
|
17
|
+
end unless RbConfig.respond_to?(:datadir)
|
18
|
+
|
19
|
+
end
|
20
|
+
|
data/lib/rubygems.rb
ADDED
@@ -0,0 +1,1220 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
|
6
|
+
gem_disabled = !defined? Gem
|
7
|
+
|
8
|
+
unless gem_disabled
|
9
|
+
# Nuke the Quickloader stuff
|
10
|
+
Gem::QuickLoader.remove if defined?(Gem::QuickLoader)
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'rubygems/defaults'
|
14
|
+
require 'thread'
|
15
|
+
|
16
|
+
##
|
17
|
+
# SlimGems is the Ruby standard for publishing and managing third party
|
18
|
+
# libraries.
|
19
|
+
#
|
20
|
+
# For user documentation, see:
|
21
|
+
#
|
22
|
+
# * <tt>gem help</tt> and <tt>gem help [command]</tt>
|
23
|
+
# * {SlimGems User Guide}[http://docs.rubygems.org/read/book/1]
|
24
|
+
# * {Frequently Asked Questions}[http://docs.rubygems.org/read/book/3]
|
25
|
+
#
|
26
|
+
# For gem developer documentation see:
|
27
|
+
#
|
28
|
+
# * {Creating Gems}[http://docs.rubygems.org/read/chapter/5]
|
29
|
+
# * Gem::Specification
|
30
|
+
# * Gem::Version for version dependency notes
|
31
|
+
#
|
32
|
+
# Further SlimGems documentation can be found at:
|
33
|
+
#
|
34
|
+
# * {SlimGems API}[http://rubygems.rubyforge.org/rdoc] (also available from
|
35
|
+
# <tt>gem server</tt>)
|
36
|
+
# * {SlimGems Bookshelf}[http://rubygem.org]
|
37
|
+
#
|
38
|
+
# == SlimGems Plugins
|
39
|
+
#
|
40
|
+
# As of #{Gem::NAME} 1.3.2, SlimGems will load plugins installed in gems or
|
41
|
+
# $LOAD_PATH. Plugins must be named 'rubygems_plugin' (.rb, .so, etc) and
|
42
|
+
# placed at the root of your gem's #require_path. Plugins are discovered via
|
43
|
+
# Gem::find_files then loaded. Take care when implementing a plugin as your
|
44
|
+
# plugin file may be loaded multiple times if multiple versions of your gem
|
45
|
+
# are installed.
|
46
|
+
#
|
47
|
+
# For an example plugin, see the graph gem which adds a `gem graph` command.
|
48
|
+
#
|
49
|
+
# == SlimGems Defaults, Packaging
|
50
|
+
#
|
51
|
+
# SlimGems defaults are stored in rubygems/defaults.rb. If you're packaging
|
52
|
+
# #{Gem::NAME} or implementing Ruby you can change SlimGems' defaults.
|
53
|
+
#
|
54
|
+
# For SlimGems packagers, provide lib/rubygems/operating_system.rb and
|
55
|
+
# override any defaults from lib/rubygems/defaults.rb.
|
56
|
+
#
|
57
|
+
# For Ruby implementers, provide lib/rubygems/#{RUBY_ENGINE}.rb and override
|
58
|
+
# any defaults from lib/rubygems/defaults.rb.
|
59
|
+
#
|
60
|
+
# If you need SlimGems to perform extra work on install or uninstall, your
|
61
|
+
# defaults override file can set pre and post install and uninstall hooks.
|
62
|
+
# See Gem::pre_install, Gem::pre_uninstall, Gem::post_install,
|
63
|
+
# Gem::post_uninstall.
|
64
|
+
#
|
65
|
+
# == Bugs
|
66
|
+
#
|
67
|
+
# You can submit bugs to the
|
68
|
+
# {SlimGems bug tracker}[http://rubyforge.org/tracker/?atid=575&group_id=126]
|
69
|
+
# on RubyForge
|
70
|
+
#
|
71
|
+
# == Credits
|
72
|
+
#
|
73
|
+
# SlimGems is currently maintained by Eric Hodel.
|
74
|
+
#
|
75
|
+
# SlimGems was originally developed at RubyConf 2003 by:
|
76
|
+
#
|
77
|
+
# * Rich Kilmer -- rich(at)infoether.com
|
78
|
+
# * Chad Fowler -- chad(at)chadfowler.com
|
79
|
+
# * David Black -- dblack(at)wobblini.net
|
80
|
+
# * Paul Brannan -- paul(at)atdesk.com
|
81
|
+
# * Jim Weirch -- jim(at)weirichhouse.org
|
82
|
+
#
|
83
|
+
# Contributors:
|
84
|
+
#
|
85
|
+
# * Gavin Sinclair -- gsinclair(at)soyabean.com.au
|
86
|
+
# * George Marrows -- george.marrows(at)ntlworld.com
|
87
|
+
# * Dick Davies -- rasputnik(at)hellooperator.net
|
88
|
+
# * Mauricio Fernandez -- batsman.geo(at)yahoo.com
|
89
|
+
# * Simon Strandgaard -- neoneye(at)adslhome.dk
|
90
|
+
# * Dave Glasser -- glasser(at)mit.edu
|
91
|
+
# * Paul Duncan -- pabs(at)pablotron.org
|
92
|
+
# * Ville Aine -- vaine(at)cs.helsinki.fi
|
93
|
+
# * Eric Hodel -- drbrain(at)segment7.net
|
94
|
+
# * Daniel Berger -- djberg96(at)gmail.com
|
95
|
+
# * Phil Hagelberg -- technomancy(at)gmail.com
|
96
|
+
# * Ryan Davis -- ryand-ruby(at)zenspider.com
|
97
|
+
#
|
98
|
+
# (If your name is missing, PLEASE let us know!)
|
99
|
+
#
|
100
|
+
# Thanks!
|
101
|
+
#
|
102
|
+
# -The SlimGems Team
|
103
|
+
|
104
|
+
module Gem
|
105
|
+
NAME = 'SlimGems'
|
106
|
+
GEM_NAME = 'slimgems'
|
107
|
+
VERSION = '1.3.8'
|
108
|
+
SlimGemsVersion = RubyGemsVersion = VERSION
|
109
|
+
|
110
|
+
##
|
111
|
+
# Raised when SlimGems is unable to load or activate a gem. Contains the
|
112
|
+
# name and version requirements of the gem that either conflicts with
|
113
|
+
# already activated gems or that SlimGems is otherwise unable to activate.
|
114
|
+
|
115
|
+
class LoadError < ::LoadError
|
116
|
+
# Name of gem
|
117
|
+
attr_accessor :name
|
118
|
+
|
119
|
+
# Version requirement of gem
|
120
|
+
attr_accessor :version_requirement
|
121
|
+
end
|
122
|
+
|
123
|
+
##
|
124
|
+
# Configuration settings from ::RbConfig
|
125
|
+
|
126
|
+
ConfigMap = {} unless defined?(ConfigMap)
|
127
|
+
|
128
|
+
require 'rbconfig'
|
129
|
+
|
130
|
+
ConfigMap.merge!(
|
131
|
+
:EXEEXT => RbConfig::CONFIG["EXEEXT"],
|
132
|
+
:RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
|
133
|
+
:arch => RbConfig::CONFIG["arch"],
|
134
|
+
:bindir => RbConfig::CONFIG["bindir"],
|
135
|
+
:datadir => RbConfig::CONFIG["datadir"],
|
136
|
+
:libdir => RbConfig::CONFIG["libdir"],
|
137
|
+
:ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
|
138
|
+
:ruby_version => RbConfig::CONFIG["ruby_version"],
|
139
|
+
:rubylibprefix => RbConfig::CONFIG["rubylibprefix"],
|
140
|
+
:sitedir => RbConfig::CONFIG["sitedir"],
|
141
|
+
:sitelibdir => RbConfig::CONFIG["sitelibdir"],
|
142
|
+
:vendordir => RbConfig::CONFIG["vendordir"] ,
|
143
|
+
:vendorlibdir => RbConfig::CONFIG["vendorlibdir"]
|
144
|
+
)
|
145
|
+
|
146
|
+
##
|
147
|
+
# Default directories in a gem repository
|
148
|
+
|
149
|
+
DIRECTORIES = %w[cache doc gems specifications] unless defined?(DIRECTORIES)
|
150
|
+
|
151
|
+
RubyGemsPackageVersion = VERSION
|
152
|
+
# :startdoc:
|
153
|
+
|
154
|
+
##
|
155
|
+
# An Array of Regexps that match windows ruby platforms.
|
156
|
+
|
157
|
+
WIN_PATTERNS = [
|
158
|
+
/bccwin/i,
|
159
|
+
/cygwin/i,
|
160
|
+
/djgpp/i,
|
161
|
+
/mingw/i,
|
162
|
+
/mswin/i,
|
163
|
+
/wince/i,
|
164
|
+
]
|
165
|
+
|
166
|
+
@@source_index = nil
|
167
|
+
@@win_platform = nil
|
168
|
+
|
169
|
+
@configuration = nil
|
170
|
+
@loaded_specs = {}
|
171
|
+
@loaded_stacks = {}
|
172
|
+
@platforms = []
|
173
|
+
@ruby = nil
|
174
|
+
@sources = []
|
175
|
+
|
176
|
+
@post_build_hooks ||= []
|
177
|
+
@post_install_hooks ||= []
|
178
|
+
@post_uninstall_hooks ||= []
|
179
|
+
@pre_uninstall_hooks ||= []
|
180
|
+
@pre_install_hooks ||= []
|
181
|
+
|
182
|
+
##
|
183
|
+
# Activates an installed gem matching +gem+. The gem must satisfy
|
184
|
+
# +version_requirements+.
|
185
|
+
#
|
186
|
+
# Returns true if the gem is activated, false if it is already
|
187
|
+
# loaded, or an exception otherwise.
|
188
|
+
#
|
189
|
+
# Gem#activate adds the library paths in +gem+ to $LOAD_PATH. Before a Gem
|
190
|
+
# is activated its required Gems are activated. If the version information
|
191
|
+
# is omitted, the highest version Gem of the supplied name is loaded. If a
|
192
|
+
# Gem is not found that meets the version requirements or a required Gem is
|
193
|
+
# not found, a Gem::LoadError is raised.
|
194
|
+
#
|
195
|
+
# More information on version requirements can be found in the
|
196
|
+
# Gem::Requirement and Gem::Version documentation.
|
197
|
+
|
198
|
+
def self.activate(gem, *version_requirements)
|
199
|
+
if version_requirements.last.is_a?(Hash)
|
200
|
+
options = version_requirements.pop
|
201
|
+
else
|
202
|
+
options = {}
|
203
|
+
end
|
204
|
+
|
205
|
+
sources = options[:sources] || []
|
206
|
+
|
207
|
+
if version_requirements.empty? then
|
208
|
+
version_requirements = Gem::Requirement.default
|
209
|
+
end
|
210
|
+
|
211
|
+
unless gem.respond_to?(:name) and
|
212
|
+
gem.respond_to?(:requirement) then
|
213
|
+
gem = Gem::Dependency.new(gem, version_requirements)
|
214
|
+
end
|
215
|
+
|
216
|
+
matches = Gem.source_index.find_name(gem.name, gem.requirement)
|
217
|
+
report_activate_error(gem) if matches.empty?
|
218
|
+
|
219
|
+
if @loaded_specs[gem.name] then
|
220
|
+
# This gem is already loaded. If the currently loaded gem is not in the
|
221
|
+
# list of candidate gems, then we have a version conflict.
|
222
|
+
existing_spec = @loaded_specs[gem.name]
|
223
|
+
|
224
|
+
unless matches.any? { |spec| spec.version == existing_spec.version } then
|
225
|
+
sources_message = sources.map { |spec| spec.full_name }
|
226
|
+
stack_message = @loaded_stacks[gem.name].map { |spec| spec.full_name }
|
227
|
+
|
228
|
+
msg = "can't activate #{gem} for #{sources_message.inspect}, "
|
229
|
+
msg << "already activated #{existing_spec.full_name} for "
|
230
|
+
msg << "#{stack_message.inspect}"
|
231
|
+
|
232
|
+
e = Gem::LoadError.new msg
|
233
|
+
e.name = gem.name
|
234
|
+
e.version_requirement = gem.requirement
|
235
|
+
|
236
|
+
raise e
|
237
|
+
end
|
238
|
+
|
239
|
+
return false
|
240
|
+
end
|
241
|
+
|
242
|
+
# new load
|
243
|
+
spec = matches.last
|
244
|
+
return false if spec.loaded?
|
245
|
+
|
246
|
+
spec.loaded = true
|
247
|
+
@loaded_specs[spec.name] = spec
|
248
|
+
@loaded_stacks[spec.name] = sources.dup
|
249
|
+
|
250
|
+
# Load dependent gems first
|
251
|
+
spec.runtime_dependencies.each do |dep_gem|
|
252
|
+
activate dep_gem, :sources => [spec, *sources]
|
253
|
+
end
|
254
|
+
|
255
|
+
# bin directory must come before library directories
|
256
|
+
spec.require_paths.unshift spec.bindir if spec.bindir
|
257
|
+
|
258
|
+
require_paths = spec.require_paths.map do |path|
|
259
|
+
File.join spec.full_gem_path, path
|
260
|
+
end
|
261
|
+
|
262
|
+
# gem directories must come after -I and ENV['RUBYLIB']
|
263
|
+
insert_index = load_path_insert_index
|
264
|
+
|
265
|
+
if insert_index then
|
266
|
+
# gem directories must come after -I and ENV['RUBYLIB']
|
267
|
+
$LOAD_PATH.insert(insert_index, *require_paths)
|
268
|
+
else
|
269
|
+
# we are probably testing in core, -I and RUBYLIB don't apply
|
270
|
+
$LOAD_PATH.unshift(*require_paths)
|
271
|
+
end
|
272
|
+
|
273
|
+
return true
|
274
|
+
end
|
275
|
+
|
276
|
+
##
|
277
|
+
# An Array of all possible load paths for all versions of all gems in the
|
278
|
+
# Gem installation.
|
279
|
+
|
280
|
+
def self.all_load_paths
|
281
|
+
result = []
|
282
|
+
|
283
|
+
Gem.path.each do |gemdir|
|
284
|
+
each_load_path all_partials(gemdir) do |load_path|
|
285
|
+
result << load_path
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
result
|
290
|
+
end
|
291
|
+
|
292
|
+
##
|
293
|
+
# Return all the partial paths in +gemdir+.
|
294
|
+
|
295
|
+
def self.all_partials(gemdir)
|
296
|
+
Dir[File.join(gemdir, 'gems/*')]
|
297
|
+
end
|
298
|
+
|
299
|
+
private_class_method :all_partials
|
300
|
+
|
301
|
+
##
|
302
|
+
# See if a given gem is available.
|
303
|
+
|
304
|
+
def self.available?(gem, *requirements)
|
305
|
+
requirements = Gem::Requirement.default if requirements.empty?
|
306
|
+
|
307
|
+
unless gem.respond_to?(:name) and
|
308
|
+
gem.respond_to?(:requirement) then
|
309
|
+
gem = Gem::Dependency.new gem, requirements
|
310
|
+
end
|
311
|
+
|
312
|
+
!Gem.source_index.search(gem).empty?
|
313
|
+
end
|
314
|
+
|
315
|
+
##
|
316
|
+
# Find the full path to the executable for gem +name+. If the +exec_name+
|
317
|
+
# is not given, the gem's default_executable is chosen, otherwise the
|
318
|
+
# specified executable's path is returned. +version_requirements+ allows
|
319
|
+
# you to specify specific gem versions.
|
320
|
+
|
321
|
+
def self.bin_path(name, exec_name = nil, *version_requirements)
|
322
|
+
version_requirements = Gem::Requirement.default if
|
323
|
+
version_requirements.empty?
|
324
|
+
specs = Gem.source_index.find_name(name, version_requirements)
|
325
|
+
|
326
|
+
raise Gem::GemNotFoundException,
|
327
|
+
"can't find gem #{name} (#{version_requirements})" if specs.empty?
|
328
|
+
|
329
|
+
specs = specs.find_all do |spec|
|
330
|
+
spec.executables.include?(exec_name)
|
331
|
+
end if exec_name
|
332
|
+
|
333
|
+
unless spec = specs.last
|
334
|
+
msg = "can't find gem #{name} (#{version_requirements}) with executable #{exec_name}"
|
335
|
+
raise Gem::GemNotFoundException, msg
|
336
|
+
end
|
337
|
+
|
338
|
+
exec_name ||= spec.default_executable
|
339
|
+
|
340
|
+
unless exec_name
|
341
|
+
msg = "no default executable for #{spec.full_name} and none given"
|
342
|
+
raise Gem::Exception, msg
|
343
|
+
end
|
344
|
+
|
345
|
+
File.join(spec.full_gem_path, spec.bindir, exec_name)
|
346
|
+
end
|
347
|
+
|
348
|
+
##
|
349
|
+
# The mode needed to read a file as straight binary.
|
350
|
+
|
351
|
+
def self.binary_mode
|
352
|
+
'rb'
|
353
|
+
end
|
354
|
+
|
355
|
+
##
|
356
|
+
# The path where gem executables are to be installed.
|
357
|
+
|
358
|
+
def self.bindir(install_dir=Gem.dir)
|
359
|
+
return File.join(install_dir, 'bin') unless
|
360
|
+
install_dir.to_s == Gem.default_dir
|
361
|
+
Gem.default_bindir
|
362
|
+
end
|
363
|
+
|
364
|
+
##
|
365
|
+
# Reset the +dir+ and +path+ values. The next time +dir+ or +path+
|
366
|
+
# is requested, the values will be calculated from scratch. This is
|
367
|
+
# mainly used by the unit tests to provide test isolation.
|
368
|
+
|
369
|
+
def self.clear_paths
|
370
|
+
@gem_home = nil
|
371
|
+
@gem_path = nil
|
372
|
+
@user_home = nil
|
373
|
+
|
374
|
+
@@source_index = nil
|
375
|
+
|
376
|
+
@searcher = nil
|
377
|
+
end
|
378
|
+
|
379
|
+
##
|
380
|
+
# The path to standard location of the user's .gemrc file.
|
381
|
+
|
382
|
+
def self.config_file
|
383
|
+
File.join Gem.user_home, '.gemrc'
|
384
|
+
end
|
385
|
+
|
386
|
+
##
|
387
|
+
# The standard configuration object for gems.
|
388
|
+
|
389
|
+
def self.configuration
|
390
|
+
@configuration ||= Gem::ConfigFile.new []
|
391
|
+
end
|
392
|
+
|
393
|
+
##
|
394
|
+
# Use the given configuration object (which implements the ConfigFile
|
395
|
+
# protocol) as the standard configuration object.
|
396
|
+
|
397
|
+
def self.configuration=(config)
|
398
|
+
@configuration = config
|
399
|
+
end
|
400
|
+
|
401
|
+
##
|
402
|
+
# The path the the data directory specified by the gem name. If the
|
403
|
+
# package is not available as a gem, return nil.
|
404
|
+
|
405
|
+
def self.datadir(gem_name)
|
406
|
+
spec = @loaded_specs[gem_name]
|
407
|
+
return nil if spec.nil?
|
408
|
+
File.join(spec.full_gem_path, 'data', gem_name)
|
409
|
+
end
|
410
|
+
|
411
|
+
##
|
412
|
+
# A Zlib::Deflate.deflate wrapper
|
413
|
+
|
414
|
+
def self.deflate(data)
|
415
|
+
require 'zlib'
|
416
|
+
Zlib::Deflate.deflate data
|
417
|
+
end
|
418
|
+
|
419
|
+
##
|
420
|
+
# The path where gems are to be installed.
|
421
|
+
|
422
|
+
def self.dir
|
423
|
+
@gem_home ||= nil
|
424
|
+
set_home(ENV['GEM_HOME'] || Gem.configuration.home || default_dir) unless @gem_home
|
425
|
+
@gem_home
|
426
|
+
end
|
427
|
+
|
428
|
+
##
|
429
|
+
# Expand each partial gem path with each of the required paths specified
|
430
|
+
# in the Gem spec. Each expanded path is yielded.
|
431
|
+
|
432
|
+
def self.each_load_path(partials)
|
433
|
+
partials.each do |gp|
|
434
|
+
base = File.basename(gp)
|
435
|
+
specfn = File.join(dir, "specifications", base + ".gemspec")
|
436
|
+
if File.exist?(specfn)
|
437
|
+
spec = eval(File.read(specfn))
|
438
|
+
spec.require_paths.each do |rp|
|
439
|
+
yield(File.join(gp, rp))
|
440
|
+
end
|
441
|
+
else
|
442
|
+
filename = File.join(gp, 'lib')
|
443
|
+
yield(filename) if File.exist?(filename)
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
private_class_method :each_load_path
|
449
|
+
|
450
|
+
##
|
451
|
+
# Quietly ensure the named Gem directory contains all the proper
|
452
|
+
# subdirectories. If we can't create a directory due to a permission
|
453
|
+
# problem, then we will silently continue.
|
454
|
+
|
455
|
+
def self.ensure_gem_subdirectories(gemdir)
|
456
|
+
require 'fileutils'
|
457
|
+
|
458
|
+
Gem::DIRECTORIES.each do |filename|
|
459
|
+
fn = File.join gemdir, filename
|
460
|
+
FileUtils.mkdir_p fn rescue nil unless File.exist? fn
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
##
|
465
|
+
# Returns a list of paths matching +glob+ that can be used by a gem to pick
|
466
|
+
# up features from other gems. For example:
|
467
|
+
#
|
468
|
+
# Gem.find_files('rdoc/discover').each do |path| load path end
|
469
|
+
#
|
470
|
+
# if +check_load_path+ is true (the default), then find_files also searches
|
471
|
+
# $LOAD_PATH for files as well as gems.
|
472
|
+
#
|
473
|
+
# Note that find_files will return all files even if they are from different
|
474
|
+
# versions of the same gem.
|
475
|
+
|
476
|
+
def self.find_files(glob, check_load_path=true)
|
477
|
+
files = []
|
478
|
+
|
479
|
+
if check_load_path
|
480
|
+
files = $LOAD_PATH.map { |load_path|
|
481
|
+
Dir["#{File.expand_path glob, load_path}#{Gem.suffix_pattern}"]
|
482
|
+
}.flatten.select { |file| File.file? file.untaint }
|
483
|
+
end
|
484
|
+
|
485
|
+
specs = searcher.find_all glob
|
486
|
+
|
487
|
+
specs.each do |spec|
|
488
|
+
files.concat searcher.matching_files(spec, glob)
|
489
|
+
end
|
490
|
+
|
491
|
+
# $LOAD_PATH might contain duplicate entries or reference
|
492
|
+
# the spec dirs directly, so we prune.
|
493
|
+
files.uniq! if check_load_path
|
494
|
+
|
495
|
+
return files
|
496
|
+
end
|
497
|
+
|
498
|
+
##
|
499
|
+
# Finds the user's home directory.
|
500
|
+
#--
|
501
|
+
# Some comments from the ruby-talk list regarding finding the home
|
502
|
+
# directory:
|
503
|
+
#
|
504
|
+
# I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems
|
505
|
+
# to be depending on HOME in those code samples. I propose that
|
506
|
+
# it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at
|
507
|
+
# least on Win32).
|
508
|
+
|
509
|
+
def self.find_home
|
510
|
+
unless RUBY_VERSION > '1.9' then
|
511
|
+
['HOME', 'USERPROFILE'].each do |homekey|
|
512
|
+
return File.expand_path(ENV[homekey]) if ENV[homekey]
|
513
|
+
end
|
514
|
+
|
515
|
+
if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
|
516
|
+
return File.expand_path("#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}")
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
File.expand_path "~"
|
521
|
+
rescue
|
522
|
+
if File::ALT_SEPARATOR then
|
523
|
+
drive = ENV['HOMEDRIVE'] || ENV['SystemDrive']
|
524
|
+
File.join(drive.to_s, '/')
|
525
|
+
else
|
526
|
+
"/"
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
private_class_method :find_home
|
531
|
+
|
532
|
+
##
|
533
|
+
# Zlib::GzipReader wrapper that unzips +data+.
|
534
|
+
|
535
|
+
def self.gunzip(data)
|
536
|
+
require 'stringio'
|
537
|
+
require 'zlib'
|
538
|
+
data = StringIO.new data
|
539
|
+
|
540
|
+
Zlib::GzipReader.new(data).read
|
541
|
+
end
|
542
|
+
|
543
|
+
##
|
544
|
+
# Zlib::GzipWriter wrapper that zips +data+.
|
545
|
+
|
546
|
+
def self.gzip(data)
|
547
|
+
require 'stringio'
|
548
|
+
require 'zlib'
|
549
|
+
zipped = StringIO.new
|
550
|
+
|
551
|
+
Zlib::GzipWriter.wrap zipped do |io| io.write data end
|
552
|
+
|
553
|
+
zipped.string
|
554
|
+
end
|
555
|
+
|
556
|
+
##
|
557
|
+
# A Zlib::Inflate#inflate wrapper
|
558
|
+
|
559
|
+
def self.inflate(data)
|
560
|
+
require 'zlib'
|
561
|
+
Zlib::Inflate.inflate data
|
562
|
+
end
|
563
|
+
|
564
|
+
##
|
565
|
+
# Get the default SlimGems API host. This is normally
|
566
|
+
# <tt>https://rubygems.org</tt>.
|
567
|
+
|
568
|
+
def self.host
|
569
|
+
@host ||= "https://rubygems.org"
|
570
|
+
end
|
571
|
+
|
572
|
+
## Set the default SlimGems API host.
|
573
|
+
|
574
|
+
def self.host= host
|
575
|
+
@host = host
|
576
|
+
end
|
577
|
+
|
578
|
+
##
|
579
|
+
# Return a list of all possible load paths for the latest version for all
|
580
|
+
# gems in the Gem installation.
|
581
|
+
|
582
|
+
def self.latest_load_paths
|
583
|
+
result = []
|
584
|
+
|
585
|
+
Gem.path.each do |gemdir|
|
586
|
+
each_load_path(latest_partials(gemdir)) do |load_path|
|
587
|
+
result << load_path
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
result
|
592
|
+
end
|
593
|
+
|
594
|
+
##
|
595
|
+
# Return only the latest partial paths in the given +gemdir+.
|
596
|
+
|
597
|
+
def self.latest_partials(gemdir)
|
598
|
+
latest = {}
|
599
|
+
all_partials(gemdir).each do |gp|
|
600
|
+
base = File.basename(gp)
|
601
|
+
if base =~ /(.*)-((\d+\.)*\d+)/ then
|
602
|
+
name, version = $1, $2
|
603
|
+
ver = Gem::Version.new(version)
|
604
|
+
if latest[name].nil? || ver > latest[name][0]
|
605
|
+
latest[name] = [ver, gp]
|
606
|
+
end
|
607
|
+
end
|
608
|
+
end
|
609
|
+
latest.collect { |k,v| v[1] }
|
610
|
+
end
|
611
|
+
|
612
|
+
private_class_method :latest_partials
|
613
|
+
|
614
|
+
##
|
615
|
+
# The index to insert activated gem paths into the $LOAD_PATH.
|
616
|
+
#
|
617
|
+
# Defaults to the site lib directory unless gem_prelude.rb has loaded paths,
|
618
|
+
# then it inserts the activated gem's paths before the gem_prelude.rb paths
|
619
|
+
# so you can override the gem_prelude.rb default $LOAD_PATH paths.
|
620
|
+
|
621
|
+
def self.load_path_insert_index
|
622
|
+
index = $LOAD_PATH.index ConfigMap[:sitelibdir]
|
623
|
+
end
|
624
|
+
|
625
|
+
def self.remove_prelude_paths
|
626
|
+
Gem::QuickLoader::GemLoadPaths.each do |path|
|
627
|
+
$LOAD_PATH.delete(path)
|
628
|
+
end
|
629
|
+
end
|
630
|
+
|
631
|
+
##
|
632
|
+
# Loads YAML, preferring Psych
|
633
|
+
|
634
|
+
def self.load_yaml
|
635
|
+
require 'psych'
|
636
|
+
rescue ::LoadError
|
637
|
+
ensure
|
638
|
+
require 'yaml'
|
639
|
+
end
|
640
|
+
|
641
|
+
##
|
642
|
+
# The file name and line number of the caller of the caller of this method.
|
643
|
+
|
644
|
+
def self.location_of_caller
|
645
|
+
caller[1] =~ /(.*?):(\d+).*?$/i
|
646
|
+
file = $1
|
647
|
+
lineno = $2.to_i
|
648
|
+
|
649
|
+
[file, lineno]
|
650
|
+
end
|
651
|
+
|
652
|
+
##
|
653
|
+
# The version of the Marshal format for your Ruby.
|
654
|
+
|
655
|
+
def self.marshal_version
|
656
|
+
"#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
|
657
|
+
end
|
658
|
+
|
659
|
+
##
|
660
|
+
# Array of paths to search for Gems.
|
661
|
+
|
662
|
+
def self.path
|
663
|
+
@gem_path ||= nil
|
664
|
+
|
665
|
+
unless @gem_path then
|
666
|
+
paths = [ENV['GEM_PATH'] || Gem.configuration.path || default_path]
|
667
|
+
|
668
|
+
if defined?(APPLE_GEM_HOME) and not ENV['GEM_PATH'] then
|
669
|
+
paths << APPLE_GEM_HOME
|
670
|
+
end
|
671
|
+
|
672
|
+
set_paths paths.compact.join(File::PATH_SEPARATOR)
|
673
|
+
end
|
674
|
+
|
675
|
+
@gem_path
|
676
|
+
end
|
677
|
+
|
678
|
+
##
|
679
|
+
# Set array of platforms this SlimGems supports (primarily for testing).
|
680
|
+
|
681
|
+
def self.platforms=(platforms)
|
682
|
+
@platforms = platforms
|
683
|
+
end
|
684
|
+
|
685
|
+
##
|
686
|
+
# Array of platforms this SlimGems supports.
|
687
|
+
|
688
|
+
def self.platforms
|
689
|
+
@platforms ||= []
|
690
|
+
if @platforms.empty?
|
691
|
+
@platforms = [Gem::Platform::RUBY, Gem::Platform.local]
|
692
|
+
end
|
693
|
+
@platforms
|
694
|
+
end
|
695
|
+
|
696
|
+
##
|
697
|
+
# Adds a post-build hook that will be passed an Gem::Installer instance
|
698
|
+
# when Gem::Installer#install is called. The hook is called after the gem
|
699
|
+
# has been extracted and extensions have been built but before the
|
700
|
+
# executables or gemspec has been written. If the hook returns +false+ then
|
701
|
+
# the gem's files will be removed and the install will be aborted.
|
702
|
+
|
703
|
+
def self.post_build(&hook)
|
704
|
+
@post_build_hooks << hook
|
705
|
+
end
|
706
|
+
|
707
|
+
##
|
708
|
+
# Adds a post-install hook that will be passed an Gem::Installer instance
|
709
|
+
# when Gem::Installer#install is called
|
710
|
+
|
711
|
+
def self.post_install(&hook)
|
712
|
+
@post_install_hooks << hook
|
713
|
+
end
|
714
|
+
|
715
|
+
##
|
716
|
+
# Adds a post-uninstall hook that will be passed a Gem::Uninstaller instance
|
717
|
+
# and the spec that was uninstalled when Gem::Uninstaller#uninstall is
|
718
|
+
# called
|
719
|
+
|
720
|
+
def self.post_uninstall(&hook)
|
721
|
+
@post_uninstall_hooks << hook
|
722
|
+
end
|
723
|
+
|
724
|
+
##
|
725
|
+
# Adds a pre-install hook that will be passed an Gem::Installer instance
|
726
|
+
# when Gem::Installer#install is called
|
727
|
+
|
728
|
+
def self.pre_install(&hook)
|
729
|
+
@pre_install_hooks << hook
|
730
|
+
end
|
731
|
+
|
732
|
+
##
|
733
|
+
# Adds a pre-uninstall hook that will be passed an Gem::Uninstaller instance
|
734
|
+
# and the spec that will be uninstalled when Gem::Uninstaller#uninstall is
|
735
|
+
# called
|
736
|
+
|
737
|
+
def self.pre_uninstall(&hook)
|
738
|
+
@pre_uninstall_hooks << hook
|
739
|
+
end
|
740
|
+
|
741
|
+
##
|
742
|
+
# The directory prefix this SlimGems was installed at.
|
743
|
+
|
744
|
+
def self.prefix
|
745
|
+
dir = File.dirname File.expand_path(__FILE__)
|
746
|
+
prefix = File.dirname dir
|
747
|
+
|
748
|
+
if prefix == File.expand_path(ConfigMap[:sitelibdir]) or
|
749
|
+
prefix == File.expand_path(ConfigMap[:libdir]) or
|
750
|
+
'lib' != File.basename(dir) then
|
751
|
+
nil
|
752
|
+
else
|
753
|
+
prefix
|
754
|
+
end
|
755
|
+
end
|
756
|
+
|
757
|
+
##
|
758
|
+
# Promotes the load paths of the +gem_name+ over the load paths of
|
759
|
+
# +over_name+. Useful for allowing one gem to override features in another
|
760
|
+
# using #find_files.
|
761
|
+
|
762
|
+
def self.promote_load_path(gem_name, over_name)
|
763
|
+
gem = Gem.loaded_specs[gem_name]
|
764
|
+
over = Gem.loaded_specs[over_name]
|
765
|
+
|
766
|
+
raise ArgumentError, "gem #{gem_name} is not activated" if gem.nil?
|
767
|
+
raise ArgumentError, "gem #{over_name} is not activated" if over.nil?
|
768
|
+
|
769
|
+
last_gem_path = File.join gem.full_gem_path, gem.require_paths.last
|
770
|
+
|
771
|
+
over_paths = over.require_paths.map do |path|
|
772
|
+
File.join over.full_gem_path, path
|
773
|
+
end
|
774
|
+
|
775
|
+
over_paths.each do |path|
|
776
|
+
$LOAD_PATH.delete path
|
777
|
+
end
|
778
|
+
|
779
|
+
gem = $LOAD_PATH.index(last_gem_path) + 1
|
780
|
+
|
781
|
+
$LOAD_PATH.insert(gem, *over_paths)
|
782
|
+
end
|
783
|
+
|
784
|
+
##
|
785
|
+
# Refresh source_index from disk and clear searcher.
|
786
|
+
|
787
|
+
def self.refresh
|
788
|
+
source_index.refresh!
|
789
|
+
|
790
|
+
@searcher = nil
|
791
|
+
end
|
792
|
+
|
793
|
+
##
|
794
|
+
# Safely read a file in binary mode on all platforms.
|
795
|
+
|
796
|
+
def self.read_binary(path)
|
797
|
+
File.open path, binary_mode do |f| f.read end
|
798
|
+
end
|
799
|
+
|
800
|
+
##
|
801
|
+
# Report a load error during activation. The message of load error
|
802
|
+
# depends on whether it was a version mismatch or if there are not gems of
|
803
|
+
# any version by the requested name.
|
804
|
+
|
805
|
+
def self.report_activate_error(gem)
|
806
|
+
matches = Gem.source_index.find_name(gem.name)
|
807
|
+
|
808
|
+
if matches.empty? then
|
809
|
+
error = Gem::LoadError.new(
|
810
|
+
"Could not find RubyGem #{gem.name} (#{gem.requirement})\n")
|
811
|
+
else
|
812
|
+
error = Gem::LoadError.new(
|
813
|
+
"RubyGem version error: " +
|
814
|
+
"#{gem.name}(#{matches.first.version} not #{gem.requirement})\n")
|
815
|
+
end
|
816
|
+
|
817
|
+
error.name = gem.name
|
818
|
+
error.version_requirement = gem.requirement
|
819
|
+
raise error
|
820
|
+
end
|
821
|
+
|
822
|
+
private_class_method :report_activate_error
|
823
|
+
|
824
|
+
##
|
825
|
+
# Full path to +libfile+ in +gemname+. Searches for the latest gem unless
|
826
|
+
# +requirements+ is given.
|
827
|
+
|
828
|
+
def self.required_location(gemname, libfile, *requirements)
|
829
|
+
requirements = Gem::Requirement.default if requirements.empty?
|
830
|
+
|
831
|
+
matches = Gem.source_index.find_name gemname, requirements
|
832
|
+
|
833
|
+
return nil if matches.empty?
|
834
|
+
|
835
|
+
spec = matches.last
|
836
|
+
spec.require_paths.each do |path|
|
837
|
+
result = File.join spec.full_gem_path, path, libfile
|
838
|
+
return result if File.exist? result
|
839
|
+
end
|
840
|
+
|
841
|
+
nil
|
842
|
+
end
|
843
|
+
|
844
|
+
##
|
845
|
+
# The path to the running Ruby interpreter.
|
846
|
+
|
847
|
+
def self.ruby
|
848
|
+
if @ruby.nil? then
|
849
|
+
@ruby = File.join(ConfigMap[:bindir],
|
850
|
+
ConfigMap[:ruby_install_name])
|
851
|
+
@ruby << ConfigMap[:EXEEXT]
|
852
|
+
|
853
|
+
# escape string in case path to ruby executable contain spaces.
|
854
|
+
@ruby.sub!(/.*\s.*/m, '"\&"')
|
855
|
+
end
|
856
|
+
|
857
|
+
@ruby
|
858
|
+
end
|
859
|
+
|
860
|
+
##
|
861
|
+
# A Gem::Version for the currently running ruby.
|
862
|
+
|
863
|
+
def self.ruby_version
|
864
|
+
return @ruby_version if defined? @ruby_version
|
865
|
+
version = RUBY_VERSION.dup
|
866
|
+
|
867
|
+
if defined?(RUBY_PATCHLEVEL) && RUBY_PATCHLEVEL != -1 then
|
868
|
+
version << ".#{RUBY_PATCHLEVEL}"
|
869
|
+
elsif defined?(RUBY_REVISION) then
|
870
|
+
version << ".dev.#{RUBY_REVISION}"
|
871
|
+
end
|
872
|
+
|
873
|
+
@ruby_version = Gem::Version.new version
|
874
|
+
end
|
875
|
+
|
876
|
+
##
|
877
|
+
# The GemPathSearcher object used to search for matching installed gems.
|
878
|
+
|
879
|
+
def self.searcher
|
880
|
+
@searcher ||= Gem::GemPathSearcher.new
|
881
|
+
end
|
882
|
+
|
883
|
+
##
|
884
|
+
# Set the Gem home directory (as reported by Gem.dir).
|
885
|
+
|
886
|
+
def self.set_home(home)
|
887
|
+
home = home.gsub File::ALT_SEPARATOR, File::SEPARATOR if File::ALT_SEPARATOR
|
888
|
+
@gem_home = home
|
889
|
+
end
|
890
|
+
|
891
|
+
private_class_method :set_home
|
892
|
+
|
893
|
+
##
|
894
|
+
# Set the Gem search path (as reported by Gem.path).
|
895
|
+
|
896
|
+
def self.set_paths(gpaths)
|
897
|
+
if gpaths
|
898
|
+
@gem_path = gpaths.split(File::PATH_SEPARATOR)
|
899
|
+
|
900
|
+
if File::ALT_SEPARATOR then
|
901
|
+
@gem_path.map! do |path|
|
902
|
+
path.gsub File::ALT_SEPARATOR, File::SEPARATOR
|
903
|
+
end
|
904
|
+
end
|
905
|
+
|
906
|
+
@gem_path << Gem.dir
|
907
|
+
else
|
908
|
+
# TODO: should this be Gem.default_path instead?
|
909
|
+
@gem_path = [Gem.dir]
|
910
|
+
end
|
911
|
+
|
912
|
+
@gem_path.uniq!
|
913
|
+
end
|
914
|
+
|
915
|
+
private_class_method :set_paths
|
916
|
+
|
917
|
+
##
|
918
|
+
# Returns the Gem::SourceIndex of specifications that are in the Gem.path
|
919
|
+
|
920
|
+
def self.source_index
|
921
|
+
@@source_index ||= SourceIndex.from_installed_gems
|
922
|
+
end
|
923
|
+
|
924
|
+
##
|
925
|
+
# Returns an Array of sources to fetch remote gems from. If the sources
|
926
|
+
# list is empty, attempts to load the "sources" gem, then uses
|
927
|
+
# default_sources if it is not installed.
|
928
|
+
|
929
|
+
def self.sources
|
930
|
+
if !@sources || @sources.empty? then
|
931
|
+
@sources = default_sources
|
932
|
+
end
|
933
|
+
|
934
|
+
@sources
|
935
|
+
end
|
936
|
+
|
937
|
+
##
|
938
|
+
# Need to be able to set the sources without calling
|
939
|
+
# Gem.sources.replace since that would cause an infinite loop.
|
940
|
+
|
941
|
+
def self.sources=(new_sources)
|
942
|
+
@sources = new_sources
|
943
|
+
end
|
944
|
+
|
945
|
+
##
|
946
|
+
# Glob pattern for require-able path suffixes.
|
947
|
+
|
948
|
+
def self.suffix_pattern
|
949
|
+
@suffix_pattern ||= "{#{suffixes.join(',')}}"
|
950
|
+
end
|
951
|
+
|
952
|
+
##
|
953
|
+
# Suffixes for require-able paths.
|
954
|
+
|
955
|
+
def self.suffixes
|
956
|
+
['', '.rb', '.rbw', '.so', '.bundle', '.dll', '.sl', '.jar']
|
957
|
+
end
|
958
|
+
|
959
|
+
##
|
960
|
+
# Prints the amount of time the supplied block takes to run using the debug
|
961
|
+
# UI output.
|
962
|
+
|
963
|
+
def self.time(msg, width = 0, display = Gem.configuration.verbose)
|
964
|
+
now = Time.now
|
965
|
+
|
966
|
+
value = yield
|
967
|
+
|
968
|
+
elapsed = Time.now - now
|
969
|
+
|
970
|
+
ui.say "%2$*1$s: %3$3.3fs" % [-width, msg, elapsed] if display
|
971
|
+
|
972
|
+
value
|
973
|
+
end
|
974
|
+
|
975
|
+
##
|
976
|
+
# Lazily loads DefaultUserInteraction and returns the default UI.
|
977
|
+
|
978
|
+
def self.ui
|
979
|
+
require 'rubygems/user_interaction'
|
980
|
+
|
981
|
+
Gem::DefaultUserInteraction.ui
|
982
|
+
end
|
983
|
+
|
984
|
+
##
|
985
|
+
# Use the +home+ and +paths+ values for Gem.dir and Gem.path. Used mainly
|
986
|
+
# by the unit tests to provide environment isolation.
|
987
|
+
|
988
|
+
def self.use_paths(home, paths=[])
|
989
|
+
clear_paths
|
990
|
+
set_home(home) if home
|
991
|
+
set_paths(paths.join(File::PATH_SEPARATOR)) if paths
|
992
|
+
end
|
993
|
+
|
994
|
+
##
|
995
|
+
# The home directory for the user.
|
996
|
+
|
997
|
+
def self.user_home
|
998
|
+
@user_home ||= find_home
|
999
|
+
end
|
1000
|
+
|
1001
|
+
##
|
1002
|
+
# Is this a windows platform?
|
1003
|
+
|
1004
|
+
def self.win_platform?
|
1005
|
+
if @@win_platform.nil? then
|
1006
|
+
@@win_platform = !!WIN_PATTERNS.find { |r| RUBY_PLATFORM =~ r }
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
@@win_platform
|
1010
|
+
end
|
1011
|
+
|
1012
|
+
##
|
1013
|
+
# Find all 'rubygems_plugin' files and load them
|
1014
|
+
|
1015
|
+
def self.load_plugin_files(plugins)
|
1016
|
+
plugins.each do |plugin|
|
1017
|
+
|
1018
|
+
# Skip older versions of the GemCutter plugin: Its commands are in
|
1019
|
+
# SlimGems proper now.
|
1020
|
+
|
1021
|
+
next if plugin =~ /gemcutter-0\.[0-3]/
|
1022
|
+
|
1023
|
+
begin
|
1024
|
+
load plugin
|
1025
|
+
rescue ::Exception => e
|
1026
|
+
details = "#{plugin.inspect}: #{e.message} (#{e.class})"
|
1027
|
+
warn "Error loading #{Gem::NAME} plugin #{details}"
|
1028
|
+
end
|
1029
|
+
end
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
##
|
1033
|
+
# Find all 'rubygems_plugin' files in installed gems and load them
|
1034
|
+
|
1035
|
+
def self.load_plugins
|
1036
|
+
load_plugin_files find_files('rubygems_plugin', false)
|
1037
|
+
end
|
1038
|
+
|
1039
|
+
##
|
1040
|
+
# Find all 'rubygems_plugin' files in $LOAD_PATH and load them
|
1041
|
+
|
1042
|
+
def self.load_env_plugins
|
1043
|
+
path = "rubygems_plugin"
|
1044
|
+
|
1045
|
+
files = []
|
1046
|
+
$LOAD_PATH.each do |load_path|
|
1047
|
+
globbed = Dir["#{File.expand_path path, load_path}#{Gem.suffix_pattern}"]
|
1048
|
+
|
1049
|
+
globbed.each do |load_path_file|
|
1050
|
+
files << load_path_file if File.file?(load_path_file.untaint)
|
1051
|
+
end
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
load_plugin_files files
|
1055
|
+
end
|
1056
|
+
|
1057
|
+
class << self
|
1058
|
+
|
1059
|
+
##
|
1060
|
+
# Hash of loaded Gem::Specification keyed by name
|
1061
|
+
|
1062
|
+
attr_reader :loaded_specs
|
1063
|
+
|
1064
|
+
##
|
1065
|
+
# The list of hooks to be run before Gem::Install#install finishes
|
1066
|
+
# installation
|
1067
|
+
|
1068
|
+
attr_reader :post_build_hooks
|
1069
|
+
|
1070
|
+
##
|
1071
|
+
# The list of hooks to be run before Gem::Install#install does any work
|
1072
|
+
|
1073
|
+
attr_reader :post_install_hooks
|
1074
|
+
|
1075
|
+
##
|
1076
|
+
# The list of hooks to be run before Gem::Uninstall#uninstall does any
|
1077
|
+
# work
|
1078
|
+
|
1079
|
+
attr_reader :post_uninstall_hooks
|
1080
|
+
|
1081
|
+
##
|
1082
|
+
# The list of hooks to be run after Gem::Install#install is finished
|
1083
|
+
|
1084
|
+
attr_reader :pre_install_hooks
|
1085
|
+
|
1086
|
+
##
|
1087
|
+
# The list of hooks to be run after Gem::Uninstall#uninstall is finished
|
1088
|
+
|
1089
|
+
attr_reader :pre_uninstall_hooks
|
1090
|
+
|
1091
|
+
# :stopdoc:
|
1092
|
+
|
1093
|
+
alias cache source_index # an alias for the old name
|
1094
|
+
|
1095
|
+
# :startdoc:
|
1096
|
+
|
1097
|
+
end
|
1098
|
+
|
1099
|
+
##
|
1100
|
+
# Location of Marshal quick gemspecs on remote repositories
|
1101
|
+
|
1102
|
+
MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/"
|
1103
|
+
|
1104
|
+
##
|
1105
|
+
# Location of legacy YAML quick gemspecs on remote repositories
|
1106
|
+
|
1107
|
+
YAML_SPEC_DIR = 'quick/'
|
1108
|
+
|
1109
|
+
root = ''
|
1110
|
+
autoload :Version, 'rubygems/version'
|
1111
|
+
autoload :Requirement, 'rubygems/requirement'
|
1112
|
+
autoload :Dependency, 'rubygems/dependency'
|
1113
|
+
autoload :GemPathSearcher, 'rubygems/gem_path_searcher'
|
1114
|
+
autoload :SpecFetcher, 'rubygems/spec_fetcher'
|
1115
|
+
autoload :UserInteraction, 'rubygems/user_interaction'
|
1116
|
+
autoload :Specification, 'rubygems/specification'
|
1117
|
+
autoload :Cache, 'rubygems/source_index'
|
1118
|
+
autoload :SourceIndex, 'rubygems/source_index'
|
1119
|
+
autoload :Platform, 'rubygems/platform'
|
1120
|
+
autoload :Builder, 'rubygems/builder'
|
1121
|
+
autoload :ConfigFile, 'rubygems/config_file'
|
1122
|
+
end
|
1123
|
+
|
1124
|
+
module ::Kernel
|
1125
|
+
|
1126
|
+
remove_method :gem if respond_to?(:gem, true) # defined in gem_prelude.rb on 1.9
|
1127
|
+
|
1128
|
+
##
|
1129
|
+
# Use Kernel#gem to activate a specific version of +gem_name+.
|
1130
|
+
#
|
1131
|
+
# +version_requirements+ is a list of version requirements that the
|
1132
|
+
# specified gem must match, most commonly "= example.version.number". See
|
1133
|
+
# Gem::Requirement for how to specify a version requirement.
|
1134
|
+
#
|
1135
|
+
# If you will be activating the latest version of a gem, there is no need to
|
1136
|
+
# call Kernel#gem, Kernel#require will do the right thing for you.
|
1137
|
+
#
|
1138
|
+
# Kernel#gem returns true if the gem was activated, otherwise false. If the
|
1139
|
+
# gem could not be found, didn't match the version requirements, or a
|
1140
|
+
# different version was already activated, an exception will be raised.
|
1141
|
+
#
|
1142
|
+
# Kernel#gem should be called *before* any require statements (otherwise
|
1143
|
+
# SlimGems may load a conflicting library version).
|
1144
|
+
#
|
1145
|
+
# In older SlimGems versions, the environment variable GEM_SKIP could be
|
1146
|
+
# used to skip activation of specified gems, for example to test out changes
|
1147
|
+
# that haven't been installed yet. Now SlimGems defers to -I and the
|
1148
|
+
# RUBYLIB environment variable to skip activation of a gem.
|
1149
|
+
#
|
1150
|
+
# Example:
|
1151
|
+
#
|
1152
|
+
# GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb
|
1153
|
+
|
1154
|
+
def gem(gem_name, *version_requirements) # :doc:
|
1155
|
+
skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
|
1156
|
+
raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
|
1157
|
+
Gem.activate(gem_name, *version_requirements)
|
1158
|
+
end
|
1159
|
+
|
1160
|
+
private :gem
|
1161
|
+
|
1162
|
+
end
|
1163
|
+
|
1164
|
+
##
|
1165
|
+
# Return the path to the data directory associated with the named package. If
|
1166
|
+
# the package is loaded as a gem, return the gem specific data directory.
|
1167
|
+
# Otherwise return a path to the share area as define by
|
1168
|
+
# "#{ConfigMap[:datadir]}/#{package_name}".
|
1169
|
+
|
1170
|
+
def RbConfig.datadir(package_name)
|
1171
|
+
Gem.datadir(package_name) ||
|
1172
|
+
File.join(Gem::ConfigMap[:datadir], package_name)
|
1173
|
+
end
|
1174
|
+
|
1175
|
+
require 'rubygems/exceptions'
|
1176
|
+
|
1177
|
+
begin
|
1178
|
+
##
|
1179
|
+
# Defaults the operating system (or packager) wants to provide for SlimGems.
|
1180
|
+
|
1181
|
+
require 'rubygems/defaults/operating_system'
|
1182
|
+
rescue LoadError
|
1183
|
+
end
|
1184
|
+
|
1185
|
+
if defined?(RUBY_ENGINE) then
|
1186
|
+
begin
|
1187
|
+
##
|
1188
|
+
# Defaults the ruby implementation wants to provide for SlimGems
|
1189
|
+
|
1190
|
+
require "rubygems/defaults/#{RUBY_ENGINE}"
|
1191
|
+
rescue LoadError
|
1192
|
+
end
|
1193
|
+
end
|
1194
|
+
|
1195
|
+
require 'rubygems/config_file'
|
1196
|
+
|
1197
|
+
class << Gem
|
1198
|
+
remove_method :try_activate if Gem.respond_to?(:try_activate, true)
|
1199
|
+
|
1200
|
+
def try_activate(path)
|
1201
|
+
spec = Gem.searcher.find(path)
|
1202
|
+
return false unless spec
|
1203
|
+
|
1204
|
+
Gem.activate(spec.name, "= #{spec.version}")
|
1205
|
+
return true
|
1206
|
+
end
|
1207
|
+
end
|
1208
|
+
|
1209
|
+
##
|
1210
|
+
# Enables the require hook for SlimGems.
|
1211
|
+
#
|
1212
|
+
# if --disable-rubygems was used, then the prelude wasn't loaded, so
|
1213
|
+
# we need to load the custom_require now.
|
1214
|
+
|
1215
|
+
if gem_disabled
|
1216
|
+
require 'rubygems/custom_require'
|
1217
|
+
end
|
1218
|
+
|
1219
|
+
Gem.clear_paths
|
1220
|
+
|