rubygems-update 1.3.7 → 1.4.0

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.

Files changed (96) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +4 -1
  3. data/ChangeLog +23 -0
  4. data/History.txt +30 -1
  5. data/Manifest.txt +1 -1
  6. data/{README → README.rdoc} +4 -4
  7. data/Rakefile +7 -56
  8. data/lib/rbconfig/datadir.rb +6 -13
  9. data/lib/rubygems.rb +144 -89
  10. data/lib/rubygems/builder.rb +15 -5
  11. data/lib/rubygems/command.rb +12 -4
  12. data/lib/rubygems/command_manager.rb +1 -1
  13. data/lib/rubygems/commands/build_command.rb +1 -1
  14. data/lib/rubygems/commands/cert_command.rb +4 -4
  15. data/lib/rubygems/commands/check_command.rb +1 -1
  16. data/lib/rubygems/commands/fetch_command.rb +1 -1
  17. data/lib/rubygems/commands/install_command.rb +4 -16
  18. data/lib/rubygems/commands/lock_command.rb +1 -1
  19. data/lib/rubygems/commands/mirror_command.rb +4 -4
  20. data/lib/rubygems/commands/pristine_command.rb +0 -1
  21. data/lib/rubygems/commands/push_command.rb +13 -2
  22. data/lib/rubygems/commands/query_command.rb +4 -4
  23. data/lib/rubygems/commands/server_command.rb +9 -1
  24. data/lib/rubygems/commands/setup_command.rb +3 -3
  25. data/lib/rubygems/commands/sources_command.rb +2 -1
  26. data/lib/rubygems/commands/specification_command.rb +2 -1
  27. data/lib/rubygems/commands/unpack_command.rb +2 -1
  28. data/lib/rubygems/commands/update_command.rb +2 -2
  29. data/lib/rubygems/commands/which_command.rb +1 -0
  30. data/lib/rubygems/custom_require.rb +0 -2
  31. data/lib/rubygems/dependency.rb +15 -20
  32. data/lib/rubygems/dependency_installer.rb +31 -24
  33. data/lib/rubygems/dependency_list.rb +2 -7
  34. data/lib/rubygems/doc_manager.rb +2 -2
  35. data/lib/rubygems/ext/rake_builder.rb +1 -1
  36. data/lib/rubygems/format.rb +0 -4
  37. data/lib/rubygems/gem_openssl.rb +1 -3
  38. data/lib/rubygems/gem_path_searcher.rb +17 -0
  39. data/lib/rubygems/gem_runner.rb +6 -0
  40. data/lib/rubygems/gemcutter_utilities.rb +3 -3
  41. data/lib/rubygems/indexer.rb +4 -4
  42. data/lib/rubygems/install_update_options.rb +6 -0
  43. data/lib/rubygems/installer.rb +13 -6
  44. data/lib/rubygems/local_remote_options.rb +18 -5
  45. data/lib/rubygems/old_format.rb +4 -4
  46. data/lib/rubygems/package.rb +1 -6
  47. data/lib/rubygems/package/tar_input.rb +3 -0
  48. data/lib/rubygems/package_task.rb +6 -6
  49. data/lib/rubygems/platform.rb +1 -1
  50. data/lib/rubygems/remote_fetcher.rb +39 -8
  51. data/lib/rubygems/requirement.rb +1 -1
  52. data/lib/rubygems/security.rb +145 -106
  53. data/lib/rubygems/server.rb +16 -2
  54. data/lib/rubygems/source_index.rb +14 -45
  55. data/lib/rubygems/source_info_cache.rb +1 -2
  56. data/lib/rubygems/spec_fetcher.rb +32 -3
  57. data/lib/rubygems/specification.rb +34 -16
  58. data/lib/rubygems/text.rb +35 -0
  59. data/lib/rubygems/uninstaller.rb +1 -1
  60. data/lib/rubygems/user_interaction.rb +70 -0
  61. data/lib/rubygems/validator.rb +5 -3
  62. data/lib/rubygems/version.rb +36 -25
  63. data/test/gem_package_tar_test_case.rb +3 -1
  64. data/test/gemutilities.rb +26 -4
  65. data/test/test_config.rb +6 -2
  66. data/test/test_gem.rb +87 -29
  67. data/test/test_gem_command_manager.rb +3 -6
  68. data/test/test_gem_commands_cert_command.rb +2 -2
  69. data/test/test_gem_commands_install_command.rb +55 -0
  70. data/test/test_gem_commands_outdated_command.rb +2 -2
  71. data/test/test_gem_commands_owner_command.rb +6 -6
  72. data/test/test_gem_commands_push_command.rb +27 -7
  73. data/test/test_gem_commands_query_command.rb +0 -6
  74. data/test/test_gem_commands_specification_command.rb +4 -4
  75. data/test/test_gem_config_file.rb +0 -2
  76. data/test/test_gem_dependency_installer.rb +21 -23
  77. data/test/test_gem_ext_ext_conf_builder.rb +0 -9
  78. data/test/test_gem_ext_rake_builder.rb +0 -15
  79. data/test/test_gem_gemcutter_utilities.rb +1 -1
  80. data/test/test_gem_installer.rb +0 -5
  81. data/test/test_gem_local_remote_options.rb +18 -1
  82. data/test/test_gem_package_task.rb +1 -1
  83. data/test/test_gem_platform.rb +0 -1
  84. data/test/test_gem_remote_fetcher.rb +5 -3
  85. data/test/test_gem_requirement.rb +2 -2
  86. data/test/test_gem_security.rb +90 -0
  87. data/test/test_gem_server.rb +6 -6
  88. data/test/test_gem_source_index.rb +7 -13
  89. data/test/test_gem_specification.rb +3 -18
  90. data/test/test_gem_stream_ui.rb +69 -5
  91. data/test/test_gem_text.rb +43 -0
  92. data/test/test_gem_version.rb +14 -7
  93. data/test/test_kernel.rb +1 -1
  94. data/util/gem_prelude.rb +8 -8
  95. metadata +15 -10
  96. metadata.gz.sig +0 -0
@@ -132,41 +132,48 @@ class Gem::DependencyInstaller
132
132
 
133
133
  dependency_list = Gem::DependencyList.new @development
134
134
  dependency_list.add(*specs)
135
+ to_do = specs.dup
135
136
 
136
- unless @ignore_dependencies then
137
- to_do = specs.dup
138
- seen = {}
137
+ add_found_dependencies to_do, dependency_list unless @ignore_dependencies
139
138
 
140
- until to_do.empty? do
141
- spec = to_do.shift
142
- next if spec.nil? or seen[spec.name]
143
- seen[spec.name] = true
139
+ @gems_to_install = dependency_list.dependency_order.reverse
140
+ end
144
141
 
145
- deps = spec.runtime_dependencies
146
- deps |= spec.development_dependencies if @development
142
+ def add_found_dependencies to_do, dependency_list
143
+ seen = {}
147
144
 
148
- deps.each do |dep|
149
- results = find_gems_with_sources(dep).reverse
145
+ until to_do.empty? do
146
+ spec = to_do.shift
147
+ next if spec.nil? or seen[spec.name]
148
+ seen[spec.name] = true
150
149
 
151
- results.reject! do |dep_spec,|
152
- to_do.push dep_spec
150
+ deps = spec.runtime_dependencies
151
+ deps |= spec.development_dependencies if @development
153
152
 
154
- @source_index.any? do |_, installed_spec|
155
- dep.name == installed_spec.name and
156
- dep.requirement.satisfied_by? installed_spec.version
157
- end
158
- end
153
+ deps.each do |dep|
154
+ results = find_gems_with_sources(dep).reverse
159
155
 
160
- results.each do |dep_spec, source_uri|
161
- next if seen[dep_spec.name]
162
- @specs_and_sources << [dep_spec, source_uri]
163
- dependency_list.add dep_spec
156
+ # FIX: throw in everything that satisfies, and let
157
+ # FIX: dependencylist reduce to the chosen few
158
+ results.reject! do |dep_spec,|
159
+ to_do.push dep_spec
160
+
161
+ # already locally installed
162
+ @source_index.any? do |_, installed_spec|
163
+ dep.name == installed_spec.name and
164
+ dep.requirement.satisfied_by? installed_spec.version
164
165
  end
165
166
  end
167
+
168
+ results.each do |dep_spec, source_uri|
169
+ next if seen[dep_spec.name]
170
+ @specs_and_sources << [dep_spec, source_uri]
171
+
172
+ # FIX: this is the bug
173
+ dependency_list.add dep_spec
174
+ end
166
175
  end
167
176
  end
168
-
169
- @gems_to_install = dependency_list.dependency_order.reverse
170
177
  end
171
178
 
172
179
  ##
@@ -187,6 +187,7 @@ class Gem::DependencyList
187
187
  begin
188
188
  yield spec
189
189
  rescue TSort::Cyclic
190
+ # do nothing
190
191
  end
191
192
  break
192
193
  end
@@ -201,13 +202,7 @@ class Gem::DependencyList
201
202
  # +ignored+.
202
203
 
203
204
  def active_count(specs, ignored)
204
- result = 0
205
-
206
- specs.each do |spec|
207
- result += 1 unless ignored[spec.full_name]
208
- end
209
-
210
- result
205
+ specs.count { |spec| ignored[spec.full_name].nil? }
211
206
  end
212
207
 
213
208
  end
@@ -4,7 +4,6 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
- require 'fileutils'
8
7
  require 'rubygems'
9
8
 
10
9
  ##
@@ -77,7 +76,7 @@ class Gem::DocManager
77
76
  :formatter => RDoc::RI::Formatter,
78
77
  }
79
78
 
80
- driver = RDoc::RI::Driver.new(options).class_cache
79
+ RDoc::RI::Driver.new(options).class_cache
81
80
  end
82
81
 
83
82
  ##
@@ -85,6 +84,7 @@ class Gem::DocManager
85
84
  # RDoc (template etc.) as a String.
86
85
 
87
86
  def initialize(spec, rdoc_args="")
87
+ require 'fileutils'
88
88
  @spec = spec
89
89
  @doc_dir = File.join(spec.installation_path, "doc", spec.full_name)
90
90
  @rdoc_args = rdoc_args.nil? ? [] : rdoc_args.split
@@ -19,7 +19,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
19
19
  # Deal with possible spaces in the path, e.g. C:/Program Files
20
20
  dest_path = '"' + dest_path + '"' if dest_path.include?(' ')
21
21
 
22
- cmd = ENV['rake'] || "#{Gem.ruby} -rubygems #{Gem.bin_path('rake')}" rescue Gem.default_exec_format % 'rake'
22
+ cmd = ENV['rake'] || "\"#{Gem.ruby}\" -rubygems #{Gem.bin_path('rake')}" rescue Gem.default_exec_format % 'rake'
23
23
  cmd += " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}" # ENV is frozen
24
24
 
25
25
  run cmd, results
@@ -4,8 +4,6 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
- require 'fileutils'
8
-
9
7
  require 'rubygems/package'
10
8
 
11
9
  ##
@@ -32,8 +30,6 @@ class Gem::Format
32
30
  # representing the data in the gem
33
31
 
34
32
  def self.from_file_by_path(file_path, security_policy = nil)
35
- format = nil
36
-
37
33
  unless File.exist?(file_path)
38
34
  raise Gem::Exception, "Cannot load gem at [#{file_path}] in #{Dir.pwd}"
39
35
  end
@@ -42,9 +42,7 @@ begin
42
42
  # Reference a constant defined in the .rb portion of ssl (just to
43
43
  # make sure that part is loaded too).
44
44
 
45
- dummy = OpenSSL::Digest::SHA1
46
-
47
- Gem.ssl_available = true
45
+ Gem.ssl_available = !!OpenSSL::Digest::SHA1
48
46
 
49
47
  class OpenSSL::X509::Certificate # :nodoc:
50
48
  # Check the validity of this certificate.
@@ -54,6 +54,23 @@ class Gem::GemPathSearcher
54
54
  end
55
55
  end
56
56
 
57
+ ##
58
+ # Find all files +path+ .rb advertised by all gemspecs.
59
+ # Only files in the gemspec's require paths are considered.
60
+
61
+ def find_all_dot_rb(path)
62
+ rb_path = "#{path}.rb"
63
+
64
+ @gemspecs.select do |spec|
65
+ rp = spec.require_paths
66
+ next false unless rp
67
+
68
+ rp.find do |lib|
69
+ spec.files.include? File.join(lib, rb_path)
70
+ end
71
+ end
72
+ end
73
+
57
74
  ##
58
75
  # Attempts to find a matching path using the require_paths of the given
59
76
  # +spec+.
@@ -8,6 +8,11 @@ require 'rubygems/command_manager'
8
8
  require 'rubygems/config_file'
9
9
  require 'rubygems/doc_manager'
10
10
 
11
+ ##
12
+ # Load additional plugins from $LOAD_PATH
13
+
14
+ Gem.load_env_plugins
15
+
11
16
  ##
12
17
  # Run an instance of the gem program.
13
18
  #
@@ -76,3 +81,4 @@ class Gem::GemRunner
76
81
 
77
82
  end
78
83
 
84
+ Gem.load_plugins
@@ -1,4 +1,3 @@
1
- require 'net/http'
2
1
  require 'rubygems/remote_fetcher'
3
2
 
4
3
  module Gem::GemcutterUtilities
@@ -23,8 +22,9 @@ module Gem::GemcutterUtilities
23
22
  end
24
23
  end
25
24
 
26
- def rubygems_api_request(method, path, &block)
27
- host = ENV['RUBYGEMS_HOST'] || 'https://rubygems.org'
25
+ def rubygems_api_request(method, path, host = Gem.host, &block)
26
+ require 'net/http'
27
+ host = ENV['RUBYGEMS_HOST'] if ENV['RUBYGEMS_HOST']
28
28
  uri = URI.parse "#{host}/#{path}"
29
29
 
30
30
  request_method = Net::HTTP.const_get method.to_s.capitalize
@@ -1,7 +1,3 @@
1
- require 'fileutils'
2
- require 'tmpdir'
3
- require 'zlib'
4
-
5
1
  require 'rubygems'
6
2
  require 'rubygems/format'
7
3
 
@@ -57,6 +53,10 @@ class Gem::Indexer
57
53
  # Create an indexer that will index the gems in +directory+.
58
54
 
59
55
  def initialize(directory, options = {})
56
+ require 'fileutils'
57
+ require 'tmpdir'
58
+ require 'zlib'
59
+
60
60
  unless ''.respond_to? :to_xs then
61
61
  raise "Gem::Indexer requires that the XML Builder library be installed:" \
62
62
  "\n\tgem install builder"
@@ -104,6 +104,12 @@ module Gem::InstallUpdateOptions
104
104
  "dependencies") do |value, options|
105
105
  options[:development] = true
106
106
  end
107
+
108
+ add_option(:"Install/Update", "--conservative",
109
+ "Don't attempt to upgrade gems already",
110
+ "meeting version requirement") do |value, options|
111
+ options[:conservative] = true
112
+ end
107
113
  end
108
114
 
109
115
  ##
@@ -4,10 +4,8 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
- require 'fileutils'
8
- require 'rbconfig'
9
-
10
7
  require 'rubygems/format'
8
+ require 'rubygems/exceptions'
11
9
  require 'rubygems/ext'
12
10
  require 'rubygems/require_paths_builder'
13
11
 
@@ -91,6 +89,8 @@ class Gem::Installer
91
89
  # :wrappers:: Install wrappers if true, symlinks if false.
92
90
 
93
91
  def initialize(gem, options={})
92
+ require 'fileutils'
93
+
94
94
  @gem = gem
95
95
 
96
96
  options = {
@@ -318,7 +318,7 @@ class Gem::Installer
318
318
  def generate_bin_script(filename, bindir)
319
319
  bin_script_path = File.join bindir, formatted_program_filename(filename)
320
320
 
321
- exec_path = File.join @gem_dir, @spec.bindir, filename
321
+ File.join @gem_dir, @spec.bindir, filename
322
322
 
323
323
  # HACK some gems don't have #! in their executables, restore 2008/06
324
324
  #if File.read(exec_path, 2) == '#!' then
@@ -466,7 +466,7 @@ TEXT
466
466
 
467
467
  say results.join("\n") if Gem.configuration.really_verbose
468
468
 
469
- rescue => ex
469
+ rescue
470
470
  results = results.join "\n"
471
471
 
472
472
  File.open('gem_make.out', 'wb') { |f| f.puts results }
@@ -497,6 +497,8 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
497
497
 
498
498
  raise ArgumentError, "format required to extract from" if @format.nil?
499
499
 
500
+ dirs = []
501
+
500
502
  @format.file_entries.each do |entry, file_data|
501
503
  path = entry['path'].untaint
502
504
 
@@ -514,7 +516,12 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
514
516
  end
515
517
 
516
518
  FileUtils.rm_rf(path) if File.exists?(path)
517
- FileUtils.mkdir_p File.dirname(path)
519
+
520
+ dir = File.dirname(path)
521
+ if !dirs.include?(dir)
522
+ dirs << dir
523
+ FileUtils.mkdir_p dir
524
+ end
518
525
 
519
526
  File.open(path, "wb") do |out|
520
527
  out.write file_data
@@ -51,6 +51,7 @@ module Gem::LocalRemoteOptions
51
51
  end
52
52
 
53
53
  add_bulk_threshold_option
54
+ add_clear_sources_option
54
55
  add_source_option
55
56
  add_proxy_option
56
57
  add_update_sources_option
@@ -68,6 +69,18 @@ module Gem::LocalRemoteOptions
68
69
  end
69
70
  end
70
71
 
72
+ ##
73
+ # Add the --clear-sources option
74
+
75
+ def add_clear_sources_option
76
+ add_option(:"Local/Remote", '--clear-sources',
77
+ 'Clear the gem sources') do |value, options|
78
+
79
+ Gem.sources.clear
80
+ options[:sources_cleared] = true
81
+ end
82
+ end
83
+
71
84
  ##
72
85
  # Add the --http-proxy option
73
86
 
@@ -88,14 +101,14 @@ module Gem::LocalRemoteOptions
88
101
  accept_uri_http
89
102
 
90
103
  add_option(:"Local/Remote", '--source URL', URI::HTTP,
91
- 'Use URL as the remote source for gems') do |source, options|
104
+ 'Add URL as a remote source for gems') do |source, options|
105
+
92
106
  source << '/' if source !~ /\/\z/
93
107
 
94
- if options[:added_source] then
95
- Gem.sources << source unless Gem.sources.include?(source)
108
+ if options.delete :sources_cleared then
109
+ Gem.sources = [source]
96
110
  else
97
- options[:added_source] = true
98
- Gem.sources.replace [source]
111
+ Gem.sources << source unless Gem.sources.include?(source)
99
112
  end
100
113
  end
101
114
  end
@@ -5,9 +5,6 @@
5
5
  #++
6
6
 
7
7
  require 'rubygems'
8
- require 'fileutils'
9
- require 'yaml'
10
- require 'zlib'
11
8
 
12
9
  ##
13
10
  # The format class knows the guts of the RubyGem .gem file format and provides
@@ -24,6 +21,9 @@ class Gem::OldFormat
24
21
  # gem:: [String] The file name of the gem
25
22
 
26
23
  def initialize(gem_path)
24
+ require 'fileutils'
25
+ require 'yaml'
26
+ require 'zlib'
27
27
  @gem_path = gem_path
28
28
  end
29
29
 
@@ -143,7 +143,7 @@ class Gem::OldFormat
143
143
  end
144
144
  yield [entry, Zlib::Inflate.inflate(file_data.strip.unpack("m")[0])]
145
145
  end
146
- rescue Zlib::DataError => e
146
+ rescue Zlib::DataError
147
147
  raise Gem::Exception, errstr
148
148
  end
149
149
  end
@@ -4,12 +4,6 @@
4
4
  # See LICENSE.txt for additional licensing information.
5
5
  #++
6
6
 
7
- require 'fileutils'
8
- require 'find'
9
- require 'stringio'
10
- require 'yaml'
11
- require 'zlib'
12
-
13
7
  require 'rubygems/security'
14
8
  require 'rubygems/specification'
15
9
 
@@ -20,6 +14,7 @@ require 'rubygems/specification'
20
14
  class Gem::FileOperations
21
15
 
22
16
  def initialize(logger = nil)
17
+ require 'fileutils'
23
18
  @logger = logger
24
19
  end
25
20
 
@@ -4,6 +4,9 @@
4
4
  # See LICENSE.txt for additional licensing information.
5
5
  #--
6
6
 
7
+ require "yaml"
8
+ require "zlib"
9
+
7
10
  class Gem::Package::TarInput
8
11
 
9
12
  include Gem::Package::FSyncDir
@@ -111,14 +111,14 @@ class Gem::PackageTask < Rake::PackageTask
111
111
  Gem.configuration.verbose = trace
112
112
 
113
113
  file gem_path => [package_dir, gem_dir] + @gem_spec.files do
114
- when_writing "Creating #{gem_spec.file_name}" do
115
- Gem::Builder.new(gem_spec).build
116
- verbose trace do
117
- mv gem_file, gem_path
114
+ chdir(gem_dir) do
115
+ when_writing "Creating #{gem_spec.file_name}" do
116
+ Gem::Builder.new(gem_spec).build
117
+ verbose(true) {
118
+ mv gem_file, ".."
119
+ }
118
120
  end
119
121
  end
120
122
  end
121
123
  end
122
-
123
124
  end
124
-
@@ -70,7 +70,7 @@ class Gem::Platform
70
70
  when /hpux(\d+)/ then [ 'hpux', $1 ]
71
71
  when /^java$/, /^jruby$/ then [ 'java', nil ]
72
72
  when /^java([\d.]*)/ then [ 'java', $1 ]
73
- when /^dotnet$/ then [ 'dotnet', nil ]
73
+ when /^dotnet$/ then [ 'dotnet', nil ]
74
74
  when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ]
75
75
  when /linux/ then [ 'linux', $1 ]
76
76
  when /mingw32/ then [ 'mingw32', nil ]