cocoapods-core 0.27.1 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cocoapods-core.rb +0 -2
  3. data/lib/cocoapods-core/core_ui.rb +0 -1
  4. data/lib/cocoapods-core/dependency.rb +20 -15
  5. data/lib/cocoapods-core/gem_version.rb +1 -1
  6. data/lib/cocoapods-core/github.rb +1 -1
  7. data/lib/cocoapods-core/lockfile.rb +15 -11
  8. data/lib/cocoapods-core/platform.rb +10 -6
  9. data/lib/cocoapods-core/podfile.rb +18 -11
  10. data/lib/cocoapods-core/podfile/dsl.rb +25 -23
  11. data/lib/cocoapods-core/podfile/target_definition.rb +60 -36
  12. data/lib/cocoapods-core/requirement.rb +2 -2
  13. data/lib/cocoapods-core/source.rb +34 -10
  14. data/lib/cocoapods-core/source/acceptor.rb +12 -8
  15. data/lib/cocoapods-core/source/aggregate.rb +22 -9
  16. data/lib/cocoapods-core/source/health_reporter.rb +2 -2
  17. data/lib/cocoapods-core/specification.rb +14 -12
  18. data/lib/cocoapods-core/specification/consumer.rb +8 -6
  19. data/lib/cocoapods-core/specification/dsl.rb +66 -18
  20. data/lib/cocoapods-core/specification/dsl/attribute.rb +5 -4
  21. data/lib/cocoapods-core/specification/dsl/deprecations.rb +35 -23
  22. data/lib/cocoapods-core/specification/dsl/platform_proxy.rb +16 -11
  23. data/lib/cocoapods-core/specification/linter.rb +107 -36
  24. data/lib/cocoapods-core/specification/root_attribute_accessors.rb +16 -4
  25. data/lib/cocoapods-core/specification/set.rb +41 -24
  26. data/lib/cocoapods-core/specification/set/presenter.rb +7 -5
  27. data/lib/cocoapods-core/specification/yaml.rb +6 -2
  28. data/lib/cocoapods-core/standard_error.rb +3 -3
  29. data/lib/cocoapods-core/vendor.rb +0 -1
  30. data/lib/cocoapods-core/vendor/requirement.rb +9 -9
  31. data/lib/cocoapods-core/vendor/version.rb +143 -140
  32. data/lib/cocoapods-core/version.rb +5 -6
  33. data/lib/cocoapods-core/yaml_converter.rb +3 -2
  34. metadata +17 -3
@@ -29,7 +29,11 @@ module Pod
29
29
  # robust handling of head versions (like a dedicated section).
30
30
  #
31
31
  def version
32
- @version ||= root? ? Version.new(attributes_hash["version"]) : root.version
32
+ if root?
33
+ @version ||= Version.new(attributes_hash["version"])
34
+ else
35
+ @version ||= root.version
36
+ end
33
37
  end
34
38
 
35
39
  # @return [Hash] a hash containing the authors as the keys and their
@@ -63,6 +67,12 @@ module Pod
63
67
  end
64
68
  end
65
69
 
70
+ # @return [String] The social media URL.
71
+ #
72
+ def social_media_url
73
+ attributes_hash["social_media_url"]
74
+ end
75
+
66
76
  # @return [Hash] A hash containing the license information of the Pod.
67
77
  #
68
78
  # @note The indentation is stripped from the license text.
@@ -108,8 +118,8 @@ module Pod
108
118
  description.strip_heredoc if description
109
119
  end
110
120
 
111
- # @return [Array<String>] The list of the URL for the screenshots of the
112
- # Pod.
121
+ # @return [Array<String>] The list of the URL for the screenshots of
122
+ # the Pod.
113
123
  #
114
124
  # @note The value is coerced to an array.
115
125
  #
@@ -130,7 +140,7 @@ module Pod
130
140
  attributes_hash["prepare_command"]
131
141
  end
132
142
 
133
- #-----------------------------------------------------------------------#
143
+ #---------------------------------------------------------------------#
134
144
 
135
145
  private
136
146
 
@@ -151,6 +161,8 @@ module Pod
151
161
  result
152
162
  end
153
163
 
164
+ #---------------------------------------------------------------------#
165
+
154
166
  end
155
167
  end
156
168
  end
@@ -1,9 +1,7 @@
1
1
  require 'active_support/core_ext/array/conversions'
2
-
3
2
  require 'cocoapods-core/specification/set/presenter'
4
3
  require 'cocoapods-core/specification/set/statistics'
5
4
 
6
-
7
5
  module Pod
8
6
  class Specification
9
7
 
@@ -38,7 +36,7 @@ module Pod
38
36
  @name = name
39
37
  sources = sources.is_a?(Array) ? sources : [sources]
40
38
  @sources = sources.sort_by(&:name)
41
- @required_by = []
39
+ @dependencies_by_requirer_name = {}
42
40
  @dependencies = []
43
41
  end
44
42
 
@@ -60,19 +58,26 @@ module Pod
60
58
  # @return [void]
61
59
  #
62
60
  def required_by(dependency, dependent_name)
63
- unless @required_by.empty? || dependency.requirement.satisfied_by?(Version.new(required_version.to_s))
64
- raise Informative, "#{dependent_name} tries to activate `#{dependency}', but already activated version `#{required_version}' by #{@required_by.to_sentence}."
61
+ dependencies_by_requirer_name[dependent_name] ||= []
62
+ dependencies_by_requirer_name[dependent_name] << dependency
63
+ dependencies << dependency
64
+
65
+ if acceptable_versions.empty?
66
+ message = "Unable to satisfy the following requirements:\n"
67
+ dependencies_by_requirer_name.each do |name, dependencies|
68
+ dependencies.each do |dep|
69
+ message << "- `#{dep.to_s}` required by `#{name}`"
70
+ end
71
+ end
72
+ raise Informative, message
65
73
  end
66
- @specification = nil
67
- @required_by << dependent_name
68
- @dependencies << dependency
69
74
  end
70
75
 
71
- # @return [Dependency] a dependency that includes all the versions
76
+ # @return [Dependency] A dependency that includes all the versions
72
77
  # requirements of the stored dependencies.
73
78
  #
74
79
  def dependency
75
- @dependencies.inject(Dependency.new(name)) do |previous, dependency|
80
+ dependencies.reduce(Dependency.new(name)) do |previous, dependency|
76
81
  previous.merge(dependency.to_root_dependency)
77
82
  end
78
83
  end
@@ -85,9 +90,12 @@ module Pod
85
90
  # used to disambiguate.
86
91
  #
87
92
  def specification
88
- @specification ||= Specification.from_file(specification_path_for_version(required_version))
93
+ path = specification_path_for_version(required_version)
94
+ Specification.from_file(path)
89
95
  end
90
96
 
97
+ # TODO
98
+ #
91
99
  def specification_path_for_version(version)
92
100
  sources = []
93
101
  versions_by_source.each do |source, source_versions|
@@ -111,6 +119,13 @@ module Pod
111
119
  version
112
120
  end
113
121
 
122
+ # @return [Array<Version>] All the versions which are acceptable given
123
+ # the requirements.
124
+ #
125
+ def acceptable_versions
126
+ versions.select { |v| dependency.match?(name, v) }
127
+ end
128
+
114
129
  # @return [Array<Version>] all the available versions for the Pod, sorted
115
130
  # from highest to lowest.
116
131
  #
@@ -142,11 +157,14 @@ module Pod
142
157
  end
143
158
 
144
159
  def ==(other)
145
- self.class === other && @name == other.name && @sources.map(&:name) == other.sources.map(&:name)
160
+ self.class == other.class &&
161
+ @name == other.name &&
162
+ @sources.map(&:name) == other.sources.map(&:name)
146
163
  end
147
164
 
148
165
  def to_s
149
- "#<#{self.class.name} for `#{name}' with required version `#{required_version}' available at `#{sources.map(&:name) * ', '}'>"
166
+ "#<#{self.class.name} for `#{name}' with required version " \
167
+ "`#{required_version}' available at `#{sources.map(&:name) * ', '}'>"
150
168
  end
151
169
  alias_method :inspect, :to_s
152
170
 
@@ -162,8 +180,9 @@ module Pod
162
180
  # @return [Hash] The hash representation.
163
181
  #
164
182
  def to_hash
165
- versions = versions_by_source.inject({}) do |memo, (source, version)|
166
- memo[source.name] = version.map(&:to_s); memo
183
+ versions = versions_by_source.reduce({}) do |memo, (source, version)|
184
+ memo[source.name] = version.map(&:to_s)
185
+ memo
167
186
  end
168
187
  {
169
188
  'name' => name,
@@ -175,6 +194,11 @@ module Pod
175
194
 
176
195
  #-----------------------------------------------------------------------#
177
196
 
197
+ attr_accessor :dependencies_by_requirer_name
198
+ attr_accessor :dependencies
199
+
200
+ #-----------------------------------------------------------------------#
201
+
178
202
  # The Set::External class handles Pods from external sources. Pods from
179
203
  # external sources don't use the {Source} and are initialized by a given
180
204
  # specification.
@@ -191,14 +215,7 @@ module Pod
191
215
  end
192
216
 
193
217
  def ==(other)
194
- self.class === other && @specification == other.specification
195
- end
196
-
197
- def required_by(dependency, dependent_name)
198
- before = @specification
199
- super(dependency, dependent_name)
200
- ensure
201
- @specification = before
218
+ self.class == other.class && specification == other.specification
202
219
  end
203
220
 
204
221
  def specification_path
@@ -206,7 +223,7 @@ module Pod
206
223
  end
207
224
 
208
225
  def versions
209
- [@specification.version]
226
+ [specification.version]
210
227
  end
211
228
  end
212
229
  end
@@ -82,7 +82,7 @@ module Pod
82
82
  # highest available version.
83
83
  #
84
84
  def spec
85
- @set.specification
85
+ @spec ||= @set.specification
86
86
  end
87
87
 
88
88
  # @return [String] the list of the authors of the Pod in sentence
@@ -128,7 +128,7 @@ module Pod
128
128
  # @return [String] the URL of the source of the Pod.
129
129
  #
130
130
  def source_url
131
- url_keys = [:git, :svn, :http, :hg, :path ]
131
+ url_keys = [:git, :svn, :http, :hg, :path]
132
132
  key = spec.source.keys.find { |k| url_keys.include?(k) }
133
133
  key ? spec.source[key] : 'No source url'
134
134
  end
@@ -141,7 +141,10 @@ module Pod
141
141
  # "iOS - OS X"
142
142
  #
143
143
  def platform
144
- spec.available_platforms.sort { |a,b| a.to_s.downcase <=> b.to_s.downcase }.join(' - ')
144
+ sorted_platforms = spec.available_platforms.sort do |a, b|
145
+ a.to_s.downcase <=> b.to_s.downcase
146
+ end
147
+ sorted_platforms.join(' - ')
145
148
  end
146
149
 
147
150
  # @return [String] the type of the license of the Pod.
@@ -212,7 +215,7 @@ module Pod
212
215
  return nil unless from_time
213
216
  from_time = Time.parse(from_time) unless from_time.is_a?(Time)
214
217
  to_time = Time.now
215
- distance_in_days = (((to_time - from_time).abs)/60/60/24).round
218
+ distance_in_days = (((to_time - from_time).abs) / 60 / 60 / 24).round
216
219
 
217
220
  case distance_in_days
218
221
  when 0..7
@@ -234,4 +237,3 @@ module Pod
234
237
  end
235
238
  end
236
239
  end
237
-
@@ -13,7 +13,9 @@ module Pod
13
13
  #
14
14
  def to_hash
15
15
  hash = attributes_hash.dup
16
- hash["subspecs"] = subspecs.map { |spec| spec.to_hash } unless subspecs.empty?
16
+ unless subspecs.empty?
17
+ hash["subspecs"] = subspecs.map { |spec| spec.to_hash }
18
+ end
17
19
  hash
18
20
  end
19
21
 
@@ -39,7 +41,9 @@ module Pod
39
41
  subspecs = attributes_hash.delete('subspecs')
40
42
  spec.attributes_hash = attributes_hash
41
43
  if subspecs
42
- spec.subspecs = subspecs.map { |s_hash| Specification.from_hash(s_hash, spec) }
44
+ spec.subspecs = subspecs.map do |s_hash|
45
+ Specification.from_hash(s_hash, spec)
46
+ end
43
47
  end
44
48
  spec
45
49
  end
@@ -67,11 +67,11 @@ module Pod
67
67
  lines = File.readlines(dsl_path.to_s)
68
68
  indent = " # "
69
69
  indicator = indent.dup.gsub("#", ">")
70
- first_line = ( line_numer.zero? )
71
- last_line = ( line_numer == (lines.count - 1) )
70
+ first_line = (line_numer.zero?)
71
+ last_line = (line_numer == (lines.count - 1))
72
72
 
73
73
  m << "\n"
74
- m << "#{indent}from #{trace_line.gsub(/:in.*$/,'')}\n"
74
+ m << "#{indent}from #{trace_line.gsub(/:in.*$/, '')}\n"
75
75
  m << "#{indent}-------------------------------------------\n"
76
76
  m << "#{indent}#{ lines[line_numer - 1] }" unless first_line
77
77
  m << "#{indicator}#{ lines[line_numer] }"
@@ -52,4 +52,3 @@ module Pod
52
52
  end
53
53
  end
54
54
  end
55
-
@@ -38,7 +38,7 @@ module Pod::Vendor
38
38
  # If the input is "weird", the default version requirement is
39
39
  # returned.
40
40
 
41
- def self.create input
41
+ def self.create(input)
42
42
  case input
43
43
  when Gem::Requirement then
44
44
  input
@@ -76,14 +76,14 @@ module Pod::Vendor
76
76
  # parse("1.0") # => ["=", "1.0"]
77
77
  # parse(Gem::Version.new("1.0")) # => ["=, "1.0"]
78
78
 
79
- def self.parse obj
79
+ def self.parse(obj)
80
80
  return ["=", obj] if Gem::Version === obj
81
81
 
82
82
  unless PATTERN =~ obj.to_s
83
83
  raise ArgumentError, "Illformed requirement [#{obj.inspect}]"
84
84
  end
85
85
 
86
- [$1 || "=", Gem::Version.new($2)]
86
+ [Regexp.last_match[1] || "=", Gem::Version.new(Regexp.last_match[2])]
87
87
  end
88
88
 
89
89
  ##
@@ -98,7 +98,7 @@ module Pod::Vendor
98
98
  # requirements are ignored. An empty set of +requirements+ is the
99
99
  # same as <tt>">= 0"</tt>.
100
100
 
101
- def initialize *requirements
101
+ def initialize(*requirements)
102
102
  requirements = requirements.flatten
103
103
  requirements.compact!
104
104
  requirements.uniq!
@@ -126,7 +126,7 @@ module Pod::Vendor
126
126
  [@requirements]
127
127
  end
128
128
 
129
- def marshal_load array # :nodoc:
129
+ def marshal_load(array) # :nodoc:
130
130
  @requirements = array[0]
131
131
 
132
132
  fix_syck_default_key_in_requirements
@@ -140,7 +140,7 @@ module Pod::Vendor
140
140
  fix_syck_default_key_in_requirements
141
141
  end
142
142
 
143
- def init_with coder # :nodoc:
143
+ def init_with(coder) # :nodoc:
144
144
  yaml_initialize coder.tag, coder.map
145
145
  end
146
146
 
@@ -148,7 +148,7 @@ module Pod::Vendor
148
148
  requirements.any? { |r| r.last.prerelease? }
149
149
  end
150
150
 
151
- def pretty_print q # :nodoc:
151
+ def pretty_print(q) # :nodoc:
152
152
  q.group 1, 'Gem::Requirement.new(', ')' do
153
153
  q.pp as_list
154
154
  end
@@ -157,7 +157,7 @@ module Pod::Vendor
157
157
  ##
158
158
  # True if +version+ satisfies this Requirement.
159
159
 
160
- def satisfied_by? version
160
+ def satisfied_by?(version)
161
161
  # #28965: syck has a bug with unquoted '=' YAML.loading as YAML::DefaultKey
162
162
  requirements.all? { |op, rv| (OPS[op] || OPS["="]).call version, rv }
163
163
  end
@@ -178,7 +178,7 @@ module Pod::Vendor
178
178
  as_list.join ", "
179
179
  end
180
180
 
181
- def <=> other # :nodoc:
181
+ def <=>(other) # :nodoc:
182
182
  to_s <=> other.to_s
183
183
  end
184
184
 
@@ -142,192 +142,195 @@ module Pod::Vendor
142
142
  # "~> 3.5" 3.5 ... 4.0
143
143
  # "~> 3.5.0" 3.5.0 ... 3.6
144
144
 
145
- class Gem::Version
146
- autoload :Requirement, 'rubygems/requirement'
145
+ module Gem
146
+ class Version
147
+ autoload :Requirement, 'rubygems/requirement'
147
148
 
148
- include Comparable
149
+ include Comparable
149
150
 
150
- VERSION_PATTERN = '[0-9]+(\.[0-9a-zA-Z]+)*' # :nodoc:
151
- ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})*\s*\z/ # :nodoc:
151
+ VERSION_PATTERN = '[0-9]+(\.[0-9a-zA-Z]+)*' # :nodoc:
152
+ ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})*\s*\z/ # :nodoc:
152
153
 
153
- ##
154
- # A string representation of this Version.
154
+ ##
155
+ # A string representation of this Version.
155
156
 
156
- attr_reader :version
157
- alias to_s version
157
+ attr_reader :version
158
+ alias to_s version
158
159
 
159
- ##
160
- # True if the +version+ string matches RubyGems' requirements.
160
+ ##
161
+ # True if the +version+ string matches RubyGems' requirements.
161
162
 
162
- def self.correct? version
163
- version.to_s =~ ANCHORED_VERSION_PATTERN
164
- end
163
+ def self.correct?(version)
164
+ version.to_s =~ ANCHORED_VERSION_PATTERN
165
+ end
165
166
 
166
- ##
167
- # Factory method to create a Version object. Input may be a Version
168
- # or a String. Intended to simplify client code.
169
- #
170
- # ver1 = Version.create('1.3.17') # -> (Version object)
171
- # ver2 = Version.create(ver1) # -> (ver1)
172
- # ver3 = Version.create(nil) # -> nil
173
-
174
- def self.create input
175
- if input.respond_to? :version then
176
- input
177
- elsif input.nil? then
178
- nil
179
- else
180
- new input
167
+ ##
168
+ # Factory method to create a Version object. Input may be a Version
169
+ # or a String. Intended to simplify client code.
170
+ #
171
+ # ver1 = Version.create('1.3.17') # -> (Version object)
172
+ # ver2 = Version.create(ver1) # -> (ver1)
173
+ # ver3 = Version.create(nil) # -> nil
174
+
175
+ def self.create(input)
176
+ if input.respond_to? :version then
177
+ input
178
+ elsif input.nil? then
179
+ nil
180
+ else
181
+ new input
182
+ end
181
183
  end
182
- end
183
184
 
184
- ##
185
- # Constructs a Version from the +version+ string. A version string is a
186
- # series of digits or ASCII letters separated by dots.
185
+ ##
186
+ # Constructs a Version from the +version+ string. A version string is a
187
+ # series of digits or ASCII letters separated by dots.
187
188
 
188
- def initialize version
189
- raise ArgumentError, "Malformed version number string #{version}" unless
190
- self.class.correct?(version)
189
+ def initialize(version)
190
+ unless self.class.correct?(version)
191
+ raise ArgumentError, "Malformed version number string #{version}"
192
+ end
191
193
 
192
- @version = version.to_s
193
- @version.strip!
194
- end
194
+ @version = version.to_s
195
+ @version.strip!
196
+ end
195
197
 
196
- ##
197
- # Return a new version object where the next to the last revision
198
- # number is one greater (e.g., 5.3.1 => 5.4).
199
- #
200
- # Pre-release (alpha) parts, e.g, 5.3.1.b.2 => 5.4, are ignored.
198
+ ##
199
+ # Return a new version object where the next to the last revision
200
+ # number is one greater (e.g., 5.3.1 => 5.4).
201
+ #
202
+ # Pre-release (alpha) parts, e.g, 5.3.1.b.2 => 5.4, are ignored.
201
203
 
202
- def bump
203
- segments = self.segments.dup
204
- segments.pop while segments.any? { |s| String === s }
205
- segments.pop if segments.size > 1
204
+ def bump
205
+ segments = self.segments.dup
206
+ segments.pop while segments.any? { |s| String === s }
207
+ segments.pop if segments.size > 1
206
208
 
207
- segments[-1] = segments[-1].succ
208
- self.class.new segments.join(".")
209
- end
209
+ segments[-1] = segments[-1].succ
210
+ self.class.new segments.join(".")
211
+ end
210
212
 
211
- ##
212
- # A Version is only eql? to another version if it's specified to the
213
- # same precision. Version "1.0" is not the same as version "1".
213
+ ##
214
+ # A Version is only eql? to another version if it's specified to the
215
+ # same precision. Version "1.0" is not the same as version "1".
214
216
 
215
- def eql? other
216
- self.class === other and @version == other.version
217
- end
217
+ def eql?(other)
218
+ self.class === other and @version == other.version
219
+ end
218
220
 
219
- def hash # :nodoc:
220
- @hash ||= segments.hash
221
- end
221
+ def hash # :nodoc:
222
+ @hash ||= segments.hash
223
+ end
222
224
 
223
- def init_with coder # :nodoc:
224
- yaml_initialize coder.tag, coder.map
225
- end
225
+ def init_with(coder) # :nodoc:
226
+ yaml_initialize coder.tag, coder.map
227
+ end
226
228
 
227
- def inspect # :nodoc:
228
- "#<#{self.class} #{version.inspect}>"
229
- end
229
+ def inspect # :nodoc:
230
+ "#<#{self.class} #{version.inspect}>"
231
+ end
230
232
 
231
- ##
232
- # Dump only the raw version string, not the complete object. It's a
233
- # string for backwards (RubyGems 1.3.5 and earlier) compatibility.
233
+ ##
234
+ # Dump only the raw version string, not the complete object. It's a
235
+ # string for backwards (RubyGems 1.3.5 and earlier) compatibility.
234
236
 
235
- def marshal_dump
236
- [version]
237
- end
237
+ def marshal_dump
238
+ [version]
239
+ end
238
240
 
239
- ##
240
- # Load custom marshal format. It's a string for backwards (RubyGems
241
- # 1.3.5 and earlier) compatibility.
241
+ ##
242
+ # Load custom marshal format. It's a string for backwards (RubyGems
243
+ # 1.3.5 and earlier) compatibility.
242
244
 
243
- def marshal_load array
244
- initialize array[0]
245
- end
245
+ def marshal_load(array)
246
+ initialize array[0]
247
+ end
246
248
 
247
- def yaml_initialize(tag, map)
248
- @version = map['version']
249
- @segments = nil
250
- @hash = nil
251
- end
249
+ def yaml_initialize(tag, map)
250
+ @version = map['version']
251
+ @segments = nil
252
+ @hash = nil
253
+ end
252
254
 
253
- ##
254
- # A version is considered a prerelease if it contains a letter.
255
+ ##
256
+ # A version is considered a prerelease if it contains a letter.
255
257
 
256
- def prerelease?
257
- @prerelease ||= @version =~ /[a-zA-Z]/
258
- end
258
+ def prerelease?
259
+ @prerelease ||= @version =~ /[a-zA-Z]/
260
+ end
259
261
 
260
- def pretty_print q # :nodoc:
261
- q.text "Gem::Version.new(#{version.inspect})"
262
- end
262
+ def pretty_print(q) # :nodoc:
263
+ q.text "Gem::Version.new(#{version.inspect})"
264
+ end
263
265
 
264
- ##
265
- # The release for this version (e.g. 1.2.0.a -> 1.2.0).
266
- # Non-prerelease versions return themselves.
266
+ ##
267
+ # The release for this version (e.g. 1.2.0.a -> 1.2.0).
268
+ # Non-prerelease versions return themselves.
267
269
 
268
- def release
269
- return self unless prerelease?
270
+ def release
271
+ return self unless prerelease?
270
272
 
271
- segments = self.segments.dup
272
- segments.pop while segments.any? { |s| String === s }
273
- self.class.new segments.join('.')
274
- end
273
+ segments = self.segments.dup
274
+ segments.pop while segments.any? { |s| String === s }
275
+ self.class.new segments.join('.')
276
+ end
275
277
 
276
- def segments # :nodoc:
278
+ def segments # :nodoc:
277
279
 
278
- # segments is lazy so it can pick up version values that come from
279
- # old marshaled versions, which don't go through marshal_load.
280
+ # segments is lazy so it can pick up version values that come from
281
+ # old marshaled versions, which don't go through marshal_load.
280
282
 
281
- @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
282
- /^\d+$/ =~ s ? s.to_i : s
283
- end
284
- end
283
+ @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
284
+ /^\d+$/ =~ s ? s.to_i : s
285
+ end
286
+ end
285
287
 
286
- ##
287
- # A recommended version for use with a ~> Requirement.
288
+ ##
289
+ # A recommended version for use with a ~> Requirement.
288
290
 
289
- def spermy_recommendation
290
- segments = self.segments.dup
291
+ def spermy_recommendation
292
+ segments = self.segments.dup
291
293
 
292
- segments.pop while segments.any? { |s| String === s }
293
- segments.pop while segments.size > 2
294
- segments.push 0 while segments.size < 2
294
+ segments.pop while segments.any? { |s| String === s }
295
+ segments.pop while segments.size > 2
296
+ segments.push 0 while segments.size < 2
295
297
 
296
- "~> #{segments.join(".")}"
297
- end
298
+ "~> #{segments.join(".")}"
299
+ end
298
300
 
299
- ##
300
- # Compares this version with +other+ returning -1, 0, or 1 if the
301
- # other version is larger, the same, or smaller than this
302
- # one. Attempts to compare to something that's not a
303
- # <tt>Gem::Version</tt> return +nil+.
301
+ ##
302
+ # Compares this version with +other+ returning -1, 0, or 1 if the
303
+ # other version is larger, the same, or smaller than this
304
+ # one. Attempts to compare to something that's not a
305
+ # <tt>Gem::Version</tt> return +nil+.
304
306
 
305
- def <=> other
306
- return unless Gem::Version === other
307
- return 0 if @version == other.version
307
+ def <=>(other)
308
+ return unless Gem::Version === other
309
+ return 0 if @version == other.version
308
310
 
309
- lhsegments = segments
310
- rhsegments = other.segments
311
+ lhsegments = segments
312
+ rhsegments = other.segments
311
313
 
312
- lhsize = lhsegments.size
313
- rhsize = rhsegments.size
314
- limit = (lhsize > rhsize ? lhsize : rhsize) - 1
314
+ lhsize = lhsegments.size
315
+ rhsize = rhsegments.size
316
+ limit = (lhsize > rhsize ? lhsize : rhsize) - 1
315
317
 
316
- i = 0
318
+ i = 0
317
319
 
318
- while i <= limit
319
- lhs, rhs = lhsegments[i] || 0, rhsegments[i] || 0
320
- i += 1
320
+ while i <= limit
321
+ lhs, rhs = lhsegments[i] || 0, rhsegments[i] || 0
322
+ i += 1
321
323
 
322
- next if lhs == rhs
323
- return -1 if String === lhs && Numeric === rhs
324
- return 1 if Numeric === lhs && String === rhs
324
+ next if lhs == rhs
325
+ return -1 if String === lhs && Numeric === rhs
326
+ return 1 if Numeric === lhs && String === rhs
325
327
 
326
- return lhs <=> rhs
327
- end
328
+ return lhs <=> rhs
329
+ end
328
330
 
329
- return 0
331
+ 0
332
+ end
330
333
  end
331
- end
332
334
 
335
+ end
333
336
  end