Commits

Anonymous committed 0ae3767

Fleshed out the Rakefile a little more.

Comments (0)

Files changed (1)

-require 'yard'
+VERSION = File.read('VERSION').chomp
 
-YARD::Rake::YardocTask.new do |t|
-  t.files = ['lib/**/*.rb', '-', 'UNLICENSE', 'VERSION']
-  t.options << '--title' << 'Tweed Documentation' <<
-               '--output-dir' << 'doc/yard' <<
-               '--markup' << 'markdown' <<
-               '--readme' << 'README' <<
-               '--protected' <<
-               '--hide-void-return'
+task :default => :specs
+
+desc "Builds the gem"
+task :gem do
+  sh "gem build tweed.gemspec"
+end
+
+desc "Installs the gem"
+task :install => :gem do
+  sh "gem install tweed-#{VERSION}.gem --no-rdoc --no-ri"
+end
+
+begin
+  require 'spec'
+  require 'spec/rake/spectask'
+ 
+  desc "Run all specs"
+  Spec::Rake::SpecTask.new("specs") do |t|
+    $DEBUG = true if ENV['DEBUG']
+    t.spec_opts = ["--format", "specdoc", "--colour"]
+    t.spec_opts += ["--require", File.join(File.dirname(__FILE__), 'spec', 'spec_helper')]
+    t.spec_files = Dir["spec/**/*_spec.rb"].sort
+  
+    if ENV['RCOV']
+      hide = '_spec\.rb$,spec_helper\.rb$,ruby_lex\.rb$,autoload\.rb$'
+      t.rcov = true
+      t.rcov_opts = ['-x', hide]
+    end
+  end
+  task :spec => :specs
+rescue LoadError
+  warn "RSpec is not available. `gem install rspec` to enable tests."
+end
+
+begin
+  require 'yard'
+
+  YARD::Rake::YardocTask.new do |t|
+    t.files = ['lib/**/*.rb', '-', 'UNLICENSE', 'VERSION']
+    t.options <<
+      '--title' << "Tweed v#{VERSION} Documentation" <<
+      '--output-dir' << 'doc/yard' <<
+      '--markup' << 'markdown' <<
+      '--readme' << 'README' <<
+      '--protected' <<
+      '--hide-void-return'
+  end
+rescue LoadError
+  warn "Yard is not available. `gem install yard` to enable documentation."
 end