Commit c82eb037 authored by Fabio Pelosin's avatar Fabio Pelosin

[ExternalSources] Refine rename of the :local option to :path

See #971
parent 74b06387
......@@ -17,10 +17,13 @@ module Pod
elsif params.key?(:svn) then SvnSource
elsif params.key?(:hg) then MercurialSource
elsif params.key?(:podspec) then PodspecSource
elsif params.key?(:local) ||
params.key?(:path) then LocalSource
elsif params.key?(:path) then PathSource
end
if params.key?(:local)
klass = PathSource
UI.warn "The `:local` option of the Podfile has been renamed to `:path` and is deprecated." \
end
UI.warn "Using :local in a Podfile is depricated. Please use :path instead." if params.key?(:local)
if klass
klass.new(name, params, podfile_path)
......@@ -314,7 +317,7 @@ module Pod
#
# Works with the {LocalPod::LocalSourcedPod} class.
#
class LocalSource < AbstractExternalSource
class PathSource < AbstractExternalSource
# @see AbstractExternalSource#fetch
#
......@@ -329,7 +332,7 @@ module Pod
# @see AbstractExternalSource#description
#
def description
"from `#{params[:local]}`"
"from `#{params[:path] || params[:local]}`"
end
#--------------------------------------#
......@@ -341,7 +344,7 @@ module Pod
# @return [Pathname] the path of the podspec.
#
def podspec_path
declared_path = params[:local].to_s
declared_path = (params[:path] || params[:local]).to_s
path_with_ext = File.extname(declared_path) == '.podspec' ? declared_path : "#{declared_path}/#{name}.podspec"
podfile_dir = File.dirname(podfile_path || '')
absolute_path = File.expand_path(path_with_ext, podfile_dir)
......
......@@ -248,7 +248,7 @@ module Pod
pods_to_fetch = result.podfile_state.added + result.podfile_state.changed
deps_to_fetch = deps_with_external_source.select { |dep| pods_to_fetch.include?(dep.root_name) }
deps_to_fetch_if_needed = deps_with_external_source.select { |dep| result.podfile_state.unchanged.include?(dep.root_name) }
deps_to_fetch += deps_to_fetch_if_needed.select { |dep| sandbox.specification(dep.root_name).nil? || !dep.external_source[:local].nil? }
deps_to_fetch += deps_to_fetch_if_needed.select { |dep| sandbox.specification(dep.root_name).nil? || !dep.external_source[:local].nil? || !dep.external_source[:path].nil? }
end
unless deps_to_fetch.empty?
......
......@@ -320,6 +320,8 @@ module Pod
# @return [Hash{String=>String}] The path of the Pods with a local source
# grouped by their name.
#
# @todo Rename (e.g. `pods_with_local_path`)
#
attr_reader :local_pods
# Checks if a Pod is locally sourced?
......
......@@ -106,7 +106,7 @@ module Pod
# @return [Bool] whether the validation should be performed against the root of
# the podspec instead to its original source.
#
# @note Uses the `:local` option of the Podfile.
# @note Uses the `:path` option of the Podfile.
#
attr_writer :local
def local?; @local; end
......
......@@ -8,11 +8,13 @@ module Pod
svn = Dependency.new("Reachability", :svn => nil)
podspec = Dependency.new("Reachability", :podspec => nil)
local = Dependency.new("Reachability", :local => nil)
path = Dependency.new("Reachability", :path => nil)
ExternalSources.from_dependency(git, nil).class.should == ExternalSources::GitSource
ExternalSources.from_dependency(svn, nil).class.should == ExternalSources::SvnSource
ExternalSources.from_dependency(podspec, nil).class.should == ExternalSources::PodspecSource
ExternalSources.from_dependency(local, nil).class.should == ExternalSources::LocalSource
ExternalSources.from_dependency(local, nil).class.should == ExternalSources::PathSource
ExternalSources.from_dependency(path, nil).class.should == ExternalSources::PathSource
end
end
......@@ -202,11 +204,11 @@ module Pod
#---------------------------------------------------------------------------#
describe ExternalSources::LocalSource do
describe ExternalSources::PathSource do
before do
podspec_path = fixture('integration/Reachability/Reachability.podspec')
dependency = Dependency.new("Reachability", :local => fixture('integration/Reachability'))
dependency = Dependency.new("Reachability", :path => fixture('integration/Reachability'))
podfile_path = fixture('integration/Podfile')
@external_source = ExternalSources.from_dependency(dependency, podfile_path)
end
......@@ -217,6 +219,15 @@ module Pod
path.should.exist?
end
it "creates a copy of the podspec [Deprecated local option]" do
dependency = Dependency.new("Reachability", :local => fixture('integration/Reachability'))
podfile_path = fixture('integration/Podfile')
external_source = ExternalSources.from_dependency(dependency, podfile_path)
external_source.fetch(config.sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist?
end
it "returns the description" do
@external_source.description.should.match %r|from `.*integration/Reachability`|
end
......@@ -231,33 +242,33 @@ module Pod
describe "Helpers" do
it "handles absolute paths" do
@external_source.stubs(:params).returns(:local => fixture('integration/Reachability'))
@external_source.stubs(:params).returns(:path => fixture('integration/Reachability'))
path = @external_source.send(:podspec_path)
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'))
@external_source.stubs(:params).returns(:path => fixture('integration/Reachability'))
path = @external_source.send(:podspec_path)
path.should == fixture('integration/Reachability/Reachability.podspec')
end
it "handles relative paths" do
@external_source.stubs(:params).returns(:local => 'Reachability')
@external_source.stubs(:params).returns(:path => 'Reachability')
path = @external_source.send(:podspec_path)
path.should == fixture('integration/Reachability/Reachability.podspec')
end
it "expands the tilde" do
@external_source.stubs(:params).returns(:local => '~/Reachability')
@external_source.stubs(:params).returns(:path => '~/Reachability')
Pathname.any_instance.stubs(:exist?).returns(true)
path = @external_source.send(:podspec_path)
path.should == Pathname(ENV['HOME']) + 'Reachability/Reachability.podspec'
end
it "raises if the podspec cannot be found" do
@external_source.stubs(:params).returns(:local => temporary_directory)
@external_source.stubs(:params).returns(:path => temporary_directory)
e = lambda { @external_source.send(:podspec_path) }.should.raise Informative
e.message.should.match /No podspec found/
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