require 'rake' require 'rubygems' require 'rake/rdoctask' require 'rake/gempackagetask' require 'rake/testtask' require 'rake/clean' require 'fileutils' ############################################### # GLOBAL ############################################### FL = FileList NAME = "mspire" lib_files = FL["lib/**/*"] test_dir_too = FL["test/**/*"] little_dist_files = lib_files + FL["INSTALL", "README", "Rakefile", "LICENSE", "changelog.txt", "release_notes.txt", "{bin,script,tutorial}/**/*"] dist_files = lib_files + FL["INSTALL", "README", "Rakefile", "LICENSE", "{bin,script,tutorial}/**/*", test_dir_too] dist_files = little_dist_files # comment out to include test files ############################################### # ENVIRONMENT ############################################### ENV["OS"] == "Windows_NT" ? WIN32 = true : WIN32 = false gemcmd = "gem" if WIN32 unless ENV["TERM"] == "cygwin" gemcmd << ".cmd" end end ############################################### # DOC ############################################### def move_and_add_webgen_header(file, newfile, src_dir, heading) string = IO.read file with_header = heading + string File.open(newfile, 'w') {|v| v.print with_header } FileUtils.mv newfile, src_dir end desc "copy top level files into doc/src" task :cp_top_level_docs do string = "--- title: TITLE inMenu: true directoryName: mspire ---\n" src = "doc/src" move_and_add_webgen_header('README', 'index.page', src, string.sub('TITLE', 'Home')) move_and_add_webgen_header('INSTALL', 'install.page', src, string.sub('TITLE', 'Install')) end desc "create and upload docs to server" task :upload_docs => :html_docs do sh "scp -i ~/.ssh/rubyforge_key -r doc/output/* jtprince@rubyforge.org:/var/www/gforge-projects/mspire/" end desc "creates docs in doc/html" task :html_docs => [:cp_top_level_docs] do FileUtils.cd 'doc' do sh "webgen" end end rdoc_options = ['--main', 'README', '--title', NAME] rdoc_extra_includes = ["README", "INSTALL", "LICENSE"] Rake::RDocTask.new do |rd| rd.main = "README" rd.rdoc_files.include rdoc_extra_includes rd.options.push( *rdoc_options ) end ############################################### # TESTS ############################################### desc "Run unit tests." Rake::TestTask.new do |t| reply = `#{gemcmd} list -l #{NAME}` if reply.include? NAME + " (" puts "GOING to uninstall gem '#{NAME}' for testing" if WIN32 %x( #{gemcmd} uninstall -x #{NAME} ) else %x( sudo #{gemcmd} uninstall -x #{NAME} ) end end # t.libs << "lib" ## done by default t.test_files = FL["test/tc_*.rb"] #t.verbose = true end desc "Run unit tests individual on each test" task :test_ind do |t| reply = `#{gemcmd} list -l #{NAME}` if reply.include? NAME + " (" %x( sudo #{gemcmd} uninstall -x #{NAME} ) end # t.libs << "lib" ## done by default test_files = FL["test/tc_*.rb"] test_files.each do |file| puts "TESTING: #{file.sub(/test\//,'')}" puts `ruby -I lib #{file}` end #t.verbose = true end #desc "Run all tests" #task :test_indiv do # sys.cd "test" do # sys["tc_*.rb"].each do |file| # sys "ruby #{file}" # end # end #end ############################################### # PACKAGE / INSTALL / UNINSTALL ############################################### ## To release a package on rubyforge: ## Login to rubyforge and go the 'Files' tab ## then "To create a new release click here" tm = Time.now spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = NAME s.version = "0.2.4" s.summary = "Mass Spectrometry Proteomics Objects, Scripts, and Executables" s.date = "#{tm.year}-#{tm.month}-#{tm.day}" s.email = "jprince@icmb.utexas.edu" s.homepage = "http://mspire.rubyforge.org" s.rubyforge_project = "mspire" s.description = "mspire is for working with mass spectrometry proteomics data" s.has_rdoc = true s.authors = ["John Prince"] s.files = little_dist_files s.rdoc_options = rdoc_options s.extra_rdoc_files = rdoc_extra_includes s.executables = FL["bin/*"].map {|file| File.basename(file) } s.add_dependency('libjtp', '~> 0.1.4') s.requirements << '"xmlparser" is the prefered xml parser right now. REXML and regular expressions are used as fallback in some routines.' s.requirements << 'some plotting functions will not be available without the "gnuplot" gem (and underlying gnuplot binary)' s.requirements << 'the "t2x" binary (in archive) or readw.exe is required to convert .RAW files to mzXML in some applications' s.requirements << '"rake" is useful for development' s.requirements << '"webgen (with gems redcloth and bluecloth) is necessary to build web pages' s.test_files = FL["test/tc_*.rb"] end desc "Create packages." Rake::GemPackageTask.new(spec) do |pkg| pkg.need_zip = true pkg.need_tar = true end #desc "Create packages." #gen RubyPackage, NAME do |t| # t.version = "0.1.4" # t.summary = "Mass Spectrometry Proteomics Objects, Scripts, and Executables" # t.files = dist_files # t.bindir = "bin" # t.executable = sys["bin/*"].collect {|file| File.basename(file) } # t.test_files = sys["test/tc_*.rb"] # t.gem_add_dependency('libjtp', '= 0.1.1') # t.package_task #end task :install => [:reinstall] desc "uninstalls the package, packages a fresh one, and installs" task :reinstall => [:clean, :package] do reply = `#{gemcmd} list -l #{NAME}` if reply.include? NAME + " (" %x( #{gemcmd} uninstall -x #{NAME} ) end FileUtils.cd("pkg") do %x( #{gemcmd} install #{NAME} ) end end ############################################### # CLEANUP ############################################### #desc "Remove autogenerated and backup files." #gen Clean #var[:clean].include "pkg", "*~", tutorial_files