rubygems-update 2.0.17 → 2.1.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -0
- data/.autotest +1 -1
- data/History.txt +82 -153
- data/Manifest.txt +35 -9
- data/Rakefile +35 -36
- data/lib/rubygems.rb +106 -18
- data/lib/rubygems/available_set.rb +68 -0
- data/lib/rubygems/basic_specification.rb +139 -0
- data/lib/rubygems/command_manager.rb +37 -40
- data/lib/rubygems/commands/cert_command.rb +78 -29
- data/lib/rubygems/commands/cleanup_command.rb +2 -2
- data/lib/rubygems/commands/contents_command.rb +101 -58
- data/lib/rubygems/commands/dependency_command.rb +94 -53
- data/lib/rubygems/commands/environment_command.rb +70 -53
- data/lib/rubygems/commands/fetch_command.rb +1 -2
- data/lib/rubygems/commands/help_command.rb +85 -55
- data/lib/rubygems/commands/install_command.rb +84 -42
- data/lib/rubygems/commands/outdated_command.rb +2 -12
- data/lib/rubygems/commands/owner_command.rb +6 -0
- data/lib/rubygems/commands/pristine_command.rb +26 -16
- data/lib/rubygems/commands/sources_command.rb +85 -70
- data/lib/rubygems/commands/uninstall_command.rb +32 -2
- data/lib/rubygems/commands/update_command.rb +111 -75
- data/lib/rubygems/config_file.rb +15 -3
- data/lib/rubygems/core_ext/kernel_require.rb +9 -31
- data/lib/rubygems/defaults.rb +8 -0
- data/lib/rubygems/dependency.rb +4 -2
- data/lib/rubygems/dependency_installer.rb +180 -170
- data/lib/rubygems/dependency_resolver.rb +191 -526
- data/lib/rubygems/dependency_resolver/activation_request.rb +109 -0
- data/lib/rubygems/dependency_resolver/api_set.rb +65 -0
- data/lib/rubygems/dependency_resolver/api_specification.rb +36 -0
- data/lib/rubygems/dependency_resolver/composed_set.rb +18 -0
- data/lib/rubygems/dependency_resolver/current_set.rb +16 -0
- data/lib/rubygems/dependency_resolver/dependency_conflict.rb +85 -0
- data/lib/rubygems/dependency_resolver/dependency_request.rb +51 -0
- data/lib/rubygems/dependency_resolver/index_set.rb +59 -0
- data/lib/rubygems/dependency_resolver/index_specification.rb +53 -0
- data/lib/rubygems/dependency_resolver/installed_specification.rb +38 -0
- data/lib/rubygems/dependency_resolver/installer_set.rb +130 -0
- data/lib/rubygems/exceptions.rb +88 -1
- data/lib/rubygems/ext/builder.rb +1 -1
- data/lib/rubygems/gem_runner.rb +17 -9
- data/lib/rubygems/gemcutter_utilities.rb +72 -42
- data/lib/rubygems/install_default_message.rb +12 -0
- data/lib/rubygems/install_update_options.rb +3 -0
- data/lib/rubygems/installer.rb +55 -30
- data/lib/rubygems/name_tuple.rb +18 -7
- data/lib/rubygems/package.rb +50 -25
- data/lib/rubygems/package/tar_test_case.rb +9 -9
- data/lib/rubygems/package/tar_writer.rb +35 -12
- data/lib/rubygems/package_task.rb +2 -5
- data/lib/rubygems/path_support.rb +10 -0
- data/lib/rubygems/platform.rb +9 -3
- data/lib/rubygems/psych_additions.rb +1 -1
- data/lib/rubygems/remote_fetcher.rb +9 -276
- data/lib/rubygems/request.rb +267 -0
- data/lib/rubygems/request_set.rb +123 -125
- data/lib/rubygems/request_set/gem_dependency_api.rb +39 -0
- data/lib/rubygems/security.rb +32 -23
- data/lib/rubygems/security/policy.rb +35 -9
- data/lib/rubygems/security/signer.rb +2 -2
- data/lib/rubygems/server.rb +8 -16
- data/lib/rubygems/source.rb +25 -14
- data/lib/rubygems/source/installed.rb +28 -0
- data/lib/rubygems/source/local.rb +122 -0
- data/lib/rubygems/source/specific_file.rb +28 -0
- data/lib/rubygems/source_local.rb +2 -89
- data/lib/rubygems/source_specific_file.rb +2 -26
- data/lib/rubygems/spec_fetcher.rb +11 -11
- data/lib/rubygems/specification.rb +186 -198
- data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +88 -30
- data/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +90 -0
- data/lib/rubygems/ssl_certs/{GeoTrustGlobalCA.pem → GeoTrust_Global_CA.pem} +20 -20
- data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
- data/lib/rubygems/stub_specification.rb +119 -0
- data/lib/rubygems/test_case.rb +117 -49
- data/lib/rubygems/uninstaller.rb +14 -9
- data/lib/rubygems/uri_formatter.rb +39 -0
- data/lib/rubygems/util/list.rb +44 -0
- data/lib/rubygems/version.rb +15 -5
- data/lib/rubygems/version_option.rb +8 -2
- data/test/rubygems/ca_cert.pem +23 -0
- data/test/rubygems/client.pem +49 -0
- data/test/rubygems/encrypted_private_key.pem +30 -0
- data/test/rubygems/invalid_client.pem +49 -0
- data/test/rubygems/specifications/bar-0.0.2.gemspec +9 -0
- data/test/rubygems/specifications/foo-0.0.1.gemspec +0 -0
- data/test/rubygems/test_gem.rb +76 -454
- data/test/rubygems/test_gem_command_manager.rb +23 -21
- data/test/rubygems/test_gem_commands_cert_command.rb +154 -14
- data/test/rubygems/test_gem_commands_cleanup_command.rb +15 -0
- data/test/rubygems/test_gem_commands_contents_command.rb +32 -4
- data/test/rubygems/test_gem_commands_environment_command.rb +9 -1
- data/test/rubygems/test_gem_commands_fetch_command.rb +2 -28
- data/test/rubygems/test_gem_commands_help_command.rb +6 -3
- data/test/rubygems/test_gem_commands_install_command.rb +2 -65
- data/test/rubygems/test_gem_commands_owner_command.rb +49 -0
- data/test/rubygems/test_gem_commands_pristine_command.rb +30 -0
- data/test/rubygems/test_gem_commands_sources_command.rb +1 -1
- data/test/rubygems/test_gem_commands_uninstall_command.rb +33 -0
- data/test/rubygems/test_gem_commands_update_command.rb +2 -1
- data/test/rubygems/test_gem_config_file.rb +12 -0
- data/test/rubygems/test_gem_dependency_installer.rb +58 -65
- data/test/rubygems/test_gem_dependency_resolver.rb +6 -3
- data/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb +36 -0
- data/test/rubygems/test_gem_ext_builder.rb +2 -4
- data/test/rubygems/test_gem_ext_ext_conf_builder.rb +7 -2
- data/test/rubygems/test_gem_gem_runner.rb +17 -13
- data/test/rubygems/test_gem_gemcutter_utilities.rb +6 -19
- data/test/rubygems/test_gem_impossible_dependencies_error.rb +41 -0
- data/test/rubygems/test_gem_install_update_options.rb +4 -1
- data/test/rubygems/test_gem_installer.rb +31 -2
- data/test/rubygems/test_gem_name_tuple.rb +22 -0
- data/test/rubygems/test_gem_package.rb +122 -11
- data/test/rubygems/test_gem_package_old.rb +8 -0
- data/test/rubygems/test_gem_package_tar_reader.rb +9 -8
- data/test/rubygems/test_gem_package_tar_reader_entry.rb +1 -1
- data/test/rubygems/test_gem_package_tar_writer.rb +78 -56
- data/test/rubygems/test_gem_package_task.rb +2 -23
- data/test/rubygems/test_gem_path_support.rb +17 -0
- data/test/rubygems/test_gem_platform.rb +18 -0
- data/test/rubygems/test_gem_remote_fetcher.rb +106 -385
- data/test/rubygems/test_gem_request.rb +239 -0
- data/test/rubygems/test_gem_requirement.rb +9 -11
- data/test/rubygems/test_gem_security.rb +58 -2
- data/test/rubygems/test_gem_security_policy.rb +42 -1
- data/test/rubygems/test_gem_security_signer.rb +13 -1
- data/test/rubygems/test_gem_security_trust_dir.rb +5 -1
- data/test/rubygems/test_gem_server.rb +1 -105
- data/test/rubygems/test_gem_source.rb +4 -14
- data/test/rubygems/test_gem_source_local.rb +4 -4
- data/test/rubygems/test_gem_source_specific_file.rb +1 -1
- data/test/rubygems/test_gem_spec_fetcher.rb +0 -12
- data/test/rubygems/test_gem_specification.rb +452 -28
- data/test/rubygems/test_gem_stub_specification.rb +30 -0
- data/test/rubygems/test_gem_uninstaller.rb +14 -0
- data/test/rubygems/test_gem_uri_formatter.rb +20 -0
- data/test/rubygems/test_gem_version.rb +23 -13
- data/test/rubygems/test_gem_version_option.rb +63 -1
- data/test/rubygems/test_require.rb +0 -12
- data/util/create_encrypted_key.rb +16 -0
- metadata +161 -23
- metadata.gz.sig +0 -0
- data/CVE-2013-4287.txt +0 -36
- data/CVE-2013-4363.txt +0 -45
- data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
- data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
- data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
- data/test/rubygems/test_bundled_ca.rb +0 -59
- data/util/update_bundled_ca_certificates.rb +0 -103
data/lib/rubygems.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
require 'rbconfig'
|
9
9
|
|
10
10
|
module Gem
|
11
|
-
VERSION = '2.0.
|
11
|
+
VERSION = '2.1.0.rc.1'
|
12
12
|
end
|
13
13
|
|
14
14
|
# Must be first since it unloads the prelude from 1.9.2
|
@@ -36,9 +36,9 @@ require 'rubygems/errors'
|
|
36
36
|
#
|
37
37
|
# Further RubyGems documentation can be found at:
|
38
38
|
#
|
39
|
-
# * {RubyGems Guides}[http://guides.rubygems.org]
|
40
39
|
# * {RubyGems API}[http://rubygems.rubyforge.org/rdoc] (also available from
|
41
40
|
# <tt>gem server</tt>)
|
41
|
+
# * {RubyGems Bookshelf}[http://rubygem.org]
|
42
42
|
#
|
43
43
|
# == RubyGems Plugins
|
44
44
|
#
|
@@ -115,7 +115,7 @@ module Gem
|
|
115
115
|
RUBYGEMS_DIR = File.dirname File.expand_path(__FILE__)
|
116
116
|
|
117
117
|
##
|
118
|
-
# An Array of Regexps that match windows
|
118
|
+
# An Array of Regexps that match windows Ruby platforms.
|
119
119
|
|
120
120
|
WIN_PATTERNS = [
|
121
121
|
/bccwin/i,
|
@@ -143,6 +143,14 @@ module Gem
|
|
143
143
|
specifications
|
144
144
|
]
|
145
145
|
|
146
|
+
##
|
147
|
+
# Subdirectories in a gem repository for default gems
|
148
|
+
|
149
|
+
REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES = %w[
|
150
|
+
gems
|
151
|
+
specifications/default
|
152
|
+
]
|
153
|
+
|
146
154
|
@@win_platform = nil
|
147
155
|
|
148
156
|
@configuration = nil
|
@@ -307,7 +315,7 @@ module Gem
|
|
307
315
|
@paths = nil
|
308
316
|
@user_home = nil
|
309
317
|
Gem::Specification.reset
|
310
|
-
Gem::Security.reset if
|
318
|
+
Gem::Security.reset if const_defined? :Security
|
311
319
|
end
|
312
320
|
|
313
321
|
##
|
@@ -379,6 +387,10 @@ module Gem
|
|
379
387
|
paths.path
|
380
388
|
end
|
381
389
|
|
390
|
+
def self.spec_cache_dir
|
391
|
+
paths.spec_cache_dir
|
392
|
+
end
|
393
|
+
|
382
394
|
##
|
383
395
|
# Quietly ensure the Gem directory +dir+ contains all the proper
|
384
396
|
# subdirectories. If we can't create a directory due to a permission
|
@@ -389,6 +401,23 @@ module Gem
|
|
389
401
|
# World-writable directories will never be created.
|
390
402
|
|
391
403
|
def self.ensure_gem_subdirectories dir = Gem.dir, mode = nil
|
404
|
+
ensure_subdirectories(dir, mode, REPOSITORY_SUBDIRECTORIES)
|
405
|
+
end
|
406
|
+
|
407
|
+
##
|
408
|
+
# Quietly ensure the Gem directory +dir+ contains all the proper
|
409
|
+
# subdirectories for handling default gems. If we can't create a
|
410
|
+
# directory due to a permission problem, then we will silently continue.
|
411
|
+
#
|
412
|
+
# If +mode+ is given, missing directories are created with this mode.
|
413
|
+
#
|
414
|
+
# World-writable directories will never be created.
|
415
|
+
|
416
|
+
def self.ensure_default_gem_subdirectories dir = Gem.dir, mode = nil
|
417
|
+
ensure_subdirectories(dir, mode, REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES)
|
418
|
+
end
|
419
|
+
|
420
|
+
def self.ensure_subdirectories dir, mode, subdirs # :nodoc:
|
392
421
|
old_umask = File.umask
|
393
422
|
File.umask old_umask | 002
|
394
423
|
|
@@ -398,7 +427,7 @@ module Gem
|
|
398
427
|
|
399
428
|
options[:mode] = mode if mode
|
400
429
|
|
401
|
-
|
430
|
+
subdirs.each do |name|
|
402
431
|
subdir = File.join dir, name
|
403
432
|
next if File.exist? subdir
|
404
433
|
FileUtils.mkdir_p subdir, options rescue nil
|
@@ -417,16 +446,12 @@ module Gem
|
|
417
446
|
# $LOAD_PATH for files as well as gems.
|
418
447
|
#
|
419
448
|
# Note that find_files will return all files even if they are from different
|
420
|
-
# versions of the same gem.
|
449
|
+
# versions of the same gem. See also find_latest_files
|
421
450
|
|
422
451
|
def self.find_files(glob, check_load_path=true)
|
423
452
|
files = []
|
424
453
|
|
425
|
-
if check_load_path
|
426
|
-
files = $LOAD_PATH.map { |load_path|
|
427
|
-
Dir["#{File.expand_path glob, load_path}#{Gem.suffix_pattern}"]
|
428
|
-
}.flatten.select { |file| File.file? file.untaint }
|
429
|
-
end
|
454
|
+
files = find_files_from_load_path glob if check_load_path
|
430
455
|
|
431
456
|
files.concat Gem::Specification.map { |spec|
|
432
457
|
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
|
@@ -439,6 +464,40 @@ module Gem
|
|
439
464
|
return files
|
440
465
|
end
|
441
466
|
|
467
|
+
def self.find_files_from_load_path glob # :nodoc:
|
468
|
+
$LOAD_PATH.map { |load_path|
|
469
|
+
Dir["#{File.expand_path glob, load_path}#{Gem.suffix_pattern}"]
|
470
|
+
}.flatten.select { |file| File.file? file.untaint }
|
471
|
+
end
|
472
|
+
|
473
|
+
##
|
474
|
+
# Returns a list of paths matching +glob+ from the latest gems that can be
|
475
|
+
# used by a gem to pick up features from other gems. For example:
|
476
|
+
#
|
477
|
+
# Gem.find_latest_files('rdoc/discover').each do |path| load path end
|
478
|
+
#
|
479
|
+
# if +check_load_path+ is true (the default), then find_latest_files also
|
480
|
+
# searches $LOAD_PATH for files as well as gems.
|
481
|
+
#
|
482
|
+
# Unlike find_files, find_latest_files will return only files from the
|
483
|
+
# latest version of a gem.
|
484
|
+
|
485
|
+
def self.find_latest_files(glob, check_load_path=true)
|
486
|
+
files = []
|
487
|
+
|
488
|
+
files = find_files_from_load_path glob if check_load_path
|
489
|
+
|
490
|
+
files.concat Gem::Specification.latest_specs(true).map { |spec|
|
491
|
+
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
|
492
|
+
}.flatten
|
493
|
+
|
494
|
+
# $LOAD_PATH might contain duplicate entries or reference
|
495
|
+
# the spec dirs directly, so we prune.
|
496
|
+
files.uniq! if check_load_path
|
497
|
+
|
498
|
+
return files
|
499
|
+
end
|
500
|
+
|
442
501
|
##
|
443
502
|
# Finds the user's home directory.
|
444
503
|
#--
|
@@ -793,7 +852,7 @@ module Gem
|
|
793
852
|
end
|
794
853
|
|
795
854
|
##
|
796
|
-
# A Gem::Version for the currently running
|
855
|
+
# A Gem::Version for the currently running Ruby.
|
797
856
|
|
798
857
|
def self.ruby_version
|
799
858
|
return @ruby_version if defined? @ruby_version
|
@@ -916,9 +975,9 @@ module Gem
|
|
916
975
|
end
|
917
976
|
|
918
977
|
##
|
919
|
-
# Load +plugins+ as
|
978
|
+
# Load +plugins+ as Ruby files
|
920
979
|
|
921
|
-
def self.load_plugin_files
|
980
|
+
def self.load_plugin_files plugins # :nodoc:
|
922
981
|
plugins.each do |plugin|
|
923
982
|
|
924
983
|
# Skip older versions of the GemCutter plugin: Its commands are in
|
@@ -936,10 +995,16 @@ module Gem
|
|
936
995
|
end
|
937
996
|
|
938
997
|
##
|
939
|
-
# Find
|
998
|
+
# Find the 'rubygems_plugin' files in the latest installed gems and load
|
999
|
+
# them
|
940
1000
|
|
941
1001
|
def self.load_plugins
|
942
|
-
|
1002
|
+
# Remove this env var by at least 3.0
|
1003
|
+
if ENV['RUBYGEMS_LOAD_ALL_PLUGINS']
|
1004
|
+
load_plugin_files find_files('rubygems_plugin', false)
|
1005
|
+
else
|
1006
|
+
load_plugin_files find_latest_files('rubygems_plugin', false)
|
1007
|
+
end
|
943
1008
|
end
|
944
1009
|
|
945
1010
|
##
|
@@ -971,10 +1036,33 @@ module Gem
|
|
971
1036
|
attr_reader :loaded_specs
|
972
1037
|
|
973
1038
|
##
|
974
|
-
# Register a Gem::Specification for default gem
|
1039
|
+
# Register a Gem::Specification for default gem.
|
1040
|
+
#
|
1041
|
+
# Two formats for the specification are supported:
|
1042
|
+
#
|
1043
|
+
# * MRI 2.0 style, where spec.files contains unprefixed require names.
|
1044
|
+
# The spec's filenames will be registered as-is.
|
1045
|
+
# * New style, where spec.files contains files prefixed with paths
|
1046
|
+
# from spec.require_paths. The prefixes are stripped before
|
1047
|
+
# registering the spec's filenames. Unprefixed files are omitted.
|
1048
|
+
#
|
975
1049
|
|
976
1050
|
def register_default_spec(spec)
|
1051
|
+
new_format, prefix_pattern = nil
|
1052
|
+
|
977
1053
|
spec.files.each do |file|
|
1054
|
+
if new_format == nil
|
1055
|
+
new_format = spec.require_paths.any? {|path| file.start_with? path}
|
1056
|
+
|
1057
|
+
prefix_group = spec.require_paths.map {|f| f + "/"}.join("|")
|
1058
|
+
prefix_pattern = /^(#{prefix_group})/
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
if new_format
|
1062
|
+
file = file.sub(prefix_pattern, "")
|
1063
|
+
next unless $~
|
1064
|
+
end
|
1065
|
+
|
978
1066
|
@path_to_default_spec_map[file] = spec
|
979
1067
|
end
|
980
1068
|
end
|
@@ -1091,7 +1179,7 @@ unless gem_preluded then # TODO: remove guard after 1.9.2 dropped
|
|
1091
1179
|
if defined?(RUBY_ENGINE) then
|
1092
1180
|
begin
|
1093
1181
|
##
|
1094
|
-
# Defaults the
|
1182
|
+
# Defaults the Ruby implementation wants to provide for RubyGems
|
1095
1183
|
|
1096
1184
|
require "rubygems/defaults/#{RUBY_ENGINE}"
|
1097
1185
|
rescue LoadError
|
@@ -1,4 +1,7 @@
|
|
1
1
|
class Gem::AvailableSet
|
2
|
+
|
3
|
+
include Enumerable
|
4
|
+
|
2
5
|
Tuple = Struct.new(:spec, :source)
|
3
6
|
|
4
7
|
def initialize
|
@@ -36,6 +39,28 @@ class Gem::AvailableSet
|
|
36
39
|
self
|
37
40
|
end
|
38
41
|
|
42
|
+
##
|
43
|
+
# Yields each Tuple in this AvailableSet
|
44
|
+
|
45
|
+
def each
|
46
|
+
return enum_for __method__ unless block_given?
|
47
|
+
|
48
|
+
@set.each do |tuple|
|
49
|
+
yield tuple
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Yields the Gem::Specification for each Tuple in this AvailableSet
|
55
|
+
|
56
|
+
def each_spec
|
57
|
+
return enum_for __method__ unless block_given?
|
58
|
+
|
59
|
+
each do |tuple|
|
60
|
+
yield tuple.spec
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
39
64
|
def empty?
|
40
65
|
@set.empty?
|
41
66
|
end
|
@@ -66,6 +91,49 @@ class Gem::AvailableSet
|
|
66
91
|
f.source
|
67
92
|
end
|
68
93
|
|
94
|
+
##
|
95
|
+
# Converts this AvailableSet into a RequestSet that can be used to install
|
96
|
+
# gems.
|
97
|
+
#
|
98
|
+
# If +development+ is :none then no development dependencies are installed.
|
99
|
+
# Other options are :shallow for only direct development dependencies of the
|
100
|
+
# gems in this set or :all for all development dependencies.
|
101
|
+
|
102
|
+
def to_request_set development = :none
|
103
|
+
request_set = Gem::RequestSet.new
|
104
|
+
request_set.development = :all == development
|
105
|
+
|
106
|
+
each_spec do |spec|
|
107
|
+
request_set.always_install << spec
|
108
|
+
|
109
|
+
request_set.gem spec.name, spec.version
|
110
|
+
request_set.import spec.development_dependencies if
|
111
|
+
:shallow == development
|
112
|
+
end
|
113
|
+
|
114
|
+
request_set
|
115
|
+
end
|
116
|
+
|
117
|
+
##
|
118
|
+
#
|
119
|
+
# Used by the DependencyResolver, the protocol to use a AvailableSet as a
|
120
|
+
# search Set.
|
121
|
+
|
122
|
+
def find_all(req)
|
123
|
+
dep = req.dependency
|
124
|
+
|
125
|
+
match = @set.find_all do |t|
|
126
|
+
dep.matches_spec? t.spec
|
127
|
+
end
|
128
|
+
|
129
|
+
match.map do |t|
|
130
|
+
Gem::DependencyResolver::InstalledSpecification.new(self, t.spec, t.source)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def prefetch(reqs)
|
135
|
+
end
|
136
|
+
|
69
137
|
def pick_best!
|
70
138
|
return self if empty?
|
71
139
|
|
@@ -0,0 +1,139 @@
|
|
1
|
+
module Gem
|
2
|
+
# BasicSpecification is an abstract class which implements some common code used by
|
3
|
+
# both Specification and StubSpecification.
|
4
|
+
class BasicSpecification
|
5
|
+
def self.default_specifications_dir
|
6
|
+
File.join(Gem.default_dir, "specifications", "default")
|
7
|
+
end
|
8
|
+
|
9
|
+
##
|
10
|
+
# Name of the gem
|
11
|
+
|
12
|
+
def name
|
13
|
+
raise NotImplementedError
|
14
|
+
end
|
15
|
+
|
16
|
+
##
|
17
|
+
# Version of the gem
|
18
|
+
|
19
|
+
def version
|
20
|
+
raise NotImplementedError
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Platform of the gem
|
25
|
+
|
26
|
+
def platform
|
27
|
+
raise NotImplementedError
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Require paths of the gem
|
32
|
+
|
33
|
+
def require_paths
|
34
|
+
raise NotImplementedError
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# True when the gem has been activated
|
39
|
+
|
40
|
+
def activated?
|
41
|
+
raise NotImplementedError
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Return a Gem::Specification from this gem
|
46
|
+
|
47
|
+
def to_spec
|
48
|
+
raise NotImplementedError
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# The filename of the gem specification
|
53
|
+
attr_reader :filename
|
54
|
+
|
55
|
+
##
|
56
|
+
# Set the filename of the Specification was loaded from. +path+ is converted
|
57
|
+
# to a String.
|
58
|
+
|
59
|
+
def filename= path
|
60
|
+
@filename = path && path.to_s
|
61
|
+
|
62
|
+
@full_gem_path = nil
|
63
|
+
@gems_dir = nil
|
64
|
+
@base_dir = nil
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# Return true if this spec can require +file+.
|
69
|
+
|
70
|
+
def contains_requirable_file? file
|
71
|
+
root = full_gem_path
|
72
|
+
suffixes = Gem.suffixes
|
73
|
+
|
74
|
+
require_paths.any? do |lib|
|
75
|
+
base = "#{root}/#{lib}/#{file}"
|
76
|
+
suffixes.any? { |suf| File.file? "#{base}#{suf}" }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# The full path to the gem (install path + full name).
|
82
|
+
|
83
|
+
def full_gem_path
|
84
|
+
# TODO: This is a heavily used method by gems, so we'll need
|
85
|
+
# to aleast just alias it to #gem_dir rather than remove it.
|
86
|
+
@full_gem_path ||= find_full_gem_path
|
87
|
+
end
|
88
|
+
|
89
|
+
# :nodoc:
|
90
|
+
def find_full_gem_path
|
91
|
+
# TODO: also, shouldn't it default to full_name if it hasn't been written?
|
92
|
+
path = File.expand_path File.join(gems_dir, full_name)
|
93
|
+
path.untaint
|
94
|
+
path if File.directory? path
|
95
|
+
end
|
96
|
+
private :find_full_gem_path
|
97
|
+
|
98
|
+
##
|
99
|
+
# Returns the full path to the gems directory containing this spec's
|
100
|
+
# gem directory. eg: /usr/local/lib/ruby/1.8/gems
|
101
|
+
|
102
|
+
def gems_dir
|
103
|
+
# TODO: this logic seems terribly broken, but tests fail if just base_dir
|
104
|
+
@gems_dir ||= File.join(filename && base_dir || Gem.dir, "gems")
|
105
|
+
end
|
106
|
+
|
107
|
+
##
|
108
|
+
# Returns the full path to the base gem directory.
|
109
|
+
#
|
110
|
+
# eg: /usr/local/lib/ruby/gems/1.8
|
111
|
+
|
112
|
+
def base_dir
|
113
|
+
return Gem.dir unless filename
|
114
|
+
@base_dir ||= if default_gem? then
|
115
|
+
File.dirname File.dirname File.dirname filename
|
116
|
+
else
|
117
|
+
File.dirname File.dirname filename
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def default_gem?
|
122
|
+
filename &&
|
123
|
+
File.dirname(filename) == self.class.default_specifications_dir
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Returns the full name (name-version) of this Gem. Platform information
|
128
|
+
# is included (name-version-platform) if it is specified and not the
|
129
|
+
# default Ruby platform.
|
130
|
+
|
131
|
+
def full_name
|
132
|
+
if platform == Gem::Platform::RUBY or platform.nil? then
|
133
|
+
"#{name}-#{version}".untaint
|
134
|
+
else
|
135
|
+
"#{name}-#{version}-#{platform}".untaint
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|