Commit 0350fff6 authored by Eloy Durán's avatar Eloy Durán

Improve Podfile.lock version when the `:head` option is used.

parent aad3fb48
...@@ -99,17 +99,17 @@ module Pod ...@@ -99,17 +99,17 @@ module Pod
# @example Strings examples # @example Strings examples
# "libPusher" # "libPusher"
# "libPusher (1.0)" # "libPusher (1.0)"
# "libPusher (HEAD from 1.0)" # "libPusher (HEAD based on 1.0)"
# "RestKit/JSON" # "RestKit/JSON"
# #
# @return [String, Version] The name and the version of a # @return [String, Version] The name and the version of a
# pod. # pod.
# #
def name_and_version_for_pod(string) def name_and_version_for_pod(string)
match_data = string.match(/(\S*) \((.*)\)/) match_data = string.match(/(\S*) \((.*)\)/)
name = match_data[1] name = match_data[1]
vers = Version.from_s(match_data[2]) vers = Version.from_string(match_data[2])
return [name, vers] [name, vers]
end end
# @param [String] The string that describes a {Dependency} generated # @param [String] The string that describes a {Dependency} generated
...@@ -241,7 +241,7 @@ module Pod ...@@ -241,7 +241,7 @@ module Pod
end end
end end
pod_and_deps = tmp.sort_by(&:first).map do |name, deps| pod_and_deps = tmp.sort_by(&:first).map do |name, deps|
deps.empty? ? name : {name => deps} deps.empty? ? name : { name => deps }
end end
hash["PODS"] = pod_and_deps hash["PODS"] = pod_and_deps
...@@ -253,7 +253,7 @@ module Pod ...@@ -253,7 +253,7 @@ module Pod
hash["EXTERNAL SOURCES"] = external_sources unless external_sources.empty? hash["EXTERNAL SOURCES"] = external_sources unless external_sources.empty?
checksums = {} checksums = {}
specs.select {|spec| !spec.defined_in_file.nil? }.each do |spec| specs.select { |spec| !spec.defined_in_file.nil? }.each do |spec|
checksum = Digest::SHA1.hexdigest(File.read(spec.defined_in_file)) checksum = Digest::SHA1.hexdigest(File.read(spec.defined_in_file))
checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode) checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode)
checksums[spec.name] = checksum checksums[spec.name] = checksum
......
...@@ -3,19 +3,23 @@ module Pod ...@@ -3,19 +3,23 @@ module Pod
# @returns A Version described by its #to_s method. # @returns A Version described by its #to_s method.
# #
def self.from_s(string) # @TODO The `from' part of the regexp should be remove before 1.0.0.
match = string.match(/HEAD from (.*)/) #
string = match[1] if match def self.from_string(string)
vers = Version.new(string) if string =~ /HEAD (based on|from) (.*)/
vers.head = true if match v = Version.new($2)
vers v.head = true
v
else
Version.new(string)
end
end end
attr_accessor :head attr_accessor :head
alias_method :head?, :head alias_method :head?, :head
def to_s def to_s
head? ? "HEAD from #{super}" : super head? ? "HEAD based on #{super}" : super
end end
end end
end end
......
...@@ -8,5 +8,21 @@ module Pod ...@@ -8,5 +8,21 @@ module Pod
version.head = true version.head = true
version.should.be.head version.should.be.head
end end
it "serializes to and from a string" do
version = Version.from_string('1.2.3')
version.to_s.should == '1.2.3'
version.should.not.be.head
version = Version.from_string('HEAD based on 1.2.3')
version.should.be.head
version.to_s.should == 'HEAD based on 1.2.3'
end
it "supports the previous way that a HEAD version was described" do
version = Version.from_string('HEAD from 1.2.3')
version.should.be.head
version.to_s.should == 'HEAD based on 1.2.3'
end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment