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
@@ -1,9 +1,3 @@
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
1
  ##
8
2
  # The Version class processes string versions into comparable
9
3
  # values. A version string should normally be a series of numbers
@@ -24,72 +18,153 @@
24
18
  # 2. 1.0.b
25
19
  # 3. 1.0.a
26
20
  # 4. 0.9
21
+ #
22
+ # == How Software Changes
23
+ #
24
+ # Users expect to be able to specify a version constraint that gives them
25
+ # some reasonable expectation that new versions of a library will work with
26
+ # their software if the version constraint is true, and not work with their
27
+ # software if the version constraint is false. In other words, the perfect
28
+ # system will accept all compatible versions of the library and reject all
29
+ # incompatible versions.
30
+ #
31
+ # Libraries change in 3 ways (well, more than 3, but stay focused here!).
32
+ #
33
+ # 1. The change may be an implementation detail only and have no effect on
34
+ # the client software.
35
+ # 2. The change may add new features, but do so in a way that client software
36
+ # written to an earlier version is still compatible.
37
+ # 3. The change may change the public interface of the library in such a way
38
+ # that old software is no longer compatible.
39
+ #
40
+ # Some examples are appropriate at this point. Suppose I have a Stack class
41
+ # that supports a <tt>push</tt> and a <tt>pop</tt> method.
42
+ #
43
+ # === Examples of Category 1 changes:
44
+ #
45
+ # * Switch from an array based implementation to a linked-list based
46
+ # implementation.
47
+ # * Provide an automatic (and transparent) backing store for large stacks.
48
+ #
49
+ # === Examples of Category 2 changes might be:
50
+ #
51
+ # * Add a <tt>depth</tt> method to return the current depth of the stack.
52
+ # * Add a <tt>top</tt> method that returns the current top of stack (without
53
+ # changing the stack).
54
+ # * Change <tt>push</tt> so that it returns the item pushed (previously it
55
+ # had no usable return value).
56
+ #
57
+ # === Examples of Category 3 changes might be:
58
+ #
59
+ # * Changes <tt>pop</tt> so that it no longer returns a value (you must use
60
+ # <tt>top</tt> to get the top of the stack).
61
+ # * Rename the methods to <tt>push_item</tt> and <tt>pop_item</tt>.
62
+ #
63
+ # == RubyGems Rational Versioning
64
+ #
65
+ # * Versions shall be represented by three non-negative integers, separated
66
+ # by periods (e.g. 3.1.4). The first integers is the "major" version
67
+ # number, the second integer is the "minor" version number, and the third
68
+ # integer is the "build" number.
69
+ #
70
+ # * A category 1 change (implementation detail) will increment the build
71
+ # number.
72
+ #
73
+ # * A category 2 change (backwards compatible) will increment the minor
74
+ # version number and reset the build number.
75
+ #
76
+ # * A category 3 change (incompatible) will increment the major build number
77
+ # and reset the minor and build numbers.
78
+ #
79
+ # * Any "public" release of a gem should have a different version. Normally
80
+ # that means incrementing the build number. This means a developer can
81
+ # generate builds all day long for himself, but as soon as he/she makes a
82
+ # public release, the version must be updated.
83
+ #
84
+ # === Examples
85
+ #
86
+ # Let's work through a project lifecycle using our Stack example from above.
87
+ #
88
+ # Version 0.0.1:: The initial Stack class is release.
89
+ # Version 0.0.2:: Switched to a linked=list implementation because it is
90
+ # cooler.
91
+ # Version 0.1.0:: Added a <tt>depth</tt> method.
92
+ # Version 1.0.0:: Added <tt>top</tt> and made <tt>pop</tt> return nil
93
+ # (<tt>pop</tt> used to return the old top item).
94
+ # Version 1.1.0:: <tt>push</tt> now returns the value pushed (it used it
95
+ # return nil).
96
+ # Version 1.1.1:: Fixed a bug in the linked list implementation.
97
+ # Version 1.1.2:: Fixed a bug introduced in the last fix.
98
+ #
99
+ # Client A needs a stack with basic push/pop capability. He writes to the
100
+ # original interface (no <tt>top</tt>), so his version constraint looks
101
+ # like:
102
+ #
103
+ # gem 'stack', '~> 0.0'
104
+ #
105
+ # Essentially, any version is OK with Client A. An incompatible change to
106
+ # the library will cause him grief, but he is willing to take the chance (we
107
+ # call Client A optimistic).
108
+ #
109
+ # Client B is just like Client A except for two things: (1) He uses the
110
+ # <tt>depth</tt> method and (2) he is worried about future
111
+ # incompatibilities, so he writes his version constraint like this:
112
+ #
113
+ # gem 'stack', '~> 0.1'
114
+ #
115
+ # The <tt>depth</tt> method was introduced in version 0.1.0, so that version
116
+ # or anything later is fine, as long as the version stays below version 1.0
117
+ # where incompatibilities are introduced. We call Client B pessimistic
118
+ # because he is worried about incompatible future changes (it is OK to be
119
+ # pessimistic!).
120
+ #
121
+ # == Preventing Version Catastrophe:
122
+ #
123
+ # From: http://blog.zenspider.com/2008/10/rubygems-howto-preventing-cata.html
124
+ #
125
+ # Let's say you're depending on the fnord gem version 2.y.z. If you
126
+ # specify your dependency as ">= 2.0.0" then, you're good, right? What
127
+ # happens if fnord 3.0 comes out and it isn't backwards compatible
128
+ # with 2.y.z? Your stuff will break as a result of using ">=". The
129
+ # better route is to specify your dependency with a "spermy" version
130
+ # specifier. They're a tad confusing, so here is how the dependency
131
+ # specifiers work:
132
+ #
133
+ # Specification From ... To (exclusive)
134
+ # ">= 3.0" 3.0 ... &infin;
135
+ # "~> 3.0" 3.0 ... 4.0
136
+ # "~> 3.0.0" 3.0.0 ... 3.1
137
+ # "~> 3.5" 3.5 ... 4.0
138
+ # "~> 3.5.0" 3.5.0 ... 3.6
27
139
 
28
140
  class Gem::Version
29
-
30
- class Part
31
- include Comparable
32
-
33
- attr_reader :value
34
-
35
- def initialize(value)
36
- @value = (value =~ /\A\d+\z/) ? value.to_i : value
37
- end
38
-
39
- def to_s
40
- self.value.to_s
41
- end
42
-
43
- def inspect
44
- @value
45
- end
46
-
47
- def alpha?
48
- String === value
49
- end
50
-
51
- def numeric?
52
- Fixnum === value
53
- end
54
-
55
- def <=>(other)
56
- if self.numeric? && other.alpha? then
57
- 1
58
- elsif self.alpha? && other.numeric? then
59
- -1
60
- else
61
- self.value <=> other.value
62
- end
63
- end
64
-
65
- def succ
66
- self.class.new(self.value.succ)
67
- end
68
- end
69
-
70
141
  include Comparable
71
142
 
72
- VERSION_PATTERN = '[0-9]+(\.[0-9a-z]+)*'
143
+ VERSION_PATTERN = '[0-9]+(\.[0-9a-zA-Z]+)*' # :nodoc:
144
+ ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})*\s*\z/ # :nodoc:
145
+
146
+ ##
147
+ # A string representation of this Version.
73
148
 
74
149
  attr_reader :version
150
+ alias to_s version
75
151
 
76
- def self.correct?(version)
77
- pattern = /\A\s*(#{VERSION_PATTERN})*\s*\z/
152
+ ##
153
+ # True if the +version+ string matches RubyGems' requirements.
78
154
 
79
- version.is_a? Integer or
80
- version =~ pattern or
81
- version.to_s =~ pattern
155
+ def self.correct? version
156
+ version.to_s =~ ANCHORED_VERSION_PATTERN
82
157
  end
83
158
 
84
159
  ##
85
- # Factory method to create a Version object. Input may be a Version or a
86
- # String. Intended to simplify client code.
160
+ # Factory method to create a Version object. Input may be a Version
161
+ # or a String. Intended to simplify client code.
87
162
  #
88
163
  # ver1 = Version.create('1.3.17') # -> (Version object)
89
164
  # ver2 = Version.create(ver1) # -> (ver1)
90
165
  # ver3 = Version.create(nil) # -> nil
91
166
 
92
- def self.create(input)
167
+ def self.create input
93
168
  if input.respond_to? :version then
94
169
  input
95
170
  elsif input.nil? then
@@ -103,149 +178,131 @@ class Gem::Version
103
178
  # Constructs a Version from the +version+ string. A version string is a
104
179
  # series of digits or ASCII letters separated by dots.
105
180
 
106
- def initialize(version)
181
+ def initialize version
107
182
  raise ArgumentError, "Malformed version number string #{version}" unless
108
183
  self.class.correct?(version)
109
184
 
110
- self.version = version
111
- end
185
+ @version = version.to_s
186
+ @version.strip!
112
187
 
113
- def inspect # :nodoc:
114
- "#<#{self.class} #{@version.inspect}>"
188
+ segments # prime @segments
115
189
  end
116
190
 
117
191
  ##
118
- # Dump only the raw version string, not the complete object
192
+ # Return a new version object where the next to the last revision
193
+ # number is one greater (e.g., 5.3.1 => 5.4).
194
+ #
195
+ # Pre-release (alpha) parts, e.g, 5.3.1.b2 => 5.4, are ignored.
119
196
 
120
- def marshal_dump
121
- [@version]
197
+ def bump
198
+ segments = self.segments.dup
199
+ segments.pop while segments.any? { |s| String === s }
200
+ segments.pop if segments.size > 1
201
+
202
+ segments[-1] = segments[-1].succ
203
+ self.class.new segments.join(".")
122
204
  end
123
205
 
124
206
  ##
125
- # Load custom marshal format
207
+ # A Version is only eql? to another version if it's specified to the
208
+ # same precision. Version "1.0" is not the same as version "1".
126
209
 
127
- def marshal_load(array)
128
- self.version = array[0]
210
+ def eql? other
211
+ self.class === other and segments == other.segments
129
212
  end
130
213
 
131
- def parts
132
- @parts ||= normalize
214
+ def hash # :nodoc:
215
+ segments.hash
133
216
  end
134
217
 
135
- ##
136
- # Strip ignored trailing zeros.
137
-
138
- def normalize
139
- parts_arr = parse_parts_from_version_string
140
- if parts_arr.length != 1
141
- parts_arr.pop while parts_arr.last && parts_arr.last.value == 0
142
- parts_arr = [Part.new(0)] if parts_arr.empty?
143
- end
144
- parts_arr
218
+ def inspect # :nodoc:
219
+ "#<#{self.class} #{version.inspect}>"
145
220
  end
146
221
 
147
222
  ##
148
- # Returns the text representation of the version
223
+ # Dump only the raw version string, not the complete object. It's a
224
+ # string for backwards (RubyGems 1.3.5 and earlier) compatibility.
149
225
 
150
- def to_s
151
- @version
226
+ def marshal_dump
227
+ [version]
152
228
  end
153
229
 
154
- def to_yaml_properties
155
- ['@version']
156
- end
230
+ ##
231
+ # Load custom marshal format. It's a string for backwards (RubyGems
232
+ # 1.3.5 and earlier) compatibility.
157
233
 
158
- def version=(version)
159
- @version = version.to_s.strip
160
- normalize
234
+ def marshal_load array
235
+ initialize array[0]
161
236
  end
162
237
 
163
238
  ##
164
- # A version is considered a prerelease if any part contains a letter.
239
+ # A version is considered a prerelease if it contains a letter.
165
240
 
166
241
  def prerelease?
167
- parts.any? { |part| part.alpha? }
168
- end
169
-
170
- ##
171
- # The release for this version (e.g. 1.2.0.a -> 1.2.0)
172
- # Non-prerelease versions return themselves
173
- def release
174
- return self unless prerelease?
175
- rel_parts = parts.dup
176
- rel_parts.pop while rel_parts.any? { |part| part.alpha? }
177
- self.class.new(rel_parts.join('.'))
242
+ @prerelease ||= segments.any? { |s| String === s }
178
243
  end
179
244
 
180
- def yaml_initialize(tag, values)
181
- self.version = values['version']
245
+ def pretty_print q # :nodoc:
246
+ q.text "Gem::Version.new(#{version.inspect})"
182
247
  end
183
248
 
184
249
  ##
185
- # Compares this version with +other+ returning -1, 0, or 1 if the other
186
- # version is larger, the same, or smaller than this one.
250
+ # The release for this version (e.g. 1.2.0.a -> 1.2.0).
251
+ # Non-prerelease versions return themselves.
187
252
 
188
- def <=>(other)
189
- return nil unless self.class === other
190
- return 1 unless other
191
- mine, theirs = balance(self.parts.dup, other.parts.dup)
192
- mine <=> theirs
193
- end
253
+ def release
254
+ return self unless prerelease?
194
255
 
195
- def balance(a, b)
196
- a << Part.new(0) while a.size < b.size
197
- b << Part.new(0) while b.size < a.size
198
- [a, b]
256
+ segments = self.segments.dup
257
+ segments.pop while segments.any? { |s| String === s }
258
+ self.class.new segments.join('.')
199
259
  end
200
260
 
201
- ##
202
- # A Version is only eql? to another version if it has the same version
203
- # string. "1.0" is not the same version as "1".
261
+ def segments # :nodoc:
204
262
 
205
- def eql?(other)
206
- self.class === other and @version == other.version
207
- end
263
+ # @segments is lazy so it can pick up @version values that come
264
+ # from old marshaled versions, which don't go through
265
+ # marshal_load. +segments+ is called in +initialize+ to "prime
266
+ # the pump" in normal cases.
208
267
 
209
- def hash # :nodoc:
210
- @version.hash
268
+ @segments ||= @version.scan(/[0-9a-z]+/i).map do |s|
269
+ /^\d+$/ =~ s ? s.to_i : s
270
+ end
211
271
  end
212
272
 
213
273
  ##
214
- # Return a new version object where the next to the last revision number is
215
- # one greater. (e.g. 5.3.1 => 5.4)
216
- #
217
- # Pre-release (alpha) parts are ignored. (e.g 5.3.1.b2 => 5.4)
274
+ # A recommended version for use with a ~> Requirement.
218
275
 
219
- def bump
220
- parts = parse_parts_from_version_string
221
- parts.pop while parts.any? { |part| part.alpha? }
222
- parts.pop if parts.size > 1
223
- parts[-1] = parts[-1].succ
224
- self.class.new(parts.join("."))
225
- end
276
+ def spermy_recommendation
277
+ segments = self.segments.dup
226
278
 
227
- def parse_parts_from_version_string # :nodoc:
228
- @version.to_s.scan(/[0-9a-z]+/i).map { |s| Part.new(s) }
229
- end
279
+ segments.pop while segments.any? { |s| String === s }
280
+ segments.pop while segments.size > 2
281
+ segments.push 0 while segments.size < 2
230
282
 
231
- def pretty_print(q) # :nodoc:
232
- q.text "Gem::Version.new(#{@version.inspect})"
283
+ "~> #{segments.join(".")}"
233
284
  end
234
285
 
235
- #:stopdoc:
286
+ ##
287
+ # Compares this version with +other+ returning -1, 0, or 1 if the other
288
+ # version is larger, the same, or smaller than this one.
236
289
 
237
- require 'rubygems/requirement'
290
+ def <=> other
291
+ return 1 unless other # HACK: comparable with nil? why?
292
+ return nil unless self.class === other
238
293
 
239
- ##
240
- # Gem::Requirement's original definition is nested in Version.
241
- # Although an inappropriate place, current gems specs reference the nested
242
- # class name explicitly. To remain compatible with old software loading
243
- # gemspecs, we leave a copy of original definition in Version, but define an
244
- # alias Gem::Requirement for use everywhere else.
294
+ lhsize = segments.size
295
+ rhsize = other.segments.size
296
+ limit = (lhsize > rhsize ? lhsize : rhsize) - 1
245
297
 
246
- Requirement = ::Gem::Requirement
298
+ 0.upto(limit) do |i|
299
+ lhs, rhs = segments[i] || 0, other.segments[i] || 0
247
300
 
248
- # :startdoc:
301
+ return -1 if String === lhs && Numeric === rhs
302
+ return 1 if Numeric === lhs && String === rhs
303
+ return lhs <=> rhs if lhs != rhs
304
+ end
249
305
 
306
+ return 0
307
+ end
250
308
  end
251
-
@@ -6,10 +6,14 @@
6
6
 
7
7
  require 'rubygems'
8
8
 
9
+ ##
9
10
  # Mixin methods for --version and --platform Gem::Command options.
11
+
10
12
  module Gem::VersionOption
11
13
 
14
+ ##
12
15
  # Add the --platform option to the option parser.
16
+
13
17
  def add_platform_option(task = command, *wrap)
14
18
  OptionParser.accept Gem::Platform do |value|
15
19
  if value == Gem::Platform::RUBY then
@@ -31,7 +35,19 @@ module Gem::VersionOption
31
35
  end
32
36
  end
33
37
 
38
+ ##
39
+ # Add the --prerelease option to the option parser.
40
+
41
+ def add_prerelease_option(*wrap)
42
+ add_option("--[no-]prerelease",
43
+ "Allow prerelease versions of a gem", *wrap) do |value, options|
44
+ options[:prerelease] = value
45
+ end
46
+ end
47
+
48
+ ##
34
49
  # Add the --version option to the option parser.
50
+
35
51
  def add_version_option(task = command, *wrap)
36
52
  OptionParser.accept Gem::Requirement do |value|
37
53
  Gem::Requirement.new value