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.
- checksums.yaml +4 -4
- data/lib/cocoapods-core.rb +0 -2
- data/lib/cocoapods-core/core_ui.rb +0 -1
- data/lib/cocoapods-core/dependency.rb +20 -15
- data/lib/cocoapods-core/gem_version.rb +1 -1
- data/lib/cocoapods-core/github.rb +1 -1
- data/lib/cocoapods-core/lockfile.rb +15 -11
- data/lib/cocoapods-core/platform.rb +10 -6
- data/lib/cocoapods-core/podfile.rb +18 -11
- data/lib/cocoapods-core/podfile/dsl.rb +25 -23
- data/lib/cocoapods-core/podfile/target_definition.rb +60 -36
- data/lib/cocoapods-core/requirement.rb +2 -2
- data/lib/cocoapods-core/source.rb +34 -10
- data/lib/cocoapods-core/source/acceptor.rb +12 -8
- data/lib/cocoapods-core/source/aggregate.rb +22 -9
- data/lib/cocoapods-core/source/health_reporter.rb +2 -2
- data/lib/cocoapods-core/specification.rb +14 -12
- data/lib/cocoapods-core/specification/consumer.rb +8 -6
- data/lib/cocoapods-core/specification/dsl.rb +66 -18
- data/lib/cocoapods-core/specification/dsl/attribute.rb +5 -4
- data/lib/cocoapods-core/specification/dsl/deprecations.rb +35 -23
- data/lib/cocoapods-core/specification/dsl/platform_proxy.rb +16 -11
- data/lib/cocoapods-core/specification/linter.rb +107 -36
- data/lib/cocoapods-core/specification/root_attribute_accessors.rb +16 -4
- data/lib/cocoapods-core/specification/set.rb +41 -24
- data/lib/cocoapods-core/specification/set/presenter.rb +7 -5
- data/lib/cocoapods-core/specification/yaml.rb +6 -2
- data/lib/cocoapods-core/standard_error.rb +3 -3
- data/lib/cocoapods-core/vendor.rb +0 -1
- data/lib/cocoapods-core/vendor/requirement.rb +9 -9
- data/lib/cocoapods-core/vendor/version.rb +143 -140
- data/lib/cocoapods-core/version.rb +5 -6
- data/lib/cocoapods-core/yaml_converter.rb +3 -2
- 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
|
-
|
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
|
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
|
-
@
|
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
|
-
|
64
|
-
|
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]
|
76
|
+
# @return [Dependency] A dependency that includes all the versions
|
72
77
|
# requirements of the stored dependencies.
|
73
78
|
#
|
74
79
|
def dependency
|
75
|
-
|
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
|
-
|
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
|
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
|
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.
|
166
|
-
memo[source.name] = version.map(&:to_s)
|
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
|
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
|
-
[
|
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
|
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
|
-
|
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
|
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 = (
|
71
|
-
last_line = (
|
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] }"
|
@@ -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
|
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
|
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
|
-
[
|
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
|
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
|
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
|
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
|
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?
|
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 <=>
|
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
|
-
|
146
|
-
|
145
|
+
module Gem
|
146
|
+
class Version
|
147
|
+
autoload :Requirement, 'rubygems/requirement'
|
147
148
|
|
148
|
-
|
149
|
+
include Comparable
|
149
150
|
|
150
|
-
|
151
|
-
|
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
|
-
|
154
|
+
##
|
155
|
+
# A string representation of this Version.
|
155
156
|
|
156
|
-
|
157
|
-
|
157
|
+
attr_reader :version
|
158
|
+
alias to_s version
|
158
159
|
|
159
|
-
|
160
|
-
|
160
|
+
##
|
161
|
+
# True if the +version+ string matches RubyGems' requirements.
|
161
162
|
|
162
|
-
|
163
|
-
|
164
|
-
|
163
|
+
def self.correct?(version)
|
164
|
+
version.to_s =~ ANCHORED_VERSION_PATTERN
|
165
|
+
end
|
165
166
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
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
|
-
|
186
|
-
|
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
|
-
|
189
|
-
|
190
|
-
|
189
|
+
def initialize(version)
|
190
|
+
unless self.class.correct?(version)
|
191
|
+
raise ArgumentError, "Malformed version number string #{version}"
|
192
|
+
end
|
191
193
|
|
192
|
-
|
193
|
-
|
194
|
-
|
194
|
+
@version = version.to_s
|
195
|
+
@version.strip!
|
196
|
+
end
|
195
197
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
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
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
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
|
-
|
208
|
-
|
209
|
-
|
209
|
+
segments[-1] = segments[-1].succ
|
210
|
+
self.class.new segments.join(".")
|
211
|
+
end
|
210
212
|
|
211
|
-
|
212
|
-
|
213
|
-
|
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
|
-
|
216
|
-
|
217
|
-
|
217
|
+
def eql?(other)
|
218
|
+
self.class === other and @version == other.version
|
219
|
+
end
|
218
220
|
|
219
|
-
|
220
|
-
|
221
|
-
|
221
|
+
def hash # :nodoc:
|
222
|
+
@hash ||= segments.hash
|
223
|
+
end
|
222
224
|
|
223
|
-
|
224
|
-
|
225
|
-
|
225
|
+
def init_with(coder) # :nodoc:
|
226
|
+
yaml_initialize coder.tag, coder.map
|
227
|
+
end
|
226
228
|
|
227
|
-
|
228
|
-
|
229
|
-
|
229
|
+
def inspect # :nodoc:
|
230
|
+
"#<#{self.class} #{version.inspect}>"
|
231
|
+
end
|
230
232
|
|
231
|
-
|
232
|
-
|
233
|
-
|
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
|
-
|
236
|
-
|
237
|
-
|
237
|
+
def marshal_dump
|
238
|
+
[version]
|
239
|
+
end
|
238
240
|
|
239
|
-
|
240
|
-
|
241
|
-
|
241
|
+
##
|
242
|
+
# Load custom marshal format. It's a string for backwards (RubyGems
|
243
|
+
# 1.3.5 and earlier) compatibility.
|
242
244
|
|
243
|
-
|
244
|
-
|
245
|
-
|
245
|
+
def marshal_load(array)
|
246
|
+
initialize array[0]
|
247
|
+
end
|
246
248
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
249
|
+
def yaml_initialize(tag, map)
|
250
|
+
@version = map['version']
|
251
|
+
@segments = nil
|
252
|
+
@hash = nil
|
253
|
+
end
|
252
254
|
|
253
|
-
|
254
|
-
|
255
|
+
##
|
256
|
+
# A version is considered a prerelease if it contains a letter.
|
255
257
|
|
256
|
-
|
257
|
-
|
258
|
-
|
258
|
+
def prerelease?
|
259
|
+
@prerelease ||= @version =~ /[a-zA-Z]/
|
260
|
+
end
|
259
261
|
|
260
|
-
|
261
|
-
|
262
|
-
|
262
|
+
def pretty_print(q) # :nodoc:
|
263
|
+
q.text "Gem::Version.new(#{version.inspect})"
|
264
|
+
end
|
263
265
|
|
264
|
-
|
265
|
-
|
266
|
-
|
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
|
-
|
269
|
-
|
270
|
+
def release
|
271
|
+
return self unless prerelease?
|
270
272
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
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
|
-
|
278
|
+
def segments # :nodoc:
|
277
279
|
|
278
|
-
|
279
|
-
|
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
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
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
|
-
|
288
|
+
##
|
289
|
+
# A recommended version for use with a ~> Requirement.
|
288
290
|
|
289
|
-
|
290
|
-
|
291
|
+
def spermy_recommendation
|
292
|
+
segments = self.segments.dup
|
291
293
|
|
292
|
-
|
293
|
-
|
294
|
-
|
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
|
-
|
297
|
-
|
298
|
+
"~> #{segments.join(".")}"
|
299
|
+
end
|
298
300
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
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
|
-
|
306
|
-
|
307
|
-
|
307
|
+
def <=>(other)
|
308
|
+
return unless Gem::Version === other
|
309
|
+
return 0 if @version == other.version
|
308
310
|
|
309
|
-
|
310
|
-
|
311
|
+
lhsegments = segments
|
312
|
+
rhsegments = other.segments
|
311
313
|
|
312
|
-
|
313
|
-
|
314
|
-
|
314
|
+
lhsize = lhsegments.size
|
315
|
+
rhsize = rhsegments.size
|
316
|
+
limit = (lhsize > rhsize ? lhsize : rhsize) - 1
|
315
317
|
|
316
|
-
|
318
|
+
i = 0
|
317
319
|
|
318
|
-
|
319
|
-
|
320
|
-
|
320
|
+
while i <= limit
|
321
|
+
lhs, rhs = lhsegments[i] || 0, rhsegments[i] || 0
|
322
|
+
i += 1
|
321
323
|
|
322
|
-
|
323
|
-
|
324
|
-
|
324
|
+
next if lhs == rhs
|
325
|
+
return -1 if String === lhs && Numeric === rhs
|
326
|
+
return 1 if Numeric === lhs && String === rhs
|
325
327
|
|
326
|
-
|
327
|
-
|
328
|
+
return lhs <=> rhs
|
329
|
+
end
|
328
330
|
|
329
|
-
|
331
|
+
0
|
332
|
+
end
|
330
333
|
end
|
331
|
-
end
|
332
334
|
|
335
|
+
end
|
333
336
|
end
|