Commit 537ba242 authored by Eloy Duran's avatar Eloy Duran

Add SVN downloader. Closes #81.

parent 139eda6a
......@@ -2,6 +2,7 @@ module Pod
class Downloader
autoload :Git, 'cocoapods/downloader/git'
autoload :Mercurial, 'cocoapods/downloader/mercurial'
autoload :Subversion, 'cocoapods/downloader/subversion'
extend Executable
......@@ -11,6 +12,8 @@ module Pod
Git.new(pod_root, url, options)
elsif url = options.delete(:hg)
Mercurial.new(pod_root, url, options)
elsif url = options.delete(:svn)
Subversion.new(pod_root, url, options)
else
raise "Unsupported download strategy `#{source.inspect}'."
end
......
module Pod
class Downloader
class Subversion < Downloader
executable :svn
def download
@pod_root.dirname.mkpath
if @options[:revision]
download_revision
else
download_head
end
end
def download_head
svn "checkout '#{@url}' '#{@pod_root}'"
end
def download_revision
svn "checkout '#{@url}' -r '#{@options[:revision]}' '#{@pod_root}'"
end
def clean(clean_paths = [])
super
@pod_root.glob('**/.svn').each(&:rmtree)
end
end
end
end
......@@ -56,7 +56,7 @@ describe "Pod::Downloader" do
it "removes the .hg directory" do
downloader = Pod::Downloader.for_source(@dir,
:hg => fixture('mercurial-repo'), :revision => '46198bb3af96'
:hg => fixture('mercurial-repo')
)
downloader.download
downloader.clean
......@@ -65,13 +65,50 @@ describe "Pod::Downloader" do
it "removes the clean_paths files and directories" do
downloader = Pod::Downloader.for_source(@dir,
:hg => fixture('mercurial-repo'), :revision => '46198bb3af96'
:hg => fixture('mercurial-repo')
)
downloader.download
downloader.clean([@dir + 'README'])
(@dir + 'README').should.not.exist
end
end
describe "for Subversion" do
extend SpecHelper::TemporaryDirectory
it "check's out a specific revision" do
downloader = Pod::Downloader.for_source(@dir,
:svn => "file://#{fixture('subversion-repo')}", :revision => '1'
)
downloader.download
(@dir + 'README').read.strip.should == 'first commit'
end
it "check's out a specific tag" do
downloader = Pod::Downloader.for_source(@dir,
:svn => "file://#{fixture('subversion-repo')}/tags/tag-1"
)
downloader.download
(@dir + 'README').read.strip.should == 'tag 1'
end
it "removes the .svn directories" do
downloader = Pod::Downloader.for_source(@dir,
:svn => "file://#{fixture('subversion-repo')}/trunk"
)
downloader.download
downloader.clean
(@dir + '.svn').should.not.exist
end
it "removes the clean_paths files and directories" do
downloader = Pod::Downloader.for_source(@dir,
:svn => "file://#{fixture('subversion-repo')}/trunk"
)
downloader.download
downloader.clean([@dir + 'README'])
(@dir + 'README').should.not.exist
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