Commit cef1a627 authored by Luke Redpath's avatar Luke Redpath

Refactor the downloaders to still work with Dependency objects.

parent 55141923
......@@ -90,7 +90,8 @@ module Pod
end
else
puts " * Pre-downloading: `#{@name}'" unless config.silent?
Downloader.for_source(pod_root, @external_spec_source).download
pod = LocalPods.new
Downloader.for_dependency(self).download
spec = pod_root + "#{@name}.podspec"
end
Specification.from_file(spec)
......@@ -98,6 +99,10 @@ module Pod
end
end
def pod_root
config.project_pods_root + @name
end
# Taken from RubyGems 1.3.7
unless public_method_defined?(:match?)
def match?(spec_name, spec_version)
......
......@@ -7,26 +7,36 @@ module Pod
extend Executable
def self.for_pod(pod)
options = pod.specification.source.dup
if url = options.delete(:git)
Git.new(pod, url, options)
elsif url = options.delete(:hg)
Mercurial.new(pod, url, options)
elsif url = options.delete(:svn)
Subversion.new(pod, url, options)
else
raise "Unsupported download strategy `#{options.inspect}'."
for_target(pod.root, pod.specification.source.dup)
end
def self.for_dependency(dependency)
for_target(dependency.pod_root, dependency.external_spec_source)
end
attr_reader :pod, :url, :options
attr_reader :target_path, :url, :options
def initialize(pod, url, options)
@pod, @url, @options = pod, url, options
def initialize(target_path, url, options)
@target_path, @url, @options = target_path, url, options
@target_path.mkpath
end
def clean
# implement in sub-classes
end
private
def self.for_target(target_path, options)
if url = options.delete(:git)
Git.new(target_path, url, options)
elsif url = options.delete(:hg)
Mercurial.new(target_path, url, options)
elsif url = options.delete(:svn)
Subversion.new(target_path, url, options)
else
raise "Unsupported download strategy `#{options.inspect}'."
end
end
end
end
......@@ -14,11 +14,11 @@ module Pod
end
def download_head
git "clone '#{url}' '#{pod.root}'"
git "clone '#{url}' '#{target_path}'"
end
def download_tag
pod.chdir do
Dir.chdir(target_path) do
git "init"
git "remote add origin '#{url}'"
git "fetch origin tags/#{options[:tag]}"
......@@ -28,15 +28,15 @@ module Pod
end
def download_commit
git "clone '#{url}' '#{pod.root}'"
git "clone '#{url}' '#{target_path}'"
pod.chdir do
Dir.chdir(target_path) do
git "checkout -b activated-pod-commit #{options[:commit]}"
end
end
def clean
(pod.root + '.git').rmtree
(target_path + '.git').rmtree
end
end
end
......
......@@ -12,15 +12,15 @@ module Pod
end
def download_head
hg "clone '#{url}' '#{pod.root}'"
hg "clone '#{url}' '#{target_path}'"
end
def download_revision
hg "clone '#{url}' --rev '#{options[:revision]}' '#{pod.root}'"
hg "clone '#{url}' --rev '#{options[:revision]}' '#{target_path}'"
end
def clean
(pod.root + '.hg').rmtree
(target_path + '.hg').rmtree
end
end
end
......
......@@ -12,15 +12,15 @@ module Pod
end
def download_head
svn "checkout '#{url}' '#{pod.root}'"
svn "checkout '#{url}' '#{target_path}'"
end
def download_revision
svn "checkout '#{url}' -r '#{options[:revision]}' '#{pod.root}'"
svn "checkout '#{url}' -r '#{options[:revision]}' '#{target_path}'"
end
def clean
pod.root.glob('**/.svn').each(&:rmtree)
target_path.glob('**/.svn').each(&:rmtree)
end
end
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