summaryrefslogtreecommitdiffhomepage
path: root/Rakefile
diff options
context:
space:
mode:
authorTom Black <[email protected]>2016-04-19 22:23:54 -0400
committerTom Black <[email protected]>2016-04-19 22:23:54 -0400
commit4a82e1d7663313e724351943cbc313ef1c828a62 (patch)
treec2ff8b5c3cabd2255e61055539f57ef3f16f7d28 /Rakefile
parent809160eb205b26f9723a5252a8ae477762921f1a (diff)
downloadruby2d-4a82e1d7663313e724351943cbc313ef1c828a62.tar.gz
ruby2d-4a82e1d7663313e724351943cbc313ef1c828a62.zip
Improving Rakefile
Added useful helper classes and methods, prettier output, other :lipstick:
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile47
1 files changed, 33 insertions, 14 deletions
diff --git a/Rakefile b/Rakefile
index df44733..fa3ad4c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,30 +1,49 @@
require 'rspec/core/rake_task'
require './lib/ruby2d/version'
-task default: 'all'
+# Helpers
+
+class String
+ def colorize(c); "\e[#{c}m#{self}\e[0m" end
+ def bold; colorize('1') end
+ def blue; colorize('1;34') end
+ def red; colorize('1;31') end
+end
+
+# Simple 2D is required for these tasks
+if `which simple2d`.empty?
+ puts "Simple 2D not found!".red
+ puts "Install before running Rake tasks."
+ exit
+end
+
+def run_cmd(cmd)
+ print "\n==> ".blue, cmd.bold, "\n\n"
+ system cmd
+end
def run_test(file)
Rake::Task['build'].invoke
Rake::Task['spec'].invoke
+ print "==> ".blue, "running tests/#{file}.rb".bold, "\n"
system "( cd tests/ ; ruby #{file}.rb )"
end
-desc "Run the specs"
+# Tasks
+
+task default: 'all'
+
+desc "Run the RSpec tests"
RSpec::Core::RakeTask.new do |t|
+ print "\n==> ".blue, "running RSpec".bold, "\n\n"
t.pattern = "spec/*spec.rb"
end
-desc "Build Gem"
+desc "Build gem"
task :build do
- puts "==> uninstall gem"
- system "gem uninstall ruby2d --executables"
-
- puts "==> build gem"
- system "gem build ruby2d.gemspec --verbose"
-
- puts "==> install gem"
- system "gem install ruby2d-#{Ruby2D::VERSION}.gem "\
- "--local --verbose -- --no-brew"
+ run_cmd "gem uninstall ruby2d --executables"
+ run_cmd "gem build ruby2d.gemspec --verbose"
+ run_cmd "gem install ruby2d-#{Ruby2D::VERSION}.gem --local --verbose"
end
desc "Run testcard"
@@ -32,12 +51,12 @@ task :testcard do
run_test 'testcard'
end
-desc "Run input"
+desc "Run input tests"
task :input do
run_test 'input'
end
-desc "Run controller"
+desc "Run controller tests"
task :controller do
run_test 'controller'
end