Rakefile in infrataster-0.1.2 vs Rakefile in infrataster-0.1.3
- old
+ new
@@ -1,10 +1,11 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
+require "open-uri"
-def red(str)
- "\e[31m#{str}\e[m"
+def yellow(str)
+ "\e[33m#{str}\e[m"
end
ENV['VAGRANT_CWD'] = File.expand_path('spec/integration/vm')
namespace :spec do
@@ -16,37 +17,44 @@
task.pattern = "./spec/integration{,/*/**}/*_spec.rb"
end
namespace :integration do
integration_dir = 'spec/integration'
+
task :prepare => ['download_browsermob', 'start_vm'] do
end
task :download_browsermob do
dir = File.join(integration_dir, 'vm/vendor/browsermob')
unless Dir.exist?(dir)
- puts red("Downloading browsermob...")
+ puts yellow("Downloading browsermob...")
Dir.mktmpdir do |tmp|
- cmd = "cd #{tmp} && wget -O browsermob-proxy.zip https://s3-us-west-1.amazonaws.com/lightbody-bmp/browsermob-proxy-2.0-beta-9-bin.zip && unzip browsermob-proxy.zip"
- system cmd
+ open('https://s3-us-west-1.amazonaws.com/lightbody-bmp/browsermob-proxy-2.0-beta-9-bin.zip') do |remote|
+ open(File.join(tmp, 'browsermob-proxy.zip'), 'wb') do |f|
+ f.write(remote.read)
+ end
+ end
+ Dir.chdir(tmp) do
+ system "unzip browsermob-proxy.zip"
+ end
FileUtils.mv(File.join(tmp, 'browsermob-proxy-2.0-beta-9'), dir)
end
end
end
task :berks_vendor do
dir = File.join(integration_dir, 'vm/vendor/cookbooks')
# Berkshelf
if Dir.exist?(dir)
- puts red("'#{dir}' already exists. If you want update cookbooks, delete the directory and re-run rake command")
+ puts yellow("'#{dir}' already exists. If you want update cookbooks, delete the directory and re-run rake command")
else
- puts red('Installing cookbooks by berkshelf...')
- system "cd #{integartion_dir} && berks vendor vendor/cookbooks"
+ puts yellow('Installing cookbooks by berkshelf...')
+ system "cd #{integration_dir}/vm && berks vendor vendor/cookbooks"
end
end
task :start_vm => ['berks_vendor'] do
- puts red('Starting VM...')
+ puts yellow('Starting VM...')
system '/usr/bin/vagrant up'
end
end
end