diff --git a/lib/cocoapods-core/dependency.rb b/lib/cocoapods-core/dependency.rb index 0fcdea173..e7d5a7b31 100644 --- a/lib/cocoapods-core/dependency.rb +++ b/lib/cocoapods-core/dependency.rb @@ -109,11 +109,16 @@ def initialize(name = nil, *requirements) # one or more version restrictions). # def requirement - if specific_version - Requirement.new(Version.new(specific_version.version)) - else - @requirement - end + @specific_requirement || @requirement + end + + # @param [Version] version the specific version to point to + # + def specific_version=(version) + @specific_version = version + @specific_requirement = if version + Requirement.new(Version.new(version.version)) + end end # @return [Bool] whether the dependency points to a subspec. @@ -196,9 +201,9 @@ def compatible?(other) def ==(other) self.class == other.class && name == other.name && - requirement == other.requirement && external_source == other.external_source && - podspec_repo == other.podspec_repo + podspec_repo == other.podspec_repo && + requirement == other.requirement end alias_method :eql?, :== diff --git a/lib/cocoapods-core/source.rb b/lib/cocoapods-core/source.rb index 4ac95f000..d33087b6f 100644 --- a/lib/cocoapods-core/source.rb +++ b/lib/cocoapods-core/source.rb @@ -167,9 +167,11 @@ def versions(name) pod_dir = pod_path(name) return unless pod_dir.exist? @versions_by_name[name] ||= pod_dir.children.map do |v| + next nil unless v.directory? basename = v.basename.to_s + next unless basename[0, 1] != '.' begin - Version.new(basename) if v.directory? && basename[0, 1] != '.' + Version.new(basename) rescue ArgumentError raise Informative, 'An unexpected version directory ' \ "`#{basename}` was encountered for the " \ @@ -266,6 +268,11 @@ def search(query) query = query.root_name end + if (versions = @versions_by_name[query]) && !versions.empty? + set = set(query) + return set if set.specification_name == query + end + found = [] Pathname.glob(pod_path(query)) do |path| next unless Dir.foreach(path).any? { |child| child != '.' && child != '..' }