Skip to content

Commit

Permalink
Merge pull request #434 from dnkoutso/change_sources_message
Browse files Browse the repository at this point in the history
Add ability to lockfile to retrieve spec repo for pod name
  • Loading branch information
dnkoutso authored Mar 6, 2018
2 parents 440ae0e + f5710a3 commit 57db34d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

##### Enhancements

* Add ability to lockfile to retrieve spec repo for pod name
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#434](https://github.com/CocoaPods/Core/pull/434)

* `HTTP::perform_head_request` now includes a 1-byte `Range` header in the fallback GET
request.
[Kyle Fleming](https://github.com/kylefleming)
Expand Down
27 changes: 25 additions & 2 deletions lib/cocoapods-core/lockfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def pod_names

# Returns the version of the given Pod.
#
# @param [name] The name of the Pod (root name of the specification).
# @param [String] pod_name The name of the Pod (root name of the specification).
#
# @return [Version] The version of the pod.
#
Expand All @@ -92,9 +92,21 @@ def version(pod_name)
pod_versions[root_name]
end

# Returns the source of the given Pod.
#
# @param [String] pod_name The name of the Pod (root name of the specification).
#
# @return [String] The source of the pod.
#
# @return [Nil] If there is no source stored for the given name.
#
def spec_repo(pod_name)
spec_repos_by_pod[pod_name]
end

# Returns the checksum for the given Pod.
#
# @param [name] The name of the Pod (root name of the specification).
# @param [String] name The name of the Pod (root name of the specification).
#
# @return [String] The checksum of the specification for the given Pod.
#
Expand Down Expand Up @@ -236,6 +248,17 @@ def checksum_data
internal_data['SPEC CHECKSUMS'] || {}
end

# @return [Hash{String => String}] A hash containing the spec repo used for the specification
# by the name of the root spec.
#
def spec_repos_by_pod
@spec_repos_by_pod ||= pods_by_spec_repo.each_with_object({}) do |(spec_repo, pods), spec_repos_by_pod|
pods.each do |pod|
spec_repos_by_pod[pod] = spec_repo
end
end
end

#-------------------------------------------------------------------------#

# !@group Comparison with a Podfile
Expand Down
6 changes: 6 additions & 0 deletions spec/lockfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ def self.specs_by_source
@lockfile.version('BananaLib').should == Version.new('1.0')
end

it 'returns the spec repo of a given pod' do
@lockfile.spec_repo('BananaLib').should == 'https://github.com/CocoaPods/Specs.git'
@lockfile.spec_repo('JSONKit').should.be.nil
@lockfile.spec_repo('monkey').should == 'https://github.com/CocoaPods/Specs.git'
end

it 'returns the checksum for the given Pod' do
@lockfile.checksum('BananaLib').should == 'd46ca864666e216300a0653de197668b12e732a1'
end
Expand Down

0 comments on commit 57db34d

Please sign in to comment.