Commit a225e746 authored by Fabio Pelosin's avatar Fabio Pelosin

[ExternalSources] Simplify path resolution logic

parent e46d15e1
...@@ -318,17 +318,14 @@ module Pod ...@@ -318,17 +318,14 @@ module Pod
def pod_spec_path def pod_spec_path
declared_path = params[:local].to_s declared_path = params[:local].to_s
path_with_ext = File.extname(declared_path) == '.podspec' ? declared_path : "#{declared_path}/#{name}.podspec" path_with_ext = File.extname(declared_path) == '.podspec' ? declared_path : "#{declared_path}/#{name}.podspec"
path_without_tilde = path_with_ext.gsub('~', ENV['HOME']) podfile_dir = File.dirname(podfile_path || '')
if podfile_path absolute_path = File.expand_path(path_with_ext, podfile_dir)
absolute_path = Pathname(podfile_path).dirname + path_without_tilde pathname = Pathname.new(absolute_path)
else
absolute_path = Pathname.new(path_without_tilde)
end
unless absolute_path.exist? unless pathname.exist?
raise Informative, "No podspec found for `#{name}` in `#{params[:local]}`" raise Informative, "No podspec found for `#{name}` in `#{params[:local]}`"
end end
absolute_path pathname
end end
end end
end end
......
...@@ -201,6 +201,13 @@ module Pod ...@@ -201,6 +201,13 @@ module Pod
path.should == fixture('integration/Reachability/Reachability.podspec') path.should == fixture('integration/Reachability/Reachability.podspec')
end end
it "handles paths when there is no podfile path" do
@external_source.stubs(:podfile_path).returns(nil)
@external_source.stubs(:params).returns(:local => fixture('integration/Reachability'))
path = @external_source.send(:pod_spec_path)
path.should == fixture('integration/Reachability/Reachability.podspec')
end
it "handles relative paths" do it "handles relative paths" do
@external_source.stubs(:params).returns(:local => 'Reachability') @external_source.stubs(:params).returns(:local => 'Reachability')
path = @external_source.send(:pod_spec_path) path = @external_source.send(:pod_spec_path)
......
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