rubygems-update 1.3.5 → 1.3.6

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 (146) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +8 -1
  3. data/ChangeLog +164 -0
  4. data/History.txt +52 -1
  5. data/Manifest.txt +8 -8
  6. data/README +3 -2
  7. data/Rakefile +49 -5
  8. data/bin/gem +2 -2
  9. data/bin/update_rubygems +9 -11
  10. data/cruise_config.rb +4 -3
  11. data/hide_lib_for_update/note.txt +5 -0
  12. data/lib/rbconfig/datadir.rb +10 -14
  13. data/lib/rubygems.rb +117 -140
  14. data/lib/rubygems/builder.rb +4 -2
  15. data/lib/rubygems/command.rb +51 -48
  16. data/lib/rubygems/command_manager.rb +2 -0
  17. data/lib/rubygems/commands/dependency_command.rb +10 -5
  18. data/lib/rubygems/commands/environment_command.rb +1 -1
  19. data/lib/rubygems/commands/fetch_command.rb +6 -5
  20. data/lib/rubygems/commands/install_command.rb +1 -0
  21. data/lib/rubygems/commands/mirror_command.rb +8 -8
  22. data/lib/rubygems/commands/owner_command.rb +75 -0
  23. data/lib/rubygems/commands/pristine_command.rb +1 -1
  24. data/lib/rubygems/commands/push_command.rb +45 -0
  25. data/lib/rubygems/commands/query_command.rb +4 -1
  26. data/lib/rubygems/commands/rdoc_command.rb +24 -9
  27. data/lib/rubygems/commands/server_command.rb +6 -0
  28. data/lib/rubygems/commands/setup_command.rb +14 -4
  29. data/lib/rubygems/commands/unpack_command.rb +2 -2
  30. data/lib/rubygems/commands/update_command.rb +2 -2
  31. data/lib/rubygems/commands/which_command.rb +7 -9
  32. data/lib/rubygems/config_file.rb +100 -26
  33. data/lib/rubygems/defaults.rb +1 -1
  34. data/lib/rubygems/dependency.rb +133 -75
  35. data/lib/rubygems/dependency_installer.rb +28 -10
  36. data/lib/rubygems/dependency_list.rb +41 -12
  37. data/lib/rubygems/doc_manager.rb +7 -0
  38. data/lib/rubygems/format.rb +16 -20
  39. data/lib/rubygems/gem_openssl.rb +1 -1
  40. data/lib/rubygems/gem_path_searcher.rb +10 -12
  41. data/lib/rubygems/gemcutter_utilities.rb +49 -0
  42. data/lib/rubygems/indexer.rb +2 -2
  43. data/lib/rubygems/install_update_options.rb +1 -9
  44. data/lib/rubygems/installer.rb +35 -76
  45. data/lib/rubygems/local_remote_options.rb +1 -2
  46. data/lib/rubygems/package.rb +0 -1
  47. data/lib/rubygems/package/tar_input.rb +3 -1
  48. data/lib/rubygems/package_task.rb +16 -11
  49. data/lib/rubygems/remote_fetcher.rb +22 -8
  50. data/lib/rubygems/requirement.rb +78 -100
  51. data/lib/rubygems/server.rb +41 -10
  52. data/lib/rubygems/source_index.rb +5 -5
  53. data/lib/rubygems/spec_fetcher.rb +2 -2
  54. data/lib/rubygems/specification.rb +66 -16
  55. data/lib/rubygems/test_utilities.rb +33 -4
  56. data/lib/rubygems/uninstaller.rb +3 -3
  57. data/lib/rubygems/user_interaction.rb +45 -0
  58. data/lib/rubygems/validator.rb +6 -7
  59. data/lib/rubygems/version.rb +206 -149
  60. data/lib/rubygems/version_option.rb +16 -0
  61. data/test/fake_certlib/openssl.rb +1 -1
  62. data/test/functional.rb +0 -7
  63. data/test/gem_installer_test_case.rb +4 -4
  64. data/test/gem_package_tar_test_case.rb +1 -1
  65. data/test/gemutilities.rb +35 -31
  66. data/test/insure_session.rb +0 -8
  67. data/test/mockgemui.rb +0 -8
  68. data/test/simple_gem.rb +2 -8
  69. data/test/test_config.rb +3 -10
  70. data/test/test_gem.rb +9 -14
  71. data/test/test_gem_builder.rb +1 -7
  72. data/test/test_gem_command.rb +1 -8
  73. data/test/test_gem_command_manager.rb +1 -7
  74. data/test/test_gem_commands_build_command.rb +4 -4
  75. data/test/test_gem_commands_cert_command.rb +1 -2
  76. data/test/test_gem_commands_check_command.rb +1 -7
  77. data/test/test_gem_commands_contents_command.rb +1 -1
  78. data/test/test_gem_commands_dependency_command.rb +17 -31
  79. data/test/test_gem_commands_environment_command.rb +1 -1
  80. data/test/test_gem_commands_fetch_command.rb +14 -12
  81. data/test/test_gem_commands_generate_index_command.rb +1 -1
  82. data/test/test_gem_commands_install_command.rb +22 -20
  83. data/test/test_gem_commands_list_command.rb +1 -1
  84. data/test/test_gem_commands_lock_command.rb +1 -1
  85. data/test/test_gem_commands_mirror_command.rb +5 -5
  86. data/test/test_gem_commands_outdated_command.rb +3 -5
  87. data/test/test_gem_commands_owner_command.rb +105 -0
  88. data/test/test_gem_commands_pristine_command.rb +2 -2
  89. data/test/test_gem_commands_push_command.rb +61 -0
  90. data/test/test_gem_commands_query_command.rb +23 -56
  91. data/test/test_gem_commands_server_command.rb +1 -1
  92. data/test/test_gem_commands_sources_command.rb +1 -70
  93. data/test/test_gem_commands_specification_command.rb +3 -4
  94. data/test/test_gem_commands_stale_command.rb +1 -1
  95. data/test/test_gem_commands_uninstall_command.rb +3 -4
  96. data/test/test_gem_commands_unpack_command.rb +1 -1
  97. data/test/test_gem_commands_update_command.rb +13 -13
  98. data/test/test_gem_commands_which_command.rb +66 -0
  99. data/test/test_gem_config_file.rb +13 -7
  100. data/test/test_gem_dependency.rb +82 -134
  101. data/test/test_gem_dependency_installer.rb +55 -30
  102. data/test/test_gem_dependency_list.rb +28 -7
  103. data/test/test_gem_doc_manager.rb +1 -7
  104. data/test/test_gem_ext_configure_builder.rb +2 -2
  105. data/test/test_gem_ext_ext_conf_builder.rb +1 -1
  106. data/test/test_gem_ext_rake_builder.rb +1 -1
  107. data/test/test_gem_format.rb +14 -11
  108. data/test/test_gem_gem_path_searcher.rb +12 -1
  109. data/test/test_gem_gem_runner.rb +1 -1
  110. data/test/test_gem_gemcutter_utilities.rb +103 -0
  111. data/test/test_gem_indexer.rb +44 -51
  112. data/test/test_gem_install_update_options.rb +1 -7
  113. data/test/test_gem_installer.rb +22 -82
  114. data/test/test_gem_local_remote_options.rb +1 -1
  115. data/test/test_gem_package_tar_header.rb +1 -8
  116. data/test/test_gem_package_tar_input.rb +1 -8
  117. data/test/test_gem_package_tar_output.rb +1 -8
  118. data/test/test_gem_package_tar_reader.rb +1 -8
  119. data/test/test_gem_package_tar_reader_entry.rb +1 -8
  120. data/test/test_gem_package_tar_writer.rb +1 -8
  121. data/test/test_gem_package_task.rb +1 -25
  122. data/test/test_gem_platform.rb +4 -4
  123. data/test/test_gem_remote_fetcher.rb +31 -21
  124. data/test/test_gem_requirement.rb +210 -140
  125. data/test/test_gem_server.rb +36 -1
  126. data/test/test_gem_source_index.rb +7 -13
  127. data/test/test_gem_spec_fetcher.rb +17 -47
  128. data/test/test_gem_specification.rb +7 -20
  129. data/test/test_gem_stream_ui.rb +21 -1
  130. data/test/test_gem_uninstaller.rb +1 -2
  131. data/test/test_gem_validator.rb +2 -8
  132. data/test/test_gem_version.rb +110 -254
  133. data/test/test_gem_version_option.rb +1 -1
  134. data/test/test_kernel.rb +1 -7
  135. data/util/CL2notes +1 -1
  136. data/util/gem_prelude.rb.template +64 -41
  137. metadata +33 -71
  138. metadata.gz.sig +0 -0
  139. data/lib/rubygems/digest/digest_adapter.rb +0 -49
  140. data/lib/rubygems/digest/md5.rb +0 -23
  141. data/lib/rubygems/digest/sha1.rb +0 -22
  142. data/lib/rubygems/digest/sha2.rb +0 -22
  143. data/lib/rubygems/timer.rb +0 -28
  144. data/test/test_gem_digest.rb +0 -46
  145. data/test/test_gem_source_info_cache.rb +0 -447
  146. data/test/test_gem_source_info_cache_entry.rb +0 -78
@@ -101,10 +101,9 @@ module Gem::LocalRemoteOptions
101
101
  end
102
102
 
103
103
  ##
104
- # Add the --update-source option
104
+ # Add the --update-sources option
105
105
 
106
106
  def add_update_sources_option
107
-
108
107
  add_option(:"Local/Remote", '-u', '--[no-]update-sources',
109
108
  'Update local source cache') do |value, options|
110
109
  Gem.configuration.update_sources = value
@@ -9,7 +9,6 @@ require 'stringio'
9
9
  require 'yaml'
10
10
  require 'zlib'
11
11
 
12
- require 'rubygems/digest/md5'
13
12
  require 'rubygems/security'
14
13
  require 'rubygems/specification'
15
14
 
@@ -1,3 +1,4 @@
1
+ # -*- coding: iso-8859-1 -*-
1
2
  #++
2
3
  # Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
3
4
  # See LICENSE.txt for additional licensing information.
@@ -199,7 +200,8 @@ class Gem::Package::TarInput
199
200
  # times. And that's the way it is.
200
201
 
201
202
  def zipped_stream(entry)
202
- if defined? Rubinius then
203
+ if defined? Rubinius or defined? Maglev then
204
+ # these implementations have working Zlib
203
205
  zis = Zlib::GzipReader.new entry
204
206
  dis = zis.read
205
207
  is = StringIO.new(dis)
@@ -97,22 +97,27 @@ class Gem::PackageTask < Rake::PackageTask
97
97
 
98
98
  def define
99
99
  super
100
+
100
101
  task :package => [:gem]
102
+
103
+ gem_file = gem_spec.file_name
104
+ gem_path = File.join package_dir, gem_file
105
+
101
106
  desc "Build the gem file #{gem_file}"
102
- task :gem => ["#{package_dir}/#{gem_file}"]
103
- file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do
104
- when_writing("Creating #{gem_spec.full_name}.gem") {
107
+ task :gem => [gem_path]
108
+
109
+ trace = Rake.application.options.trace
110
+ Gem.configuration.verbose = trace
111
+
112
+ file gem_path => [package_dir] + @gem_spec.files do
113
+ when_writing "Creating #{gem_spec.file_name}" do
105
114
  Gem::Builder.new(gem_spec).build
106
- verbose(true) {
107
- mv gem_file, "#{package_dir}/#{gem_file}"
108
- }
109
- }
115
+ verbose trace do
116
+ mv gem_file, gem_path
117
+ end
118
+ end
110
119
  end
111
120
  end
112
121
 
113
- def gem_file
114
- "#{@gem_spec.full_name}.gem"
115
- end
116
-
117
122
  end
118
123
 
@@ -81,7 +81,7 @@ class Gem::RemoteFetcher
81
81
  cache_dir = File.join(Gem.user_dir, 'cache')
82
82
  end
83
83
 
84
- gem_file_name = "#{spec.full_name}.gem"
84
+ gem_file_name = spec.file_name
85
85
  local_gem_path = File.join cache_dir, gem_file_name
86
86
 
87
87
  FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
@@ -138,12 +138,18 @@ class Gem::RemoteFetcher
138
138
  say "Using local gem #{local_gem_path}" if
139
139
  Gem.configuration.really_verbose
140
140
  when nil then # TODO test for local overriding cache
141
+ source_path = if Gem.win_platform? && source_uri.scheme &&
142
+ !source_uri.path.include?(':') then
143
+ "#{source_uri.scheme}:#{source_uri.path}"
144
+ else
145
+ source_uri.path
146
+ end
147
+
148
+ source_path = URI.unescape source_path
149
+
141
150
  begin
142
- if Gem.win_platform? && source_uri.scheme && !source_uri.path.include?(':')
143
- FileUtils.cp URI.unescape(source_uri.scheme + ':' + source_uri.path), local_gem_path
144
- else
145
- FileUtils.cp URI.unescape(source_uri.path), local_gem_path
146
- end
151
+ FileUtils.cp source_path, local_gem_path unless
152
+ File.expand_path(source_path) == File.expand_path(local_gem_path)
147
153
  rescue Errno::EACCES
148
154
  local_gem_path = source_uri.to_s
149
155
  end
@@ -317,6 +323,8 @@ class Gem::RemoteFetcher
317
323
  request.add_field 'If-Modified-Since', last_modified.rfc2822
318
324
  end
319
325
 
326
+ yield request if block_given?
327
+
320
328
  connection = connection_for uri
321
329
 
322
330
  retried = false
@@ -324,10 +332,16 @@ class Gem::RemoteFetcher
324
332
 
325
333
  begin
326
334
  @requests[connection.object_id] += 1
335
+
336
+ say "#{request.method} #{uri}" if
337
+ Gem.configuration.really_verbose
327
338
  response = connection.request request
328
- say "#{request.method} #{response.code} #{response.message}: #{uri}" if
339
+ say "#{response.code} #{response.message}" if
329
340
  Gem.configuration.really_verbose
341
+
330
342
  rescue Net::HTTPBadResponse
343
+ say "bad response" if Gem.configuration.really_verbose
344
+
331
345
  reset connection
332
346
 
333
347
  raise FetchError.new('too many bad responses', uri) if bad_response
@@ -337,7 +351,7 @@ class Gem::RemoteFetcher
337
351
  # HACK work around EOFError bug in Net::HTTP
338
352
  # NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible
339
353
  # to install gems.
340
- rescue EOFError, Errno::ECONNABORTED, Errno::ECONNRESET
354
+ rescue EOFError, Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE
341
355
  requests = @requests[connection.object_id]
342
356
  say "connection reset after #{requests} requests, retrying" if
343
357
  Gem.configuration.really_verbose
@@ -1,41 +1,33 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
1
+ require "rubygems/version"
6
2
 
7
3
  ##
8
- # Requirement version includes a prefaced comparator in addition
9
- # to a version number.
10
- #
11
- # A Requirement object can actually contain multiple, er,
12
- # requirements, as in (> 1.2, < 2.0).
4
+ # A Requirement is a set of one or more version restrictions. It supports a
5
+ # few (<tt>=, !=, >, <, >=, <=, ~></tt>) different restriction operators.
13
6
 
14
7
  class Gem::Requirement
15
-
16
8
  include Comparable
17
9
 
18
- attr_reader :requirements
19
-
20
- OPS = {
10
+ OPS = { #:nodoc:
21
11
  "=" => lambda { |v, r| v == r },
22
12
  "!=" => lambda { |v, r| v != r },
23
- ">" => lambda { |v, r| v > r },
24
- "<" => lambda { |v, r| v < r },
13
+ ">" => lambda { |v, r| v > r },
14
+ "<" => lambda { |v, r| v < r },
25
15
  ">=" => lambda { |v, r| v >= r },
26
16
  "<=" => lambda { |v, r| v <= r },
27
17
  "~>" => lambda { |v, r| v = v.release; v >= r && v < r.bump }
28
18
  }
29
19
 
30
- OP_RE = OPS.keys.map{ |k| Regexp.quote k }.join '|'
20
+ quoted = OPS.keys.map { |k| Regexp.quote k }.join "|"
21
+ PATTERN = /\A\s*(#{quoted})?\s*(#{Gem::Version::VERSION_PATTERN})\s*\z/
31
22
 
32
23
  ##
33
- # Factory method to create a Gem::Requirement object. Input may be a
34
- # Version, a String, or nil. Intended to simplify client code.
24
+ # Factory method to create a Gem::Requirement object. Input may be
25
+ # a Version, a String, or nil. Intended to simplify client code.
35
26
  #
36
- # If the input is "weird", the default version requirement is returned.
27
+ # If the input is "weird", the default version requirement is
28
+ # returned.
37
29
 
38
- def self.create(input)
30
+ def self.create input
39
31
  case input
40
32
  when Gem::Requirement then
41
33
  input
@@ -43,9 +35,9 @@ class Gem::Requirement
43
35
  new input
44
36
  else
45
37
  if input.respond_to? :to_str then
46
- self.new [input.to_str]
38
+ new [input.to_str]
47
39
  else
48
- self.default
40
+ default
49
41
  end
50
42
  end
51
43
  end
@@ -58,113 +50,99 @@ class Gem::Requirement
58
50
  # "A default "version requirement" can surely _only_ be '> 0'."
59
51
 
60
52
  def self.default
61
- self.new ['>= 0']
53
+ new '>= 0'
62
54
  end
63
55
 
64
56
  ##
65
- # Constructs a Requirement from +requirements+ which can be a String, a
66
- # Gem::Version, or an Array of those. See #parse for details on the
67
- # formatting of requirement strings.
68
-
69
- def initialize(requirements)
70
- @requirements = case requirements
71
- when Array then
72
- requirements.map do |requirement|
73
- parse(requirement)
74
- end
75
- else
76
- [parse(requirements)]
77
- end
78
- @version = nil # Avoid warnings.
79
- end
57
+ # Parse +obj+, returning an <tt>[op, version]</tt> pair. +obj+ can
58
+ # be a String or a Gem::Version.
59
+ #
60
+ # If +obj+ is a String, it can be either a full requirement
61
+ # specification, like <tt>">= 1.2"</tt>, or a simple version number,
62
+ # like <tt>"1.2"</tt>.
63
+ #
64
+ # parse("> 1.0") # => [">", "1.0"]
65
+ # parse("1.0") # => ["=", "1.0"]
66
+ # parse(Gem::Version.new("1.0")) # => ["=, "1.0"]
80
67
 
81
- ##
82
- # Marshal raw requirements, rather than the full object
68
+ def self.parse obj
69
+ return ["=", obj] if Gem::Version === obj
83
70
 
84
- def marshal_dump # :nodoc:
85
- [@requirements]
71
+ unless PATTERN =~ obj.to_s
72
+ raise ArgumentError, "Illformed requirement [#{obj.inspect}]"
73
+ end
74
+
75
+ [$1 || "=", Gem::Version.new($2)]
86
76
  end
87
77
 
88
78
  ##
89
- # Load custom marshal format
79
+ # An array of requirement pairs. The first element of the pair is
80
+ # the op, and the second is the Gem::Version.
90
81
 
91
- def marshal_load(array) # :nodoc:
92
- @requirements = array[0]
93
- @version = nil
82
+ attr_reader :requirements #:nodoc:
83
+
84
+ ##
85
+ # Constructs a requirement from +requirements+. Requirements can be
86
+ # Strings, Gem::Versions, or Arrays of those. +nil+ and duplicate
87
+ # requirements are ignored. An empty set of +requirements+ is the
88
+ # same as <tt>">= 0"</tt>.
89
+
90
+ def initialize *requirements
91
+ requirements = requirements.flatten
92
+ requirements.compact!
93
+ requirements.uniq!
94
+
95
+ requirements << ">= 0" if requirements.empty?
96
+ @requirements = requirements.map! { |r| self.class.parse r }
94
97
  end
95
98
 
96
- def to_s # :nodoc:
97
- as_list.join(", ")
99
+ def as_list # :nodoc:
100
+ requirements.map { |op, version| "#{op} #{version}" }
98
101
  end
99
102
 
100
- def pretty_print(q) # :nodoc:
101
- q.group 1, 'Gem::Requirement.new(', ')' do
102
- q.pp as_list
103
- end
103
+ def hash # :nodoc:
104
+ requirements.hash
104
105
  end
105
106
 
106
- def as_list
107
- normalize
108
- @requirements.map do |op, version| "#{op} #{version}" end
107
+ def marshal_dump # :nodoc:
108
+ [@requirements]
109
109
  end
110
110
 
111
- def normalize
112
- return if not defined? @version or @version.nil?
113
- @requirements = [parse(@version)]
114
- @nums = nil
115
- @version = nil
116
- @op = nil
111
+ def marshal_load array # :nodoc:
112
+ @requirements = array[0]
117
113
  end
118
114
 
119
- ##
120
- # True if this requirement satisfied by the Gem::Version +version+.
115
+ def prerelease?
116
+ requirements.any? { |r| r.last.prerelease? }
117
+ end
121
118
 
122
- def satisfied_by?(version)
123
- normalize
124
- @requirements.all? { |op, rv| satisfy?(op, version, rv) }
119
+ def pretty_print q # :nodoc:
120
+ q.group 1, 'Gem::Requirement.new(', ')' do
121
+ q.pp as_list
122
+ end
125
123
  end
126
124
 
127
125
  ##
128
- # Is "+version+ +op+ +required_version+" satisfied?
126
+ # True if +version+ satisfies this Requirement.
129
127
 
130
- def satisfy?(op, version, required_version)
131
- OPS[op].call(version, required_version)
132
- end
133
-
134
- def prerelease?
135
- # TODO: why is @requirements a nested array?
136
- @requirements.any?{ |r| r[1].prerelease? }
128
+ def satisfied_by? version
129
+ requirements.all? { |op, rv| OPS[op].call version, rv }
137
130
  end
138
131
 
139
- ##
140
- # Parse the version requirement obj returning the operator and version.
141
- #
142
- # The requirement can be a String or a Gem::Version. A String can be an
143
- # operator (<, <=, =, >=, >, !=, ~>), a version number, or both, operator
144
- # first.
145
-
146
- def parse(obj)
147
- case obj
148
- when /^\s*(#{OP_RE})\s*(#{Gem::Version::VERSION_PATTERN})\s*$/o then
149
- [$1, Gem::Version.new($2)]
150
- when /^\s*(#{Gem::Version::VERSION_PATTERN})\s*$/o then
151
- ['=', Gem::Version.new($1)]
152
- when /^\s*(#{OP_RE})\s*$/o then
153
- [$1, Gem::Version.new('0')]
154
- when Gem::Version then
155
- ['=', obj]
156
- else
157
- fail ArgumentError, "Illformed requirement [#{obj.inspect}]"
158
- end
132
+ def to_s # :nodoc:
133
+ as_list.join ", "
159
134
  end
160
135
 
161
- def <=>(other) # :nodoc:
136
+ def <=> other # :nodoc:
162
137
  to_s <=> other.to_s
163
138
  end
139
+ end
164
140
 
165
- def hash # :nodoc:
166
- to_s.hash
167
- end
141
+ # :stopdoc:
142
+ # Gem::Version::Requirement is used in a lot of old YAML specs. It's aliased
143
+ # here for backwards compatibility. I'd like to remove this, maybe in RubyGems
144
+ # 2.0.
168
145
 
169
- end
146
+ ::Gem::Version::Requirement = ::Gem::Requirement
147
+ # :startdoc:
170
148
 
@@ -39,9 +39,9 @@ class Gem::Server
39
39
  SEARCH = <<-SEARCH
40
40
  <form class="headerSearch" name="headerSearchForm" method="get" action="/rdoc">
41
41
  <div id="search" style="float:right">
42
- <span>Filter/Search</span>
43
- <input id="q" type="text" style="width:10em" name="q"/>
44
- <button type="submit" style="display:none" />
42
+ <label for="q">Filter/Search</label>
43
+ <input id="q" type="text" style="width:10em" name="q">
44
+ <button type="submit" style="display:none"></button>
45
45
  </div>
46
46
  </form>
47
47
  SEARCH
@@ -426,15 +426,17 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
426
426
  RDOC_SEARCH
427
427
 
428
428
  def self.run(options)
429
- new(options[:gemdir], options[:port], options[:daemon]).run
429
+ new(options[:gemdir], options[:port], options[:daemon],
430
+ options[:addresses]).run
430
431
  end
431
432
 
432
- def initialize(gem_dir, port, daemon)
433
+ def initialize(gem_dir, port, daemon, addresses = nil)
433
434
  Socket.do_not_reverse_lookup = true
434
435
 
435
436
  @gem_dir = gem_dir
436
437
  @port = port
437
438
  @daemon = daemon
439
+ @addresses = addresses
438
440
  logger = WEBrick::Log.new nil, WEBrick::BasicLog::FATAL
439
441
  @server = WEBrick::HTTPServer.new :DoNotListen => true, :Logger => logger
440
442
 
@@ -498,6 +500,37 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
498
500
  end
499
501
  end
500
502
 
503
+ ##
504
+ # Creates server sockets based on the addresses option. If no addresses
505
+ # were given a server socket for all interfaces is created.
506
+
507
+ def listen addresses = @addresses
508
+ addresses = [nil] unless addresses
509
+
510
+ listeners = 0
511
+
512
+ addresses.each do |address|
513
+ begin
514
+ @server.listen address, @port
515
+ @server.listeners[listeners..-1].each do |listener|
516
+ host, port = listener.addr.values_at 2, 1
517
+ host = "[#{host}]" if host =~ /:/ # we don't reverse lookup
518
+ say "Server started at http://#{host}:#{port}"
519
+ end
520
+
521
+ listeners = @server.listeners.length
522
+ rescue SystemCallError
523
+ next
524
+ end
525
+ end
526
+
527
+ if @server.listeners.empty? then
528
+ say "Unable to start a server."
529
+ say "Check for running servers or your --bind and --port arguments"
530
+ terminate_interaction 1
531
+ end
532
+ end
533
+
501
534
  def quick(req, res)
502
535
  @source_index.refresh!
503
536
 
@@ -566,7 +599,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
566
599
  deps = spec.dependencies.map do |dep|
567
600
  { "name" => dep.name,
568
601
  "type" => dep.type,
569
- "version" => dep.version_requirements.to_s, }
602
+ "version" => dep.requirement.to_s, }
570
603
  end
571
604
 
572
605
  deps = deps.sort_by { |dep| [dep["name"].downcase, dep["version"]] }
@@ -602,7 +635,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
602
635
  "only_one_executable" => true,
603
636
  "full_name" => "rubygems-#{Gem::RubyGemsVersion}",
604
637
  "has_deps" => false,
605
- "homepage" => "http://rubygems.org/",
638
+ "homepage" => "http://docs.rubygems.org/",
606
639
  "name" => 'rubygems',
607
640
  "rdoc_installed" => true,
608
641
  "summary" => "RubyGems itself",
@@ -716,9 +749,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
716
749
  end
717
750
 
718
751
  def run
719
- @server.listen nil, @port
720
-
721
- say "Starting gem server on http://localhost:#{@port}/"
752
+ listen
722
753
 
723
754
  WEBrick::Daemon.start if @daemon
724
755