slimgems 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/ChangeLog +5811 -0
  2. data/History.txt +887 -0
  3. data/LICENSE.txt +51 -0
  4. data/README.md +87 -0
  5. data/Rakefile +120 -0
  6. data/bin/gem +25 -0
  7. data/bin/update_slimgems +35 -0
  8. data/bootstrap/Rakefile +4 -0
  9. data/hide_lib_for_update/note.txt +5 -0
  10. data/lib/gauntlet_rubygems.rb +50 -0
  11. data/lib/rbconfig/datadir.rb +20 -0
  12. data/lib/rubygems.rb +1220 -0
  13. data/lib/rubygems/builder.rb +102 -0
  14. data/lib/rubygems/command.rb +534 -0
  15. data/lib/rubygems/command_manager.rb +182 -0
  16. data/lib/rubygems/commands/build_command.rb +53 -0
  17. data/lib/rubygems/commands/cert_command.rb +86 -0
  18. data/lib/rubygems/commands/check_command.rb +80 -0
  19. data/lib/rubygems/commands/cleanup_command.rb +106 -0
  20. data/lib/rubygems/commands/contents_command.rb +98 -0
  21. data/lib/rubygems/commands/dependency_command.rb +195 -0
  22. data/lib/rubygems/commands/environment_command.rb +132 -0
  23. data/lib/rubygems/commands/fetch_command.rb +67 -0
  24. data/lib/rubygems/commands/generate_index_command.rb +133 -0
  25. data/lib/rubygems/commands/help_command.rb +172 -0
  26. data/lib/rubygems/commands/install_command.rb +178 -0
  27. data/lib/rubygems/commands/list_command.rb +35 -0
  28. data/lib/rubygems/commands/lock_command.rb +110 -0
  29. data/lib/rubygems/commands/mirror_command.rb +111 -0
  30. data/lib/rubygems/commands/outdated_command.rb +33 -0
  31. data/lib/rubygems/commands/owner_command.rb +75 -0
  32. data/lib/rubygems/commands/pristine_command.rb +93 -0
  33. data/lib/rubygems/commands/push_command.rb +56 -0
  34. data/lib/rubygems/commands/query_command.rb +280 -0
  35. data/lib/rubygems/commands/rdoc_command.rb +91 -0
  36. data/lib/rubygems/commands/search_command.rb +31 -0
  37. data/lib/rubygems/commands/server_command.rb +86 -0
  38. data/lib/rubygems/commands/setup_command.rb +387 -0
  39. data/lib/rubygems/commands/sources_command.rb +157 -0
  40. data/lib/rubygems/commands/specification_command.rb +125 -0
  41. data/lib/rubygems/commands/stale_command.rb +27 -0
  42. data/lib/rubygems/commands/uninstall_command.rb +83 -0
  43. data/lib/rubygems/commands/unpack_command.rb +121 -0
  44. data/lib/rubygems/commands/update_command.rb +212 -0
  45. data/lib/rubygems/commands/which_command.rb +86 -0
  46. data/lib/rubygems/config_file.rb +345 -0
  47. data/lib/rubygems/custom_require.rb +44 -0
  48. data/lib/rubygems/defaults.rb +101 -0
  49. data/lib/rubygems/dependency.rb +227 -0
  50. data/lib/rubygems/dependency_installer.rb +286 -0
  51. data/lib/rubygems/dependency_list.rb +208 -0
  52. data/lib/rubygems/doc_manager.rb +242 -0
  53. data/lib/rubygems/errors.rb +35 -0
  54. data/lib/rubygems/exceptions.rb +91 -0
  55. data/lib/rubygems/ext.rb +18 -0
  56. data/lib/rubygems/ext/builder.rb +56 -0
  57. data/lib/rubygems/ext/configure_builder.rb +25 -0
  58. data/lib/rubygems/ext/ext_conf_builder.rb +24 -0
  59. data/lib/rubygems/ext/rake_builder.rb +39 -0
  60. data/lib/rubygems/format.rb +81 -0
  61. data/lib/rubygems/gem_openssl.rb +92 -0
  62. data/lib/rubygems/gem_path_searcher.rb +100 -0
  63. data/lib/rubygems/gem_runner.rb +79 -0
  64. data/lib/rubygems/gemcutter_utilities.rb +49 -0
  65. data/lib/rubygems/indexer.rb +720 -0
  66. data/lib/rubygems/install_update_options.rb +125 -0
  67. data/lib/rubygems/installer.rb +604 -0
  68. data/lib/rubygems/local_remote_options.rb +135 -0
  69. data/lib/rubygems/old_format.rb +153 -0
  70. data/lib/rubygems/package.rb +97 -0
  71. data/lib/rubygems/package/f_sync_dir.rb +23 -0
  72. data/lib/rubygems/package/tar_header.rb +266 -0
  73. data/lib/rubygems/package/tar_input.rb +222 -0
  74. data/lib/rubygems/package/tar_output.rb +144 -0
  75. data/lib/rubygems/package/tar_reader.rb +106 -0
  76. data/lib/rubygems/package/tar_reader/entry.rb +141 -0
  77. data/lib/rubygems/package/tar_writer.rb +241 -0
  78. data/lib/rubygems/package_task.rb +126 -0
  79. data/lib/rubygems/platform.rb +183 -0
  80. data/lib/rubygems/remote_fetcher.rb +414 -0
  81. data/lib/rubygems/require_paths_builder.rb +18 -0
  82. data/lib/rubygems/requirement.rb +153 -0
  83. data/lib/rubygems/security.rb +814 -0
  84. data/lib/rubygems/server.rb +872 -0
  85. data/lib/rubygems/source_index.rb +597 -0
  86. data/lib/rubygems/source_info_cache.rb +395 -0
  87. data/lib/rubygems/source_info_cache_entry.rb +56 -0
  88. data/lib/rubygems/spec_fetcher.rb +337 -0
  89. data/lib/rubygems/specification.rb +1486 -0
  90. data/lib/rubygems/test_utilities.rb +147 -0
  91. data/lib/rubygems/text.rb +65 -0
  92. data/lib/rubygems/uninstaller.rb +278 -0
  93. data/lib/rubygems/user_interaction.rb +527 -0
  94. data/lib/rubygems/validator.rb +240 -0
  95. data/lib/rubygems/version.rb +316 -0
  96. data/lib/rubygems/version_option.rb +65 -0
  97. data/lib/ubygems.rb +10 -0
  98. data/setup.rb +42 -0
  99. data/test/bogussources.rb +8 -0
  100. data/test/data/gem-private_key.pem +27 -0
  101. data/test/data/gem-public_cert.pem +20 -0
  102. data/test/fake_certlib/openssl.rb +7 -0
  103. data/test/foo/discover.rb +0 -0
  104. data/test/functional.rb +92 -0
  105. data/test/gem_installer_test_case.rb +97 -0
  106. data/test/gem_package_tar_test_case.rb +132 -0
  107. data/test/gemutilities.rb +605 -0
  108. data/test/insure_session.rb +43 -0
  109. data/test/mockgemui.rb +56 -0
  110. data/test/plugin/exception/rubygems_plugin.rb +2 -0
  111. data/test/plugin/load/rubygems_plugin.rb +1 -0
  112. data/test/plugin/standarderror/rubygems_plugin.rb +2 -0
  113. data/test/private_key.pem +27 -0
  114. data/test/public_cert.pem +20 -0
  115. data/test/rubygems_plugin.rb +21 -0
  116. data/test/simple_gem.rb +66 -0
  117. data/test/test_config.rb +12 -0
  118. data/test/test_gem.rb +766 -0
  119. data/test/test_gem_builder.rb +27 -0
  120. data/test/test_gem_command.rb +178 -0
  121. data/test/test_gem_command_manager.rb +207 -0
  122. data/test/test_gem_commands_build_command.rb +74 -0
  123. data/test/test_gem_commands_cert_command.rb +124 -0
  124. data/test/test_gem_commands_check_command.rb +18 -0
  125. data/test/test_gem_commands_contents_command.rb +156 -0
  126. data/test/test_gem_commands_dependency_command.rb +216 -0
  127. data/test/test_gem_commands_environment_command.rb +144 -0
  128. data/test/test_gem_commands_fetch_command.rb +76 -0
  129. data/test/test_gem_commands_generate_index_command.rb +135 -0
  130. data/test/test_gem_commands_install_command.rb +315 -0
  131. data/test/test_gem_commands_list_command.rb +36 -0
  132. data/test/test_gem_commands_lock_command.rb +68 -0
  133. data/test/test_gem_commands_mirror_command.rb +60 -0
  134. data/test/test_gem_commands_outdated_command.rb +40 -0
  135. data/test/test_gem_commands_owner_command.rb +105 -0
  136. data/test/test_gem_commands_pristine_command.rb +108 -0
  137. data/test/test_gem_commands_push_command.rb +81 -0
  138. data/test/test_gem_commands_query_command.rb +426 -0
  139. data/test/test_gem_commands_server_command.rb +59 -0
  140. data/test/test_gem_commands_sources_command.rb +209 -0
  141. data/test/test_gem_commands_specification_command.rb +139 -0
  142. data/test/test_gem_commands_stale_command.rb +38 -0
  143. data/test/test_gem_commands_uninstall_command.rb +83 -0
  144. data/test/test_gem_commands_unpack_command.rb +199 -0
  145. data/test/test_gem_commands_update_command.rb +353 -0
  146. data/test/test_gem_commands_which_command.rb +66 -0
  147. data/test/test_gem_config_file.rb +287 -0
  148. data/test/test_gem_dependency.rb +149 -0
  149. data/test/test_gem_dependency_installer.rb +661 -0
  150. data/test/test_gem_dependency_list.rb +230 -0
  151. data/test/test_gem_doc_manager.rb +31 -0
  152. data/test/test_gem_ext_configure_builder.rb +84 -0
  153. data/test/test_gem_ext_ext_conf_builder.rb +173 -0
  154. data/test/test_gem_ext_rake_builder.rb +81 -0
  155. data/test/test_gem_format.rb +70 -0
  156. data/test/test_gem_gem_path_searcher.rb +78 -0
  157. data/test/test_gem_gem_runner.rb +45 -0
  158. data/test/test_gem_gemcutter_utilities.rb +103 -0
  159. data/test/test_gem_indexer.rb +673 -0
  160. data/test/test_gem_install_update_options.rb +68 -0
  161. data/test/test_gem_installer.rb +857 -0
  162. data/test/test_gem_local_remote_options.rb +97 -0
  163. data/test/test_gem_package_tar_header.rb +130 -0
  164. data/test/test_gem_package_tar_input.rb +112 -0
  165. data/test/test_gem_package_tar_output.rb +97 -0
  166. data/test/test_gem_package_tar_reader.rb +46 -0
  167. data/test/test_gem_package_tar_reader_entry.rb +109 -0
  168. data/test/test_gem_package_tar_writer.rb +144 -0
  169. data/test/test_gem_package_task.rb +59 -0
  170. data/test/test_gem_platform.rb +264 -0
  171. data/test/test_gem_remote_fetcher.rb +740 -0
  172. data/test/test_gem_requirement.rb +292 -0
  173. data/test/test_gem_server.rb +356 -0
  174. data/test/test_gem_silent_ui.rb +113 -0
  175. data/test/test_gem_source_index.rb +461 -0
  176. data/test/test_gem_spec_fetcher.rb +410 -0
  177. data/test/test_gem_specification.rb +1291 -0
  178. data/test/test_gem_stream_ui.rb +218 -0
  179. data/test/test_gem_text.rb +43 -0
  180. data/test/test_gem_uninstaller.rb +146 -0
  181. data/test/test_gem_validator.rb +63 -0
  182. data/test/test_gem_version.rb +181 -0
  183. data/test/test_gem_version_option.rb +89 -0
  184. data/test/test_kernel.rb +59 -0
  185. metadata +413 -0
@@ -0,0 +1,91 @@
1
+ ##
2
+ # Base exception class for #{Gem::NAME}. All exception raised by SlimGems are a
3
+ # subclass of this one.
4
+ class Gem::Exception < RuntimeError; end
5
+
6
+ class Gem::CommandLineError < Gem::Exception; end
7
+
8
+ class Gem::DependencyError < Gem::Exception; end
9
+
10
+ class Gem::DependencyRemovalException < Gem::Exception; end
11
+
12
+ ##
13
+ # Raised when attempting to uninstall a gem that isn't in GEM_HOME.
14
+
15
+ class Gem::GemNotInHomeException < Gem::Exception
16
+ attr_accessor :spec
17
+ end
18
+
19
+ class Gem::DocumentError < Gem::Exception; end
20
+
21
+ ##
22
+ # Potentially raised when a specification is validated.
23
+ class Gem::EndOfYAMLException < Gem::Exception; end
24
+
25
+ ##
26
+ # Signals that a file permission error is preventing the user from
27
+ # installing in the requested directories.
28
+ class Gem::FilePermissionError < Gem::Exception
29
+ def initialize(path)
30
+ super("You don't have write permissions into the #{path} directory.")
31
+ end
32
+ end
33
+
34
+ ##
35
+ # Used to raise parsing and loading errors
36
+ class Gem::FormatException < Gem::Exception
37
+ attr_accessor :file_path
38
+ end
39
+
40
+ class Gem::GemNotFoundException < Gem::Exception
41
+ def initialize(msg, name=nil, version=nil, errors=nil)
42
+ super msg
43
+ @name = name
44
+ @version = version
45
+ @errors = errors
46
+ end
47
+
48
+ attr_reader :name, :version, :errors
49
+ end
50
+
51
+ class Gem::InstallError < Gem::Exception; end
52
+
53
+ ##
54
+ # Potentially raised when a specification is validated.
55
+ class Gem::InvalidSpecificationException < Gem::Exception; end
56
+
57
+ class Gem::OperationNotSupportedError < Gem::Exception; end
58
+
59
+ ##
60
+ # Signals that a remote operation cannot be conducted, probably due to not
61
+ # being connected (or just not finding host).
62
+ #--
63
+ # TODO: create a method that tests connection to the preferred gems server.
64
+ # All code dealing with remote operations will want this. Failure in that
65
+ # method should raise this error.
66
+ class Gem::RemoteError < Gem::Exception; end
67
+
68
+ class Gem::RemoteInstallationCancelled < Gem::Exception; end
69
+
70
+ class Gem::RemoteInstallationSkipped < Gem::Exception; end
71
+
72
+ ##
73
+ # Represents an error communicating via HTTP.
74
+ class Gem::RemoteSourceException < Gem::Exception; end
75
+
76
+ class Gem::VerificationError < Gem::Exception; end
77
+
78
+ ##
79
+ # Raised to indicate that a system exit should occur with the specified
80
+ # exit_code
81
+
82
+ class Gem::SystemExitException < SystemExit
83
+ attr_accessor :exit_code
84
+
85
+ def initialize(exit_code)
86
+ @exit_code = exit_code
87
+
88
+ super "Exiting #{Gem::NAME} with exit_code #{exit_code}"
89
+ end
90
+
91
+ end
@@ -0,0 +1,18 @@
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
+ require 'rubygems'
8
+
9
+ ##
10
+ # Classes for building C extensions live here.
11
+
12
+ module Gem::Ext; end
13
+
14
+ require 'rubygems/ext/builder'
15
+ require 'rubygems/ext/configure_builder'
16
+ require 'rubygems/ext/ext_conf_builder'
17
+ require 'rubygems/ext/rake_builder'
18
+
@@ -0,0 +1,56 @@
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
+ class Gem::Ext::Builder
8
+
9
+ def self.class_name
10
+ name =~ /Ext::(.*)Builder/
11
+ $1.downcase
12
+ end
13
+
14
+ def self.make(dest_path, results)
15
+ unless File.exist? 'Makefile' then
16
+ raise Gem::InstallError, "Makefile not found:\n\n#{results.join "\n"}"
17
+ end
18
+
19
+ mf = File.read('Makefile')
20
+ mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
21
+ mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}")
22
+
23
+ File.open('Makefile', 'wb') {|f| f.print mf}
24
+
25
+ # try to find make program from Ruby configue arguments first
26
+ RbConfig::CONFIG['configure_args'] =~ /with-make-prog\=(\w+)/
27
+ make_program = $1 || ENV['make']
28
+ unless make_program then
29
+ make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
30
+ end
31
+
32
+ ['', ' install'].each do |target|
33
+ cmd = "#{make_program}#{target}"
34
+ results << cmd
35
+ results << `#{cmd} #{redirector}`
36
+
37
+ raise Gem::InstallError, "make#{target} failed:\n\n#{results}" unless
38
+ $?.success?
39
+ end
40
+ end
41
+
42
+ def self.redirector
43
+ '2>&1'
44
+ end
45
+
46
+ def self.run(command, results)
47
+ results << command
48
+ results << `#{command} #{redirector}`
49
+
50
+ unless $?.success? then
51
+ raise Gem::InstallError, "#{class_name} failed:\n\n#{results.join "\n"}"
52
+ end
53
+ end
54
+
55
+ end
56
+
@@ -0,0 +1,25 @@
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
+ require 'rubygems/ext/builder'
8
+
9
+ class Gem::Ext::ConfigureBuilder < Gem::Ext::Builder
10
+
11
+ def self.build(extension, directory, dest_path, results)
12
+ unless File.exist?('Makefile') then
13
+ cmd = "sh ./configure --prefix=#{dest_path}"
14
+ cmd << " #{Gem::Command.build_args.join ' '}" unless Gem::Command.build_args.empty?
15
+
16
+ run cmd, results
17
+ end
18
+
19
+ make dest_path, results
20
+
21
+ results
22
+ end
23
+
24
+ end
25
+
@@ -0,0 +1,24 @@
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
+ require 'rubygems/ext/builder'
8
+ require 'rubygems/command'
9
+
10
+ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
11
+
12
+ def self.build(extension, directory, dest_path, results)
13
+ cmd = "#{Gem.ruby} #{File.basename extension}"
14
+ cmd << " #{Gem::Command.build_args.join ' '}" unless Gem::Command.build_args.empty?
15
+
16
+ run cmd, results
17
+
18
+ make dest_path, results
19
+
20
+ results
21
+ end
22
+
23
+ end
24
+
@@ -0,0 +1,39 @@
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
+ require 'rubygems/ext/builder'
8
+ require 'rubygems/command'
9
+
10
+ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
11
+
12
+ def self.build(extension, directory, dest_path, results)
13
+ if File.basename(extension) =~ /mkrf_conf/i then
14
+ cmd = "#{Gem.ruby} #{File.basename extension}"
15
+ cmd << " #{Gem::Command.build_args.join " "}" unless Gem::Command.build_args.empty?
16
+ run cmd, results
17
+ end
18
+
19
+ # Deal with possible spaces in the path, e.g. C:/Program Files
20
+ dest_path = '"' + dest_path + '"' if dest_path.include?(' ')
21
+
22
+ rake = ENV['rake']
23
+
24
+ rake ||= begin
25
+ "\"#{Gem.ruby}\" -rubygems #{Gem.bin_path('rake')}"
26
+ rescue Gem::Exception
27
+ end
28
+
29
+ rake ||= Gem.default_exec_format % 'rake'
30
+
31
+ cmd = "#{rake} RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}" # ENV is frozen
32
+
33
+ run cmd, results
34
+
35
+ results
36
+ end
37
+
38
+ end
39
+
@@ -0,0 +1,81 @@
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
+ require 'fileutils'
8
+
9
+ require 'rubygems/package'
10
+
11
+ ##
12
+ # Gem::Format knows the guts of the RubyGem .gem file format and provides the
13
+ # capability to read gem files
14
+
15
+ class Gem::Format
16
+
17
+ attr_accessor :spec
18
+ attr_accessor :file_entries
19
+ attr_accessor :gem_path
20
+
21
+ extend Gem::UserInteraction
22
+
23
+ ##
24
+ # Constructs a Format representing the gem's data which came from +gem_path+
25
+
26
+ def initialize(gem_path)
27
+ @gem_path = gem_path
28
+ end
29
+
30
+ ##
31
+ # Reads the gem +file_path+ using +security_policy+ and returns a Format
32
+ # representing the data in the gem
33
+
34
+ def self.from_file_by_path(file_path, security_policy = nil)
35
+ unless File.exist?(file_path)
36
+ raise Gem::Exception, "Cannot load gem at [#{file_path}] in #{Dir.pwd}"
37
+ end
38
+
39
+ start = File.read file_path, 20
40
+
41
+ if start.nil? or start.length < 20 then
42
+ nil
43
+ elsif start.include?("MD5SUM =") # old version gems
44
+ require 'rubygems/old_format'
45
+
46
+ Gem::OldFormat.from_file_by_path file_path
47
+ else
48
+ open file_path, Gem.binary_mode do |io|
49
+ from_io io, file_path, security_policy
50
+ end
51
+ end
52
+ end
53
+
54
+ ##
55
+ # Reads a gem from +io+ at +gem_path+ using +security_policy+ and returns a
56
+ # Format representing the data from the gem
57
+
58
+ def self.from_io(io, gem_path="(io)", security_policy = nil)
59
+ format = new gem_path
60
+
61
+ Gem::Package.open io, 'r', security_policy do |pkg|
62
+ format.spec = pkg.metadata
63
+ format.file_entries = []
64
+
65
+ pkg.each do |entry|
66
+ size = entry.header.size
67
+ mode = entry.header.mode
68
+
69
+ format.file_entries << [{
70
+ "size" => size, "mode" => mode, "path" => entry.full_name,
71
+ },
72
+ entry.read
73
+ ]
74
+ end
75
+ end
76
+
77
+ format
78
+ end
79
+
80
+ end
81
+
@@ -0,0 +1,92 @@
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
+ #--
8
+ # Some system might not have OpenSSL installed, therefore the core
9
+ # library file openssl might not be available. We localize testing
10
+ # for the presence of OpenSSL in this file.
11
+ #++
12
+
13
+ module Gem
14
+ class << self
15
+ ##
16
+ # Is SSL (used by the signing commands) available on this
17
+ # platform?
18
+
19
+ def ssl_available?
20
+ @ssl_available
21
+ end
22
+
23
+ ##
24
+ # Is SSL available?
25
+
26
+ attr_writer :ssl_available
27
+
28
+ ##
29
+ # Ensure that SSL is available. Throw an exception if it is not.
30
+
31
+ def ensure_ssl_available
32
+ unless ssl_available?
33
+ raise Gem::Exception, "SSL is not installed on this system"
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ begin
40
+ require 'openssl'
41
+
42
+ # Reference a constant defined in the .rb portion of ssl (just to
43
+ # make sure that part is loaded too).
44
+
45
+ Gem.ssl_available = !!OpenSSL::Digest::SHA1
46
+
47
+ class OpenSSL::X509::Certificate # :nodoc:
48
+ # Check the validity of this certificate.
49
+ def check_validity(issuer_cert = nil, time = Time.now)
50
+ ret = if @not_before && @not_before > time
51
+ [false, :expired, "not valid before '#@not_before'"]
52
+ elsif @not_after && @not_after < time
53
+ [false, :expired, "not valid after '#@not_after'"]
54
+ elsif issuer_cert && !verify(issuer_cert.public_key)
55
+ [false, :issuer, "#{issuer_cert.subject} is not issuer"]
56
+ else
57
+ [true, :ok, 'Valid certificate']
58
+ end
59
+
60
+ # return hash
61
+ { :is_valid => ret[0], :error => ret[1], :desc => ret[2] }
62
+ end
63
+ end
64
+
65
+ rescue LoadError, StandardError
66
+ Gem.ssl_available = false
67
+ end
68
+
69
+ # :stopdoc:
70
+
71
+ module Gem::SSL
72
+
73
+ # We make our own versions of the constants here. This allows us
74
+ # to reference the constants, even though some systems might not
75
+ # have SSL installed in the Ruby core package.
76
+ #
77
+ # These constants are only used during load time. At runtime, any
78
+ # method that makes a direct reference to SSL software must be
79
+ # protected with a Gem.ensure_ssl_available call.
80
+
81
+ if Gem.ssl_available? then
82
+ PKEY_RSA = OpenSSL::PKey::RSA
83
+ DIGEST_SHA1 = OpenSSL::Digest::SHA1
84
+ else
85
+ PKEY_RSA = :rsa
86
+ DIGEST_SHA1 = :sha1
87
+ end
88
+
89
+ end
90
+
91
+ # :startdoc:
92
+
@@ -0,0 +1,100 @@
1
+ ##
2
+ # GemPathSearcher has the capability to find loadable files inside
3
+ # gems. It generates data up front to speed up searches later.
4
+
5
+ class Gem::GemPathSearcher
6
+
7
+ ##
8
+ # Initialise the data we need to make searches later.
9
+
10
+ def initialize
11
+ # We want a record of all the installed gemspecs, in the order we wish to
12
+ # examine them.
13
+ @gemspecs = init_gemspecs
14
+
15
+ # Map gem spec to glob of full require_path directories. Preparing this
16
+ # information may speed up searches later.
17
+ @lib_dirs = {}
18
+
19
+ @gemspecs.each do |spec|
20
+ @lib_dirs[spec.object_id] = lib_dirs_for spec
21
+ end
22
+ end
23
+
24
+ ##
25
+ # Look in all the installed gems until a matching _path_ is found.
26
+ # Return the _gemspec_ of the gem where it was found. If no match
27
+ # is found, return nil.
28
+ #
29
+ # The gems are searched in alphabetical order, and in reverse
30
+ # version order.
31
+ #
32
+ # For example:
33
+ #
34
+ # find('log4r') # -> (log4r-1.1 spec)
35
+ # find('log4r.rb') # -> (log4r-1.1 spec)
36
+ # find('rake/rdoctask') # -> (rake-0.4.12 spec)
37
+ # find('foobarbaz') # -> nil
38
+ #
39
+ # Matching paths can have various suffixes ('.rb', '.so', and
40
+ # others), which may or may not already be attached to _file_.
41
+ # This method doesn't care about the full filename that matches;
42
+ # only that there is a match.
43
+
44
+ def find(path)
45
+ @gemspecs.find do |spec| matching_file? spec, path end
46
+ end
47
+
48
+ ##
49
+ # Works like #find, but finds all gemspecs matching +path+.
50
+
51
+ def find_all(path)
52
+ @gemspecs.select do |spec|
53
+ matching_file? spec, path
54
+ end
55
+ end
56
+
57
+ ##
58
+ # Attempts to find a matching path using the require_paths of the given
59
+ # +spec+.
60
+
61
+ def matching_file?(spec, path)
62
+ !matching_files(spec, path).empty?
63
+ end
64
+
65
+ ##
66
+ # Returns files matching +path+ in +spec+.
67
+ #--
68
+ # Some of the intermediate results are cached in @lib_dirs for speed.
69
+
70
+ def matching_files(spec, path)
71
+ return [] unless @lib_dirs[spec.object_id] # case no paths
72
+ glob = File.join @lib_dirs[spec.object_id], "#{path}#{Gem.suffix_pattern}"
73
+ Dir[glob].select { |f| File.file? f.untaint }
74
+ end
75
+
76
+ ##
77
+ # Return a list of all installed gemspecs, sorted by alphabetical order and
78
+ # in reverse version order. (bar-2, bar-1, foo-2)
79
+
80
+ def init_gemspecs
81
+ specs = Gem.source_index.map { |_, spec| spec }
82
+
83
+ specs.sort { |a, b|
84
+ names = a.name <=> b.name
85
+ next names if names.nonzero?
86
+ b.version <=> a.version
87
+ }
88
+ end
89
+
90
+ ##
91
+ # Returns library directories glob for a gemspec. For example,
92
+ # '/usr/local/lib/ruby/gems/1.8/gems/foobar-1.0/{lib,ext}'
93
+
94
+ def lib_dirs_for(spec)
95
+ "#{spec.full_gem_path}/{#{spec.require_paths.join(',')}}" if
96
+ spec.require_paths
97
+ end
98
+
99
+ end
100
+