Commit 77f79910 authored by Danielle Tomlinson's avatar Danielle Tomlinson Committed by GitHub

Merge pull request #6049 from CocoaPods/orta-validator-swift

Adds support in the validator for expressing what version of Swift was used
parents 8ee37c39 46073589
...@@ -20,6 +20,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -20,6 +20,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Uku Loskit](https://github.com/UkuLoskit) [Uku Loskit](https://github.com/UkuLoskit)
[#6037](https://github.com/CocoaPods/CocoaPods/issues/6037) [#6037](https://github.com/CocoaPods/CocoaPods/issues/6037)
* The validator has an API for accessing which version of Swift was used.
[Orta Therox](https://github.com/orta)
[#6049](https://github.com/CocoaPods/CocoaPods/pull/6049)
##### Bug Fixes ##### Bug Fixes
......
...@@ -262,6 +262,13 @@ module Pod ...@@ -262,6 +262,13 @@ module Pod
swift_version_path.read if swift_version_path.exist? swift_version_path.read if swift_version_path.exist?
end end
# @return [String] A string representing the Swift version used during linting
# or nil, if Swift was not used.
#
def used_swift_version
swift_version if @installer.pod_targets.any?(&:uses_swift?)
end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
private private
......
...@@ -868,7 +868,29 @@ module Pod ...@@ -868,7 +868,29 @@ module Pod
validator.dot_swift_version.should == '1.0' validator.dot_swift_version.should == '1.0'
end end
end end
describe 'Getting the Swift value used by the validator' do
it 'passes nil when no targets have used Swift' do
validator = test_swiftpod
pod_target = stub(:uses_swift? => true)
installer = stub(:pod_targets => [pod_target])
validator.instance_variable_set(:@installer, installer)
validator.stubs(:dot_swift_version).returns('1.2.3')
validator.used_swift_version.should == '1.2.3'
end
it 'returns the swift_version when a target has used Swift' do
validator = test_swiftpod
pod_target = stub(:uses_swift? => false)
installer = stub(:pod_targets => [pod_target])
validator.instance_variable_set(:@installer, installer)
validator.used_swift_version.should.nil?
end
end
end 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