Я не знаю, почему очевидное решение не пришло мне в голову раньше: gitignore файлы doc и добавить задачу развертывания, чтобы scp файлы прямо в общий каталог приложения.
.gitignore
public/doc
lib / tasks / doc.rake
namespace :doc do
desc "run features and specs then generate pages accessible in public/doc"
task :html do
# Delete old files
puts "Clearing out old html files..."
system("rm -rf public/doc/")
system("mkdir public/doc/")
# Generate the feature html files
puts "Generating Cucumber html files..."
system("mkdir public/doc/features")
Dir.glob("features/**/*.feature").each do |story|
system("bundle exec cucumber #{story} --drb --format=html -o public/doc/#{story.gsub(/(\w*).feature/, '\1.html')}")
puts "public/doc/#{story}"
end
# Generate RSpec html files
puts "Generating RSpec html files..."
system("mkdir public/doc/spec/")
Dir.glob("spec/**/*_spec.rb").each do |spec|
system("bundle exec rspec #{spec} --drb --format html -o public/doc/#{spec.gsub(/(\w*).rb/, '\1.html')}")
end
# Generate the index file
puts "Writing index file..."
system("echo \"<html><head><title>Doc</title></head><body>\" > public/doc/index.html")
# Write test report navigation
Dir.glob("public/doc/**/*.html").each do |file|
unless file == 'public/doc/index.html'
file.gsub!(/\public\/doc\//, '')
system("echo \"<p><a href='#{file}'>#{file.gsub('.html', '')}</a></p>\" >> public/doc/index.html")
end
end
# Close index.html file
system("echo \"</body></html>\" >> public/doc/index.html")
puts "Done!"
end
end
config / deploy.rb
desc "Generate Cucumber & RSpec HTML docs"
task :generate_docs, :roles => :app do
system("bundle exec rake doc:html")
end
desc "Copy Cucumber & RSpec HTML docs outside of version control with scp"
task :copy_docs, :roles => :app do
system("tar -zcvf tmp/doc.tar.gz public/doc && rm -rf public/doc")
system("scp -r -i ~/myKey.pem tmp/doc.tar.gz #{user}@#{hostname}:#{deploy_to}/current/public/doc.tar.gz && rm tmp/doc.tar.gz")
run "cd #{release_path}; tar -zxvf public/doc.tar.gz && rm public/doc.tar.gz"
end
after 'deploy', 'docs:generate_docs', 'docs:copy_docs'