deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject [2/2] git commit: * Rakefile (mock:fixtures): fix tasks to work with new layout/initializers
Date Tue, 19 Feb 2013 23:41:37 GMT
Updated Branches:
  refs/heads/master 8cd277cad -> db3c40f4b


* Rakefile (mock:fixtures): fix tasks to work with new layout/initializers


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/db3c40f4
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/db3c40f4
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/db3c40f4

Branch: refs/heads/master
Commit: db3c40f4bfeddd39ae91c7b28b71cd2ea90672f3
Parents: f73d190
Author: David Lutterkort <lutter@redhat.com>
Authored: Mon Feb 18 14:54:54 2013 -0800
Committer: David Lutterkort <lutter@redhat.com>
Committed: Tue Feb 19 15:40:17 2013 -0800

----------------------------------------------------------------------
 server/Rakefile |   47 ++++++++++++++++++++---------------------------
 1 files changed, 20 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/db3c40f4/server/Rakefile
----------------------------------------------------------------------
diff --git a/server/Rakefile b/server/Rakefile
index f472b6b..e22f673 100644
--- a/server/Rakefile
+++ b/server/Rakefile
@@ -46,8 +46,10 @@ Gem::PackageTask.new(spec) do |pkg|
   pkg.need_tar = true
 end
 
-require 'require_relative' if RUBY_VERSION < '1.9'
-require_relative './lib/initializers/mock_initialize'
+# Not meant for enduser consumption; make sure we run our initializers
+task :initialize do
+  require_relative 'lib/initialize.rb'
+end
 
 namespace :db do
   desc 'Execute the database migrations'
@@ -59,37 +61,28 @@ end
 namespace :mock do
   namespace :fixtures do
     desc "Setup Mock driver fixtures"
-    task 'setup' do
-      if ENV["DELTACLOUD_MOCK_STORAGE"]
-        storage_root = ENV["DELTACLOUD_MOCK_STORAGE"]
-      elsif ENV["USER"]
-        storage_root = File::join("/var/tmp", "deltacloud-mock-#{ENV["USER"]}")
-      else
-        raise "Please set either the DELTACLOUD_MOCK_STORAGE or USER environment variable"
-      end
-      data = Dir::glob(File::join(File::dirname(__FILE__), "lib", "deltacloud", "drivers",
"mock", "data", "*"))
-      FileUtils::mkdir_p(storage_root, :verbose => true)
-      FileUtils::cp_r(data, storage_root, :verbose => true)
+    task 'setup' => :initialize do
+      srcdir = File::join(File::dirname(__FILE__), "lib", "deltacloud", "drivers", "mock",
"data")
+      data = Dir::glob(File::join(srcdir, "*"))
+      srcdir.gsub!(/^#{ENV["PWD"]}/, ".").gsub!(/^#{ENV["HOME"]}/, "~")
+      puts "Copy mock data to #{MOCK_STORAGE_DIR}"
+      puts "  (from #{srcdir})"
+      FileUtils::cp_r(data, MOCK_STORAGE_DIR, :verbose => false)
     end
 
     desc "Remove Mock driver fixtures"
-    task 'clean' do
-      if ENV["DELTACLOUD_MOCK_STORAGE"]
-        storage_root = ENV["DELTACLOUD_MOCK_STORAGE"]
-      elsif ENV["USER"]
-        storage_root = File::join("/var/tmp", "deltacloud-mock-#{ENV["USER"]}")
-      else
-        raise "Please set either the DELTACLOUD_MOCK_STORAGE or USER environment variable"
-      end
-      FileUtils::rm_rf(storage_root, :verbose => true)
+    task 'clean' => :initialize do
+      puts "Remove mock data in #{MOCK_STORAGE_DIR}"
+      files = Dir::glob(File::join(MOCK_STORAGE_DIR, "*"))
+      FileUtils::rm_rf(files, :verbose => false)
     end
 
     desc "Reset Mock driver fixtures"
-    task 'reset' do
-      Rake::Task["mock:fixtures:clean"].reenable
-      Rake::Task["mock:fixtures:clean"].invoke
-      Rake::Task["mock:fixtures:setup"].reenable
-      Rake::Task["mock:fixtures:setup"].invoke
+    task 'reset' => :initialize do
+      ["mock:fixtures:clean", "mock:fixtures:setup"].each do |t|
+        Rake::Task[t].reenable
+        Rake::Task[t].invoke
+      end
     end
 
   end


Mime
View raw message