require "bundler/gem_tasks"
require "rack"
require "RedCloth"
require "redcloth-formatters-rdoc"
require "rdoc/task"
desc "Create and open documentation"
task :doc do
# Compile the readme to the rdoc format
readme_textile = File.open('README.textile', 'r+'){ |file| file.read }
readme_rdoc = RedCloth.new(readme_textile).to_rdoc
File.open('README.rdoc', 'w+'){ |file| file.write(readme_rdoc) }
# Create rdoc with the readme as main file
`rdoc --main README.rdoc --include lib/bigbench/help/`
RDoc::Task.new do |rdoc|
rdoc.main = "README.rdoc"
rdoc.rdoc_files.include("README.rdoc", "lib/bigbench/help/")
end
# Fix RDocs inability to handle tables
index_html = File.open('doc/index.html', 'r+'){ |file| file.read }
index_html.gsub! '<', '<'
index_html.gsub! '>', '>'
index_html.gsub! '
', ''
index_html.gsub! '', '
'
index_html.gsub! '
', ''
index_html.gsub! '
', '
'
File.open('doc/index.html', 'w+'){ |file| file.write(index_html) }
# Add table style
rdoc_css = File.open('doc/rdoc.css', 'r+'){ |file| file.read }
rdoc_css += "\n table{ border: 1px dashed #D3D3D3; line-height: 30px; margin-top: 10px; border-collapse: collapse; }"
rdoc_css += "\n td{ padding-left:20px; padding-right:20px; border-top: 1px solid #E4E4E4; }"
rdoc_css += "\n th{ padding-left:20px; padding-right:20px; text-align:left; }"
File.open('doc/rdoc.css', 'w+'){ |file| file.write(rdoc_css) }
# Clean up the rdoc file
File.delete("README.rdoc")
`open doc/index.html`
end
desc "Start Thin RDoc Testserver"
task :server do
load "spec/lib/test_web_server.rb"
Rack::Handler::Thin.run Sinatra::Application, :Port => 3001
end