Commit a225e746 authored by Fabio Pelosin's avatar Fabio Pelosin

[ExternalSources] Simplify path resolution logic

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