Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 80 lines (68 sloc) 1.961 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
require "rubygems"
require "rake"
require "rake/testtask"
require "rubygems/package_task"
require "rake/clean"
require "bundler/setup"

task :default => :test

CLEAN << "pkg" << "doc" << "coverage" << ".yardoc"

gemspec = File.expand_path("../friendly_id.gemspec", __FILE__)
if File.exists? gemspec
  Gem::PackageTask.new(eval(File.read("friendly_id.gemspec"))) { |pkg| }
end

begin
  require "yard"
  YARD::Rake::YardocTask.new do |t|
    t.options = ["--output-dir=doc"]
    t.options << "--files" << ["Guide.md", "Contributors.md", "Changelog.md"].join(",")
  end
rescue LoadError
end

begin
  require "rcov/rcovtask"
  Rcov::RcovTask.new do |r|
    r.test_files = FileList["test/**/*_test.rb"]
    r.verbose = true
    r.rcov_opts << "--exclude gems/*"
  end
rescue LoadError
end


Rake::TestTask.new(:test) { |t| t.pattern = "test/**/*_test.rb" }

namespace :test do
  task :rails do
    rm_rf "fid"
    sh "rails --template extras/template-gem.rb fid"
    sh "cd fid; rake test"
  end
  Rake::TestTask.new(:friendly_id) { |t| t.pattern = "test/*_test.rb" }
  Rake::TestTask.new(:ar) { |t| t.pattern = "test/active_record_adapter/*_test.rb" }

  desc "Test against lots of versions"
  task :pre_release do
    ["ree-1.8.7-2010.02", "ruby-1.9.2-p136"].each do |ruby|
      ["sqlite3", "mysql", "postgres"].each do |driver|
        [2, 3].each do |ar_version|
          command = "rake-#{ruby} test AR=#{ar_version} DB=#{driver}"
          puts command
          puts `#{command}`
        end
      end
    end
  end

  namespace :rails do
    task :plugin do
      rm_rf "fid"
      sh "rails --template extras/template-plugin.rb fid"
      sh "cd fid; rake test"
    end
  end
end

task :pushdocs do
  branch = `git branch | grep "*"`.chomp.gsub("* ", "")
  sh "git stash"
  sh "git checkout gh-pages"
  sh "cp -rp doc/* ."
  sh 'git commit -a -m "Regenerated docs"'
  sh "git push origin gh-pages"
  sh "git checkout #{branch}"
  sh "git stash apply"
end
Something went wrong with that request. Please try again.