Commit dad16075 authored by Fabio Pelosin's avatar Fabio Pelosin

[Resolver] No need to pass the platform to external sources.

parent 0d387594
...@@ -68,18 +68,16 @@ module Pod ...@@ -68,18 +68,16 @@ module Pod
# #
# TODO: rename to specification. # TODO: rename to specification.
# #
def specification_from_sandbox(sandbox, platform) def specification_from_sandbox(sandbox)
specification_from_local(sandbox, platform) || specification_from_local(sandbox) ||
specification_from_external(sandbox, platform) specification_from_external(sandbox)
end end
# @return [Specification] returns the specification associated with the # @return [Specification] returns the specification associated with the
# external source if available in the sandbox. # external source if available in the sandbox.
# #
def specification_from_local(sandbox, platform) def specification_from_local(sandbox)
if local_pod = sandbox.installed_pod_named(name, platform) sandbox.specification(name)
local_pod.top_specification
end
end end
# @return [Specification] returns the specification associated with the # @return [Specification] returns the specification associated with the
...@@ -88,9 +86,9 @@ module Pod ...@@ -88,9 +86,9 @@ module Pod
# #
# @raise If not specification could be found. # @raise If not specification could be found.
# #
def specification_from_external(sandbox, platform) def specification_from_external(sandbox)
copy_external_source_into_sandbox(sandbox, platform) copy_external_source_into_sandbox(sandbox)
spec = specification_from_local(sandbox, platform) spec = specification_from_local(sandbox)
unless spec unless spec
raise Informative, "No podspec found for `#{name}' in #{description}" raise Informative, "No podspec found for `#{name}' in #{description}"
end end
...@@ -106,12 +104,9 @@ module Pod ...@@ -106,12 +104,9 @@ module Pod
# @param [Sandbox] sandbox # @param [Sandbox] sandbox
# the sandbox where the specification should be stored. # the sandbox where the specification should be stored.
# #
# @param [Platform] platform
# TODO this is not needed.
#
# @return [void] # @return [void]
# #
def copy_external_source_into_sandbox(sandbox, platform) def copy_external_source_into_sandbox(sandbox)
raise "Abstract method" raise "Abstract method"
end end
...@@ -170,16 +165,14 @@ module Pod ...@@ -170,16 +165,14 @@ module Pod
# as pre-downloaded indicating to the installer that only clean # as pre-downloaded indicating to the installer that only clean
# operations are needed. # operations are needed.
# #
def copy_external_source_into_sandbox(sandbox, platform) def copy_external_source_into_sandbox(sandbox)
UI.info("->".green + " Pre-downloading: '#{name}'") do UI.info("->".green + " Pre-downloading: '#{name}'") do
target = sandbox.root + name target = sandbox.root + name
target.rmtree if target.exist? target.rmtree if target.exist?
downloader = Downloader.for_target(sandbox.root + name, @params) downloader = Downloader.for_target(sandbox.root + name, @params)
downloader.download downloader.download
store_podspec(sandbox, target + "#{name}.podspec") store_podspec(sandbox, target + "#{name}.podspec")
if local_pod = sandbox.installed_pod_named(name, platform) sandbox.predownloaded_pods << name
local_pod.downloaded = true
end
end end
end end
...@@ -203,7 +196,7 @@ module Pod ...@@ -203,7 +196,7 @@ module Pod
# @see AbstractExternalSource#copy_external_source_into_sandbox # @see AbstractExternalSource#copy_external_source_into_sandbox
# #
def copy_external_source_into_sandbox(sandbox, _) def copy_external_source_into_sandbox(sandbox)
UI.info("->".green + " Fetching podspec for `#{name}' from: #{@params[:podspec]}") do UI.info("->".green + " Fetching podspec for `#{name}' from: #{@params[:podspec]}") do
path = @params[:podspec] path = @params[:podspec]
path = Pathname.new(path).expand_path if path.start_with?("~") path = Pathname.new(path).expand_path if path.start_with?("~")
...@@ -229,7 +222,7 @@ module Pod ...@@ -229,7 +222,7 @@ module Pod
# @see AbstractExternalSource#copy_external_source_into_sandbox # @see AbstractExternalSource#copy_external_source_into_sandbox
# #
def copy_external_source_into_sandbox(sandbox, _) def copy_external_source_into_sandbox(sandbox)
store_podspec(sandbox, pod_spec_path) store_podspec(sandbox, pod_spec_path)
end end
...@@ -246,8 +239,8 @@ module Pod ...@@ -246,8 +239,8 @@ module Pod
# once installed, the podspec would be updated only by `pod # once installed, the podspec would be updated only by `pod
# update`. # update`.
# #
def specification_from_local(sandbox, platform) def specification_from_local(sandbox)
specification_from_external(sandbox, platform) specification_from_external(sandbox)
end end
# @see AbstractExternalSource#specification_from_local # @see AbstractExternalSource#specification_from_local
...@@ -255,8 +248,8 @@ module Pod ...@@ -255,8 +248,8 @@ module Pod
# @note The LocalSource overrides the source of the specification to # @note The LocalSource overrides the source of the specification to
# point to the local path. # point to the local path.
# #
def specification_from_external(sandbox, platform) def specification_from_external(sandbox)
copy_external_source_into_sandbox(sandbox, platform) copy_external_source_into_sandbox(sandbox)
spec = Specification.from_file(pod_spec_path) spec = Specification.from_file(pod_spec_path)
spec.source = @params spec.source = @params
spec spec
......
...@@ -174,7 +174,7 @@ module Pod ...@@ -174,7 +174,7 @@ module Pod
dependency = locked_dep if locked_dep dependency = locked_dep if locked_dep
UI.message("- #{dependency}", '', 2) do UI.message("- #{dependency}", '', 2) do
set = find_cached_set(dependency, target_definition.platform) set = find_cached_set(dependency)
set.required_by(dependency, dependent_spec.to_s) set.required_by(dependency, dependent_spec.to_s)
unless @loaded_specs.include?(dependency.name) unless @loaded_specs.include?(dependency.name)
...@@ -213,13 +213,13 @@ module Pod ...@@ -213,13 +213,13 @@ module Pod
# #
# @return [Set] the cached set for a given dependency. # @return [Set] the cached set for a given dependency.
# #
def find_cached_set(dependency, platform) def find_cached_set(dependency)
name = dependency.root_name name = dependency.root_name
unless cached_sets[name] unless cached_sets[name]
if dependency.specification if dependency.specification
set = Specification::Set::External.new(dependency.specification) set = Specification::Set::External.new(dependency.specification)
elsif dependency.external_source elsif dependency.external_source
set = set_from_external_source(dependency, platform) set = set_from_external_source(dependency)
else else
set = cached_sources.search(dependency) set = cached_sources.search(dependency)
end end
...@@ -230,12 +230,12 @@ module Pod ...@@ -230,12 +230,12 @@ module Pod
# Returns a new set created from an external source # Returns a new set created from an external source
# #
def set_from_external_source(dependency, platform) def set_from_external_source(dependency)
source = ExternalSources.from_dependency(dependency) source = ExternalSources.from_dependency(dependency)
spec = if update_external_specs if update_external_specs
source.specification_from_external(@sandbox, platform) spec = source.specification_from_external(sandbox)
else else
source.specification_from_sandbox(@sandbox, platform) spec = source.specification_from_sandbox(sandbox)
end end
set = Specification::Set::External.new(spec) set = Specification::Set::External.new(spec)
set set
......
...@@ -40,6 +40,7 @@ module Pod ...@@ -40,6 +40,7 @@ module Pod
@public_headers = HeadersDirectory.new(self, PUBLIC_HEADERS_DIR) @public_headers = HeadersDirectory.new(self, PUBLIC_HEADERS_DIR)
@cached_local_pods = {} @cached_local_pods = {}
@cached_locally_sourced_pods = {} @cached_locally_sourced_pods = {}
@predownloaded_pods = []
FileUtils.mkdir_p(@root) FileUtils.mkdir_p(@root)
end end
...@@ -112,16 +113,6 @@ module Pod ...@@ -112,16 +113,6 @@ module Pod
end end
end end
#--------------------------------------#
# @!group Private methods
attr_accessor :cached_local_pods
attr_accessor :cached_locally_sourced_pods
private
# Returns the path of the specification for the Pod with the # Returns the path of the specification for the Pod with the
# given name. # given name.
# #
...@@ -134,6 +125,36 @@ module Pod ...@@ -134,6 +125,36 @@ module Pod
path = root + "Local Podspecs/#{name}.podspec" path = root + "Local Podspecs/#{name}.podspec"
path.exist? ? path : nil path.exist? ? path : nil
end end
# Returns the specification for the Pod with the given name.
#
# @param [String] name
# the name of the Pod for which the specification is requested.
#
# @return [Specification] the specification.
#
def specification(name)
if file = podspec_for_name(name)
Specification.from_file(file)
end
end
# @return [Array<String>] the names of the pods that have been
# pre-downloaded from an external source.
#
# TODO: the installer needs to be aware of it.
#
attr_reader :predownloaded_pods
#--------------------------------------#
# @!group Private methods
private
attr_accessor :cached_local_pods
attr_accessor :cached_locally_sourced_pods
end end
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
......
...@@ -26,7 +26,7 @@ module Pod ...@@ -26,7 +26,7 @@ module Pod
it "creates a copy of the podspec" do it "creates a copy of the podspec" do
dependency = Dependency.new("Reachability", :git => fixture('integration/Reachability')) dependency = Dependency.new("Reachability", :git => fixture('integration/Reachability'))
external_source = ExternalSources.from_dependency(dependency) external_source = ExternalSources.from_dependency(dependency)
external_source.copy_external_source_into_sandbox(config.sandbox, Platform.ios) external_source.copy_external_source_into_sandbox(config.sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = config.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
end end
...@@ -34,8 +34,8 @@ module Pod ...@@ -34,8 +34,8 @@ module Pod
it "marks a LocalPod as downloaded" do it "marks a LocalPod as downloaded" do
dependency = Dependency.new("Reachability", :git => fixture('integration/Reachability')) dependency = Dependency.new("Reachability", :git => fixture('integration/Reachability'))
external_source = ExternalSources.from_dependency(dependency) external_source = ExternalSources.from_dependency(dependency)
external_source.copy_external_source_into_sandbox(config.sandbox, Platform.ios) external_source.copy_external_source_into_sandbox(config.sandbox)
config.sandbox.installed_pod_named('Reachability', Platform.ios).downloaded.should.be.true config.sandbox.predownloaded_pods.should == ["Reachability"]
end end
xit "returns the description" do end xit "returns the description" do end
...@@ -45,7 +45,7 @@ module Pod ...@@ -45,7 +45,7 @@ module Pod
it "creates a copy of the podspec" do it "creates a copy of the podspec" do
dependency = Dependency.new("Reachability", :podspec => fixture('integration/Reachability/Reachability.podspec').to_s) dependency = Dependency.new("Reachability", :podspec => fixture('integration/Reachability/Reachability.podspec').to_s)
external_source = ExternalSources.from_dependency(dependency) external_source = ExternalSources.from_dependency(dependency)
external_source.copy_external_source_into_sandbox(config.sandbox, Platform.ios) external_source.copy_external_source_into_sandbox(config.sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = config.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
end end
...@@ -57,7 +57,7 @@ module Pod ...@@ -57,7 +57,7 @@ module Pod
it "creates a copy of the podspec" do it "creates a copy of the podspec" do
dependency = Dependency.new("Reachability", :local => fixture('integration/Reachability')) dependency = Dependency.new("Reachability", :local => fixture('integration/Reachability'))
external_source = ExternalSources.from_dependency(dependency) external_source = ExternalSources.from_dependency(dependency)
external_source.copy_external_source_into_sandbox(config.sandbox, Platform.ios) external_source.copy_external_source_into_sandbox(config.sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = config.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
end end
......
...@@ -174,6 +174,30 @@ module Pod ...@@ -174,6 +174,30 @@ module Pod
e.message.should.match(/already activated version/) e.message.should.match(/already activated version/)
end end
xit "is robust against infinite loops" do
end
xit "takes into account locked dependencies" do
end
xit "transfers the head state of a dependency to a specification" do
end
xit "" do
end
xit "" do
end
xit "" do
end
# describe "Concerning Installation mode" do # describe "Concerning Installation mode" do
# before do # before do
# config.repos_dir = fixture('spec-repos') # config.repos_dir = fixture('spec-repos')
......
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