Commit e08be2fe authored by Eloy Duran's avatar Eloy Duran

Stash hacking.

parent 7061b9eb
module Pod module Pod
class Downloader class Downloader
extend Executable
def self.for_source(pod_root, source) def self.for_source(pod_root, source)
options = source.dup options = source.dup
if url = options.delete(:git) if url = options.delete(:git)
Git.new(pod_root, url, options) Git.new(pod_root, url, options)
elsif url = options.delete(:hg)
Mercurial.new(pod_root, url, options)
else else
raise "Unsupported download strategy `#{source.inspect}'." raise "Unsupported download strategy `#{source.inspect}'."
end end
...@@ -15,8 +19,13 @@ module Pod ...@@ -15,8 +19,13 @@ module Pod
@pod_root, @url, @options = pod_root, url, options @pod_root, @url, @options = pod_root, url, options
end end
def clean(clean_paths = [])
clean_paths.each do |path|
path.rmtree
end if clean_paths
end
class Git < Downloader class Git < Downloader
extend Executable
executable :git executable :git
def download def download
...@@ -53,10 +62,36 @@ module Pod ...@@ -53,10 +62,36 @@ module Pod
end end
def clean(clean_paths = []) def clean(clean_paths = [])
super
(@pod_root + '.git').rmtree (@pod_root + '.git').rmtree
clean_paths.each do |path| end
path.rmtree end
end if clean_paths
class Mercurial < Downloader
extend Executable
executable :hg
def download
@pod_root.dirname.mkpath
if @options[:revision]
download_revision
else
download_head
end
end
def download_head
hg "clone '#{@url}' '#{@pod_root}'"
end
def download_revision
hg "clone '#{@url}' --rev '#{@options[:revision]}' '#{@pod_root}'"
end
def clean(clean_paths = [])
super
#(@pod_root + '.git').rmtree
puts "TODO clean mercurial!"
end end
end 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