# -*- 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'
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) => __
def Koans.make_koan_file(infile, outfile)
if infile =~ /edgecase/
cp infile, outfile
- elsif infile =~ /autotest/
- cp_r infile, outfile
else
open(infile) do |ins|
open(outfile, "w") do |outs|
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
# 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
task :default => :walk_the_path
task :walk_the_path do
- cd 'koans'
+ cd PROB_DIR
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", "${PROB_DIR}/*.rb")
+ end
end
directory DIST_DIR
task :run do
puts 'koans'
- Dir.chdir("src") do
+ Dir.chdir("${SRC_DIR}") do
puts "in #{Dir.pwd}"
sh "ruby path_to_enlightenment.rb"
end
RubyImpls.list.each do |impl|
puts "=" * 40
puts "On Ruby #{impl}"
- sh "rvm #{impl} rake run"
+ sh ". rvm #{impl}; rake run"
results << [impl, "RAN"]
puts
end