Restrict assert checks to .rb files.
[ruby_koans.git] / Rakefile
index 2eec08d..07da095 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -2,7 +2,11 @@
 # -*- ruby -*-
 
 require 'rake/clean'
-require 'rake/rdoctask'
+begin
+  require 'rdoc/task'
+rescue LoadError => ex
+  # No rdoc task availble.
+end
 
 SRC_DIR      = 'src'
 PROB_DIR     = 'koans'
@@ -15,9 +19,12 @@ today    = Time.now.strftime("%Y-%m-%d")
 TAR_FILE = "#{DIST_DIR}/rubykoans-#{today}.tgz"
 ZIP_FILE = "#{DIST_DIR}/rubykoans-#{today}.zip"
 
+CLEAN.include("**/*.rbc")
 CLOBBER.include(DIST_DIR)
 
 module Koans
+  extend Rake::DSL if defined?(Rake::DSL)
+
   # Remove solution info from source
   #   __(a,b)     => __
   #   _n_(number) => __
@@ -60,7 +67,7 @@ end
 module RubyImpls
   # Calculate the list of relevant Ruby implementations.
   def self.find_ruby_impls
-    rubys = `rvm list`.gsub(/=>/,'').split(/\n/).sort
+    rubys = `rvm list`.gsub(/=>/,'').split(/\n/).map { |x| x.strip }.reject { |x| x.empty? || x =~ /^rvm/ }.sort
     expected.map { |impl|
       last = rubys.grep(Regexp.new(Regexp.quote(impl))).last
       last ? last.split.first : nil
@@ -74,7 +81,7 @@ module RubyImpls
 
   # List of expected ruby implementations.
   def self.expected
-    %w(ruby-1.8.6 ruby-1.8.7 ruby-1.9.2 jruby ree)
+    %w(ruby-1.8.7 ruby-1.9.2 jruby ree)
   end
 end
 
@@ -85,9 +92,11 @@ task :walk_the_path do
   ruby 'path_to_enlightenment.rb'
 end
 
-Rake::RDocTask.new do |rd|
-  rd.main = "README.rdoc"
-  rd.rdoc_files.include("README.rdoc", "koans/*.rb")
+if defined?(Rake::RDocTask)
+  Rake::RDocTask.new do |rd|
+    rd.main = "README.rdoc"
+    rd.rdoc_files.include("README.rdoc", "koans/*.rb")
+  end
 end
 
 directory DIST_DIR
@@ -143,12 +152,12 @@ task :cruise => :run_all
 
 desc "Run the completed koans againts a list of relevant Ruby Implementations"
 task :run_all do
-  results = {}
+  results = []
   RubyImpls.list.each do |impl|
     puts "=" * 40
     puts "On Ruby #{impl}"
-    res = sh "rvm #{impl} rake run"
-    results[impl] = res
+    sh ". rvm #{impl}; rake run"
+    results << [impl, "RAN"]
     puts
   end
   puts "=" * 40
@@ -160,6 +169,6 @@ task :run_all do
   puts
   RubyImpls.expected.each do |requested_impl|
     impl_pattern = Regexp.new(Regexp.quote(requested_impl))
-    puts "No Results for #{requested_impl}" if results.keys.grep(impl_pattern).empty?
+    puts "No Results for #{requested_impl}" unless results.detect { |x| x.first =~ impl_pattern }
   end
 end