Rakefile 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. require "rake/rdoctask"
  2. require "rake/testtask"
  3. require "rake/gempackagetask"
  4. require "rubygems"
  5. dir = File.dirname(__FILE__)
  6. lib = File.join(dir, "lib", "faster_csv.rb")
  7. version = File.read(lib)[/^\s*VERSION\s*=\s*(['"])(\d\.\d\.\d)\1/, 2]
  8. task :default => [:test]
  9. Rake::TestTask.new do |test|
  10. test.libs << "test"
  11. test.test_files = %w[test/ts_all.rb]
  12. test.verbose = true
  13. end
  14. Rake::RDocTask.new do |rdoc|
  15. rdoc.main = "README"
  16. rdoc.rdoc_dir = "doc/html"
  17. rdoc.title = "FasterCSV Documentation"
  18. rdoc.options = %w[--charset utf-8]
  19. rdoc.rdoc_files.include( "README", "INSTALL",
  20. "TODO", "CHANGELOG",
  21. "AUTHORS", "COPYING",
  22. "LICENSE", "lib/" )
  23. end
  24. desc "Upload current documentation to Rubyforge"
  25. task :upload_docs => [:rdoc] do
  26. sh "scp -r doc/html/* " +
  27. "bbazzarrakk@rubyforge.org:/var/www/gforge-projects/fastercsv/"
  28. end
  29. desc "Show library's code statistics"
  30. task :stats do
  31. require 'code_statistics'
  32. CodeStatistics.new( ["FasterCSV", "lib"],
  33. ["Units", "test"] ).to_s
  34. end
  35. desc "Time FasterCSV and CSV"
  36. task :benchmark do
  37. TESTS = 6
  38. path = "test/test_data.csv"
  39. sh %Q{time ruby -r csv -e } +
  40. %Q{'#{TESTS}.times { CSV.foreach("#{path}") { |row| } }'}
  41. sh %Q{time ruby -r lib/faster_csv -e } +
  42. %Q{'#{TESTS}.times { FasterCSV.foreach("#{path}") { |row| } }'}
  43. end
  44. spec = Gem::Specification.new do |spec|
  45. spec.name = "fastercsv"
  46. spec.version = version
  47. spec.platform = Gem::Platform::RUBY
  48. spec.summary = "FasterCSV is CSV, but faster, smaller, and cleaner."
  49. spec.test_files = %w[test/ts_all.rb]
  50. spec.files = Dir.glob("{lib,test,examples}/**/*.rb").
  51. reject { |item| item.include?(".svn") } +
  52. Dir.glob("{test,examples}/**/*.csv").
  53. reject { |item| item.include?(".svn") } +
  54. %w[Rakefile test/line_endings.gz]
  55. spec.has_rdoc = true
  56. spec.extra_rdoc_files = %w[ AUTHORS COPYING README INSTALL TODO CHANGELOG
  57. LICENSE ]
  58. spec.rdoc_options << "--title" << "FasterCSV Documentation" <<
  59. "--main" << "README"
  60. spec.require_path = "lib"
  61. spec.author = "James Edward Gray II"
  62. spec.email = "james@grayproductions.net"
  63. spec.rubyforge_project = "fastercsv"
  64. spec.homepage = "http://fastercsv.rubyforge.org"
  65. spec.description = <<END_DESC
  66. FasterCSV is intended as a complete replacement to the CSV standard library. It
  67. is significantly faster and smaller while still being pure Ruby code. It also
  68. strives for a better interface.
  69. END_DESC
  70. end
  71. Rake::GemPackageTask.new(spec) do |pkg|
  72. pkg.need_zip = true
  73. pkg.need_tar = true
  74. end
  75. desc "Add new files to Subversion"
  76. task :add_to_svn do
  77. sh %Q{svn status | ruby -nae 'system "svn add \#{$F[1]}" if $F[0] == "?"' }
  78. end