Permalink
Browse files

Added tasks to download/extract the example projects for the specs.

  • Loading branch information...
1 parent b86203a commit d05b358fe42933273bee31d2c7970fb1131048ae @postmodern committed Apr 23, 2012
Showing with 45 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +44 −0 Rakefile
View
@@ -1,2 +1,3 @@
doc/
pkg/
+data/projects/
View
@@ -33,3 +33,47 @@ rescue LoadError => e
abort 'Please run `gem install yard` to install YARD.'
end
end
+
+require 'net/https'
+require 'uri'
+
+DOWNLOAD_URI = 'http://cloud.github.com/downloads/postmodern/rubygems-tasks/'
+PROJECTS_DIR = File.join('data','projects')
+PROJECTS = %w[rubygems-project rubygems-multi-project bundler-project]
+
+directory PROJECTS_DIR
+
+PROJECTS.each do |project|
+ project_file = "#{project}.tar.gz"
+ project_path = File.join(PROJECTS_DIR,project_file)
+ project_dir = File.join(PROJECTS_DIR,project)
+
+ file project_path => PROJECTS_DIR do
+ Net::HTTP.get_response(URI(DOWNLOAD_URI + project_file)) do |response|
+ size, total = 0, response.header['Content-Length'].to_i
+
+ puts ">>> Downloading to #{project_file} to #{project_path} ..."
+
+ File.open(project_path,"wb") do |file|
+ response.read_body do |chunk|
+ file.write(chunk)
+
+ size += chunk.size
+ printf "\r>>> [%d / %d] %d%% ...", size, total, ((size * 100) / total)
+ end
+ end
+
+ puts
+ end
+ end
+
+ task project_dir => project_path do
+ unless File.directory?(project_dir)
+ sh 'tar', 'xzf', project_path, '-C', PROJECTS_DIR
+ end
+ end
+
+ task 'data:projects' => project_dir
+end
+
+task :spec => 'data:projects'

0 comments on commit d05b358

Please sign in to comment.