Rakefile in file-tail-1.0.5 vs Rakefile in file-tail-1.0.6

- old
+ new

@@ -1,40 +1,62 @@ # vim: set filetype=ruby et sw=2 ts=2: begin - require 'rake/gempackagetask' + require 'rubygems/package_task' rescue LoadError end require 'rake/clean' require 'rbconfig' include Config PKG_NAME = 'file-tail' PKG_VERSION = File.read('VERSION').chomp -PKG_FILES = FileList["**/*"].exclude(/^(pkg|coverage|doc)/) +PKG_FILES = FileList["**/*"].exclude(/^(pkg|coverage|doc|\..*|Gemfile.lock)/) CLEAN.include 'coverage', 'doc' -desc "Installing library" +desc "Install executable/library into site_ruby directories" task :install do - ruby 'install.rb' + cd 'lib' do + libdir = CONFIG["sitelibdir"] + + dest = File.join(libdir, 'file') + mkdir_p(dest) + file = File.join('file', 'tail.rb') + install(file, dest, :verbose => true) + + dest = File.join(dest, 'tail') + mkdir_p(dest) + for file in Dir[File.join('file', 'tail', '*.rb')] + install(file, dest, :verbose => true) + end + end + bindir = CONFIG["bindir"] + install('bin/rtail', bindir, :verbose => true, :mode => 0755) end -desc "Creating documentation" +desc "Create documentation" task :doc do - ruby 'make_doc.rb' + sh "sdoc -m README.rdoc -t 'File::Tail - Tailing files in Ruby' README.rdoc #{Dir['lib/**/*.rb'] * ' '}" end desc "Testing library" task :test do - ruby %{-Ilib tests/test_file-tail.rb} + ruby %{-Ilib tests/test_file-tail*.rb} end desc "Testing library with rcov" task :coverage do - system %{rcov -x '\\btests\/' -Ilib tests/test_file-tail.rb} + sh %{rcov -x '\\b/gems\/' -x '\\btests\/' -Ilib tests/test_file-tail*.rb} end +namespace :gems do + desc "Install all gems from the Gemfile" + task :install do + sh 'bundle install' + end +end + if defined? Gem spec = Gem::Specification.new do |s| s.name = PKG_NAME s.version = PKG_VERSION s.summary = "File::Tail for Ruby" @@ -43,24 +65,30 @@ s.executables = 'rtail' s.files = PKG_FILES s.require_path = 'lib' - s.add_dependency 'spruz', '>=0.1.0' + s.add_dependency 'spruz', '~>0.2' - s.has_rdoc = true - s.rdoc_options << '--main' << 'README' << '--title' << 'File::Tail - Tailing files in Ruby' - s.extra_rdoc_files << 'README' - s.test_files << 'tests/test_file-tail.rb' + s.rdoc_options << '--main' << 'README.rdoc' << '--title' << 'File::Tail - Tailing files in Ruby' + s.extra_rdoc_files << 'README.rdoc' + s.test_files.concat Dir['tests/test_*.rb'] s.author = "Florian Frank" s.email = "flori@ping.de" s.homepage = "http://flori.github.com/#{PKG_NAME}" s.rubyforge_project = PKG_NAME end - Rake::GemPackageTask.new(spec) do |pkg| + desc 'Create a gemspec file' + task :gemspec => :version do + File.open('file-tail.gemspec', 'w') do |gemspec| + gemspec.write spec.to_ruby + end + end + + Gem::PackageTask.new(spec) do |pkg| pkg.need_tar = true pkg.package_files += PKG_FILES end end @@ -81,8 +109,10 @@ end EOT end end +desc "Run the tests by default" task :default => [ :version, :test ] -task :release => [ :clean, :version, :package ] +desc "Prepare release of the library" +task :release => [ :clean, :gemspec, :package ]