require 'rake/clean' require 'rake/testtask' require 'rake/gempackagetask' require 'rbconfig' include Config require 'find' include Find PKG_NAME = 'neuro' PKG_VERSION = File.read('VERSION').chomp PKG_FILES = FileList['**/*'] PKG_FILES.exclude('CVS') PKG_FILES.exclude('pkg') PKG_FILES.exclude(/\.dump$/) task :default => [:test] desc "Run unit tests" task(:test => [:compile]) do cd 'tests' do ruby %{-I../ext runner.rb} end end desc "Creating documentation" task :doc do sh 'rdoc -m Neuro -d -o doc ext/neuro.c'# lib/neuro/display.rb' end desc "Compiling library" task :compile do cd 'ext' do ruby 'extconf.rb' sh 'make' end end desc "Installing library" task(:install => [:test]) do src = "ext/neuro.#{CONFIG['DLEXT']}" filename = File.basename(src) dst = File.join(CONFIG["sitelibdir"], filename) install(src, dst, :verbose => true, :mode => 0644) src = 'lib/neuro/display.rb' filename = File.basename(src) dst_dir = File.join(CONFIG["sitelibdir"], 'neuro') mkdir_p dst_dir dst = File.join(dst_dir, filename) install(src, dst, :verbose => true, :mode => 0644) end task :clean do find('.') do |f| if f =~ /\.dump$/ rm f end end cd 'ext' do sh 'make distclean' rescue nil end end spec = Gem::Specification.new do |s| #### Basic information. s.name = 'neuro' s.version = PKG_VERSION s.summary = "Neural Network Extension for Ruby" s.description = < 1.0.4') #s.requirements << "" s.files = PKG_FILES #### C code extensions. s.extensions << "ext/extconf.rb" #### Load-time details: library and application (you will need one or both). s.require_path = 'ext' # Use these for libraries. s.autorequire = 'neuro' #s.bindir = "bin" # Use these for applications. #s.executables = ["foo.rb"] #s.default_executable = "foo.rb" #### Documentation and testing. s.has_rdoc = true s.extra_rdoc_files = [ 'ext/neuro.c' ] s.rdoc_options << '--main' << 'Neuro' s.test_files << 'tests/runner.rb' #### Author and project details. s.author = "Florian Frank" s.email = "flori@ping.de" s.homepage = "http://neuro.rubyforge.org" s.rubyforge_project = "neuro" end Rake::GemPackageTask.new(spec) do |pkg| pkg.package_files += PKG_FILES pkg.need_tar = true end task :release => [ :clean, :compile, :package ] # vim: set et sw=2 ts=2: