Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update CocoaPods version class to support prerelease version strings …

…that conform to the Semantic Versioning specification. fixes CocoaPods/Core#4
  • Loading branch information...
commit be56f5bc1d2b77ea10c3ff89217d3a3eb21c5892 1 parent 0a99b9d
Blake Watters authored
Showing with 21 additions and 4 deletions.
  1. +3 −4 lib/cocoapods-core/vendor/version.rb
  2. +18 −0 spec/version_spec.rb
7 lib/cocoapods-core/vendor/version.rb
View
@@ -147,7 +147,7 @@ class Gem::Version
include Comparable
- VERSION_PATTERN = '[0-9]+(\.[0-9a-zA-Z]+)*' # :nodoc:
+ VERSION_PATTERN = '[0-9]+(\.[0-9a-zA-Z\-]+)*' # :nodoc:
ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})*\s*\z/ # :nodoc:
##
@@ -251,10 +251,9 @@ def yaml_initialize(tag, map)
end
##
- # A version is considered a prerelease if it contains a letter.
-
+ # Prerelease Pods can contain a hyphen and/or a letter (conforms to Semantic Versioning instead of RubyGems)
def prerelease?
- @prerelease ||= @version =~ /[a-zA-Z]/
+ @prerelease ||= @version =~ /[a-zA-Z\-]/
end
def pretty_print q # :nodoc:
18 spec/version_spec.rb
View
@@ -43,6 +43,24 @@ module Pod
version.should.be.head
version.to_s.should == 'HEAD based on 1.2.3'
end
+
+ it "identifies release versions" do
+ version = Version.new('1.0.0')
+ version.should.not.be.prerelease
+ end
+
+ it "matches Semantic Version pre-release versions" do
+ version = Version.new('1.0.0a1')
+ version.should.be.prerelease
+ version = Version.new('1.0.0-alpha')
+ version.should.be.prerelease
+ version = Version.new('1.0.0-alpha.1')
+ version.should.be.prerelease
+ version = Version.new('1.0.0-0.3.7')
+ version.should.be.prerelease
+ version = Version.new('1.0.0-x.7.z.92')
+ version.should.be.prerelease
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.