Class: Pod::Version
- Inherits:
-
Pod::Vendor::Gem::Version
- Object
- Pod::Vendor::Gem::Version
- Pod::Version
- Defined in:
- lib/cocoapods-core/version.rb
Overview
The Version class stores information about the version of a Specification.
It is based on the RubyGems class adapted to support head information.
### From RubyGems:
The Version class processes string versions into comparable values. A version string should normally be a series of numbers separated by periods. Each part (digits separated by periods) is considered its own number, and these are used for sorting. So for instance, 3.10 sorts higher than 3.2 because ten is greater than two.
If any part contains letters (currently only a-z are supported) then that version is considered prerelease. Versions with a prerelease part in the Nth part sort less than versions with N-1 parts. Prerelease parts are sorted alphabetically using the normal Ruby string sorting rules. If a prerelease part contains both letters and numbers, it will be broken into multiple parts to provide expected sort behavior (1.0.a10 becomes 1.0.a.10, and is greater than 1.0.a9).
Prereleases sort between real releases (newest to oldest):
-
1.0
-
1.0.b1
-
1.0.a.2
-
0.9
Constant Summary collapse
- VERSION_PATTERN =
Override the constants defined by the superclass to add Semantic Versioning prerelease support (with a dash). E.g.: 1.0.0-alpha1
For more info, see: semver.org
'[0-9]+(\.[0-9a-zA-Z\-]+)*'
- ANCHORED_VERSION_PATTERN =
/\A\s*(#{VERSION_PATTERN})*\s*\z/
Constants inherited from Pod::Vendor::Gem::Version
Pod::Vendor::Gem::Version::Requirement
Instance Attribute Summary collapse
-
#head ⇒ Bool
(also: #head?)
Whether the version represents the ‘head` of repository.
Attributes inherited from Pod::Vendor::Gem::Version
Class Method Summary collapse
-
.correct?(version) ⇒ Bool
Whether a string representation is correct.
Instance Method Summary collapse
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
-
#inspect ⇒ String
A string representation suitable for debugging.
-
#prerelease? ⇒ Boolean
Indicates whether or not the version is a prerelease.
-
#to_s ⇒ String
A string representation that indicates if the version is head.
Methods inherited from Pod::Vendor::Gem::Version
#<=>, #bump, create, #eql?, #hash, #init_with, #marshal_dump, #marshal_load, #pretty_print, #release, #segments, #spermy_recommendation, #yaml_initialize
Constructor Details
#initialize(version) ⇒ Version
The ‘from` part of the regular expression should be remove in CocoaPods 1.0.0.
Returns a new instance of Version.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cocoapods-core/version.rb', line 54 def initialize(version) if version.is_a?(Version) && version.head? version = version.version @head = true elsif version.is_a?(String) && version =~ /HEAD (based on|from) (.*)/ version = $2 @head = true end super(version) end |
Instance Attribute Details
#head ⇒ Bool Also known as: head?
Returns whether the version represents the ‘head` of repository.
45 46 47 |
# File 'lib/cocoapods-core/version.rb', line 45 def head @head end |
Class Method Details
.correct?(version) ⇒ Bool
Returns Whether a string representation is correct.
97 98 99 |
# File 'lib/cocoapods-core/version.rb', line 97 def self.correct? version version.to_s =~ ANCHORED_VERSION_PATTERN end |
Instance Method Details
#inspect ⇒ String
Returns a string representation suitable for debugging.
80 81 82 |
# File 'lib/cocoapods-core/version.rb', line 80 def inspect "<#{self.class} version=#{self.version}>" end |
#prerelease? ⇒ Boolean
Prerelease Pods can contain a hyphen and/or a letter (conforms to Semantic Versioning instead of RubyGems).
For more info, see: semver.org
Returns indicates whether or not the version is a prerelease.
91 92 93 |
# File 'lib/cocoapods-core/version.rb', line 91 def prerelease? @prerelease ||= @version =~ /[a-zA-Z\-]/ end |
#to_s ⇒ String
Adding the head information to the string representation creates issues (see Dependency#requirement).
The raw version string is still accessible with the Pod::Vendor::Gem::Version#version method.
Returns a string representation that indicates if the version is head.
74 75 76 |
# File 'lib/cocoapods-core/version.rb', line 74 def to_s head? ? "HEAD based on #{super}" : super end |