Skip to content

Commit

Permalink
Add ability to lockfile to retrieve spec repo for pod name
Browse files Browse the repository at this point in the history
  • Loading branch information
dnkoutso committed Feb 27, 2018
1 parent f55deb9 commit baf0568
Show file tree
Hide file tree
Showing 3 changed files with 24 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
16 changes: 14 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)
pods_by_spec_repo.detect { |key, values| break key if values.include?(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
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.include 'Core'
@lockfile.spec_repo('JSONKit').should.be.nil
@lockfile.spec_repo('monkey').should.include 'Core'
end

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

0 comments on commit baf0568

Please sign in to comment.