Commit c1704945 authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Validator] take URLs instead of actual sources

parent 897dfd7b
...@@ -123,7 +123,7 @@ module Pod ...@@ -123,7 +123,7 @@ module Pod
@clean = argv.flag?('clean', true) @clean = argv.flag?('clean', true)
@subspecs = argv.flag?('subspecs', true) @subspecs = argv.flag?('subspecs', true)
@only_subspec = argv.option('subspec') @only_subspec = argv.option('subspec')
@sources = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',') @source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@podspecs_paths = argv.arguments! @podspecs_paths = argv.arguments!
super super
end end
...@@ -136,7 +136,7 @@ module Pod ...@@ -136,7 +136,7 @@ module Pod
UI.puts UI.puts
podspecs_to_lint.each do |podspec| podspecs_to_lint.each do |podspec|
validator = Validator.new(podspec, sources) validator = Validator.new(podspec, @source_urls)
validator.local = true validator.local = true
validator.quick = @quick validator.quick = @quick
validator.no_clean = !@clean validator.no_clean = !@clean
...@@ -169,10 +169,6 @@ module Pod ...@@ -169,10 +169,6 @@ module Pod
#----------------------------------------# #----------------------------------------#
def sources
@sources ||= @source_urls.map { |url| SourcesManager.find_or_create_source_with_url(url) }
end
# !@group Private helpers # !@group Private helpers
# @return [Pathname] The path of the podspec found in the current # @return [Pathname] The path of the podspec found in the current
......
...@@ -82,7 +82,7 @@ module Pod ...@@ -82,7 +82,7 @@ module Pod
def validate_podspec_files def validate_podspec_files
UI.puts "\nValidating #{'spec'.pluralize(count)}".yellow UI.puts "\nValidating #{'spec'.pluralize(count)}".yellow
podspec_files.each do |podspec| podspec_files.each do |podspec|
validator = Validator.new(podspec, SourcesManager.all) validator = Validator.new(podspec, SourcesManager.all.map(&:url))
validator.only_errors = @allow_warnings validator.only_errors = @allow_warnings
begin begin
validator.validate validator.validate
......
...@@ -87,7 +87,7 @@ module Pod ...@@ -87,7 +87,7 @@ module Pod
UI.puts UI.puts
invalid_count = 0 invalid_count = 0
podspecs_to_lint.each do |podspec| podspecs_to_lint.each do |podspec|
validator = Validator.new(podspec, sources) validator = Validator.new(podspec, @source_urls)
validator.quick = @quick validator.quick = @quick
validator.no_clean = !@clean validator.no_clean = !@clean
validator.only_errors = @only_errors validator.only_errors = @only_errors
...@@ -115,10 +115,6 @@ module Pod ...@@ -115,10 +115,6 @@ module Pod
private private
def sources
@sources ||= @source_urls.map { |url| SourcesManager.find_or_create_source_with_url(url) }
end
def podspecs_to_lint def podspecs_to_lint
@podspecs_to_lint ||= begin @podspecs_to_lint ||= begin
files = [] files = []
......
...@@ -19,8 +19,11 @@ module Pod ...@@ -19,8 +19,11 @@ module Pod
# @param [Specification, Pathname, String] spec_or_path # @param [Specification, Pathname, String] spec_or_path
# the Specification or the path of the `podspec` file to lint. # the Specification or the path of the `podspec` file to lint.
# #
def initialize(spec_or_path, sources) # @param [Array<String>] source_urls
@sources = sources # the Source URLs to use in creating a {Podfile}.
#
def initialize(spec_or_path, source_urls)
@source_urls = source_urls
@linter = Specification::Linter.new(spec_or_path) @linter = Specification::Linter.new(spec_or_path)
end end
...@@ -412,7 +415,9 @@ module Pod ...@@ -412,7 +415,9 @@ module Pod
# @return [Array<Source>] an array of sources used to create the # @return [Array<Source>] an array of sources used to create the
# {Podfile} used in the linting process # {Podfile} used in the linting process
# #
attr_reader :sources def sources
@sources ||= @source_urls.map { |url| SourcesManager.find_or_create_source_with_url(url) }
end
# @return [Podfile] a podfile that requires the specification on the # @return [Podfile] a podfile that requires the specification on the
# current platform. # current platform.
......
...@@ -47,7 +47,7 @@ module Pod ...@@ -47,7 +47,7 @@ module Pod
describe 'Quick mode' do describe 'Quick mode' do
it 'validates a correct podspec' do it 'validates a correct podspec' do
sut = Validator.new(podspec_path, SourcesManager.master) sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.quick = true sut.quick = true
sut.validate sut.validate
sut.results.should == [] sut.results.should == []
...@@ -57,7 +57,7 @@ module Pod ...@@ -57,7 +57,7 @@ module Pod
it 'lints the podspec during validation' do it 'lints the podspec during validation' do
podspec = stub_podspec(/.*name.*/, '"name": "TEST",') podspec = stub_podspec(/.*name.*/, '"name": "TEST",')
file = write_podspec(podspec) file = write_podspec(podspec)
sut = Validator.new(file, SourcesManager.master) sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.quick = true sut.quick = true
sut.validate sut.validate
sut.results.map(&:to_s).first.should.match /should match the name/ sut.results.map(&:to_s).first.should.match /should match the name/
...@@ -66,7 +66,7 @@ module Pod ...@@ -66,7 +66,7 @@ module Pod
it 'respects quick mode' do it 'respects quick mode' do
file = write_podspec(stub_podspec) file = write_podspec(stub_podspec)
sut = Validator.new(file, SourcesManager.master) sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.quick = true sut.quick = true
sut.expects(:perform_extensive_analysis).never sut.expects(:perform_extensive_analysis).never
sut.validate sut.validate
...@@ -75,7 +75,7 @@ module Pod ...@@ -75,7 +75,7 @@ module Pod
it 'respects the only errors option' do it 'respects the only errors option' do
podspec = stub_podspec(/.*summary.*/, '"summary": "A short description of",') podspec = stub_podspec(/.*summary.*/, '"summary": "A short description of",')
file = write_podspec(podspec) file = write_podspec(podspec)
sut = Validator.new(file, SourcesManager.master) sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.quick = true sut.quick = true
sut.only_errors = true sut.only_errors = true
sut.validate sut.validate
...@@ -85,7 +85,7 @@ module Pod ...@@ -85,7 +85,7 @@ module Pod
it 'handles symlinks' do it 'handles symlinks' do
file = write_podspec(stub_podspec) file = write_podspec(stub_podspec)
validator = Validator.new(file, SourcesManager.master) validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.quick = true validator.quick = true
validator.stubs(:validate_url) validator.stubs(:validate_url)
validator.validate validator.validate
...@@ -99,7 +99,7 @@ module Pod ...@@ -99,7 +99,7 @@ module Pod
describe 'URL validation' do describe 'URL validation' do
before do before do
@sut = Validator.new(podspec_path, SourcesManager.master) @sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
@sut.stubs(:install_pod) @sut.stubs(:install_pod)
@sut.stubs(:build_pod) @sut.stubs(:build_pod)
@sut.stubs(:check_file_patterns) @sut.stubs(:check_file_patterns)
...@@ -257,7 +257,7 @@ module Pod ...@@ -257,7 +257,7 @@ module Pod
it 'respects the no clean option' do it 'respects the no clean option' do
file = write_podspec(stub_podspec) file = write_podspec(stub_podspec)
sut = Validator.new(file, SourcesManager.master) sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.stubs(:validate_url) sut.stubs(:validate_url)
sut.no_clean = true sut.no_clean = true
sut.validate sut.validate
...@@ -266,7 +266,7 @@ module Pod ...@@ -266,7 +266,7 @@ module Pod
it 'builds the pod per platform' do it 'builds the pod per platform' do
file = write_podspec(stub_podspec) file = write_podspec(stub_podspec)
sut = Validator.new(file, SourcesManager.master) sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.stubs(:validate_url) sut.stubs(:validate_url)
sut.expects(:install_pod).twice sut.expects(:install_pod).twice
sut.expects(:build_pod).twice sut.expects(:build_pod).twice
...@@ -275,7 +275,7 @@ module Pod ...@@ -275,7 +275,7 @@ module Pod
end end
it 'uses the deployment target of the specification' do it 'uses the deployment target of the specification' do
sut = Validator.new(podspec_path, SourcesManager.master) sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.stubs(:validate_url) sut.stubs(:validate_url)
sut.stubs(:validate_screenshots) sut.stubs(:validate_screenshots)
podfile = sut.send(:podfile_from_spec, :ios, '5.0') podfile = sut.send(:podfile_from_spec, :ios, '5.0')
...@@ -284,7 +284,7 @@ module Pod ...@@ -284,7 +284,7 @@ module Pod
end end
it 'respects the local option' do it 'respects the local option' do
sut = Validator.new(podspec_path, SourcesManager.master) sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.stubs(:validate_url) sut.stubs(:validate_url)
podfile = sut.send(:podfile_from_spec, :ios, '5.0') podfile = sut.send(:podfile_from_spec, :ios, '5.0')
deployment_target = podfile.target_definitions['Pods'].platform.deployment_target deployment_target = podfile.target_definitions['Pods'].platform.deployment_target
...@@ -292,7 +292,7 @@ module Pod ...@@ -292,7 +292,7 @@ module Pod
end end
it 'uses xcodebuild to generate notes and warnings' do it 'uses xcodebuild to generate notes and warnings' do
sut = Validator.new(podspec_path, SourcesManager.master) sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.stubs(:check_file_patterns) sut.stubs(:check_file_patterns)
sut.stubs(:xcodebuild).returns("file.m:1:1: warning: direct access to objective-c's isa is deprecated") sut.stubs(:xcodebuild).returns("file.m:1:1: warning: direct access to objective-c's isa is deprecated")
sut.stubs(:validate_url) sut.stubs(:validate_url)
...@@ -304,7 +304,7 @@ module Pod ...@@ -304,7 +304,7 @@ module Pod
it 'checks for file patterns' do it 'checks for file patterns' do
file = write_podspec(stub_podspec(/.*source_files.*/, '"source_files": "wrong_paht.*",')) file = write_podspec(stub_podspec(/.*source_files.*/, '"source_files": "wrong_paht.*",'))
sut = Validator.new(file, SourcesManager.master) sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.stubs(:build_pod) sut.stubs(:build_pod)
sut.stubs(:validate_url) sut.stubs(:validate_url)
sut.validate sut.validate
...@@ -319,7 +319,7 @@ module Pod ...@@ -319,7 +319,7 @@ module Pod
file = write_podspec(podspec, 'ZKit.podspec.json') file = write_podspec(podspec, 'ZKit.podspec.json')
spec = Specification.from_file(file) spec = Specification.from_file(file)
sut = Validator.new(spec, SourcesManager.master) sut = Validator.new(spec, SourcesManager.master.map(&:url))
sut.stubs(:validate_url) sut.stubs(:validate_url)
sut.stubs(:build_pod) sut.stubs(:build_pod)
sut.validate sut.validate
......
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