require 'bundler/setup' require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'appraisal' require 'erb' require_relative 'lib/shoulda/matchers/version' CURRENT_VERSION = Shoulda::Matchers::VERSION RSpec::Core::RakeTask.new('spec:unit') do |t| t.ruby_opts = '-w -r ./spec/report_warnings' t.pattern = "spec/unit/**/*_spec.rb" t.rspec_opts = '--color --format progress' t.verbose = false end RSpec::Core::RakeTask.new('spec:acceptance') do |t| t.ruby_opts = '-w -r ./spec/report_warnings' t.pattern = "spec/acceptance/**/*_spec.rb" t.rspec_opts = '--color --format progress' t.verbose = false end task :default do if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/ sh 'rake spec:unit' sh 'rake spec:acceptance' else Rake::Task['appraise'].invoke end end task :appraise do exec 'appraisal install && appraisal rake' end GH_PAGES_DIR = '.gh-pages' namespace :docs do file GH_PAGES_DIR do sh "git clone git@github.com:thoughtbot/shoulda-matchers.git #{GH_PAGES_DIR} --branch gh-pages" end task :setup => GH_PAGES_DIR do within_gh_pages do sh 'git fetch origin' sh 'git reset --hard origin/gh-pages' end end desc 'Generate docs for a particular version' task :generate, [:version, :latest_version] => :setup do |t, args| generate_docs(args.version, latest_version: latest_version) end desc 'Generate docs for a particular version and push them to GitHub' task :publish, [:version, :latest_version] => :setup do |t, args| generate_docs(args.version, latest_version: latest_version) publish_docs(args.version, latest_version: latest_version) end desc "Generate docs for version #{CURRENT_VERSION} and push them to GitHub" task :publish_latest => :setup do version = Gem::Version.new(CURRENT_VERSION) unless version.prerelease? latest_version = version.to_s end generate_docs(CURRENT_VERSION, latest_version: latest_version) publish_docs(CURRENT_VERSION, latest_version: latest_version) end def rewrite_index_to_inject_version(ref, version) within_gh_pages do filename = "#{ref}/index.html" content = File.read(filename) content.sub!(%r{