# -* coding: utf-8 -*-
#require 'rake/testtask'
#require 'rake/extensiontask'
require 'rake/packagetask'
begin
  require 'bundler/gem_tasks'
rescue LoadError
  puts 'If you want to create gem, You must install Bundler'
end

require './lib/numru/misc/version.rb'
def version
  NumRu::Misc::VERSION
end

=begin
task :default => :test
task :test => :compile
Rake::TestTask.new do |t|
  t.libs << 'lib' << 'test'
  #t.test_files = FileList['test/test_*.rb'].exclude('test/test_assoccoords.rb')
  #t.test_files = FileList['./demo/rubydcloriginal/*.rb']
end

Rake::ExtensionTask.new do |ext|
  ext.name = 'dcl_raw'
  ext.ext_dir = 'ext/numru'
  ext.lib_dir = 'lib/numru'
end
=end

Rake::PackageTask.new('numru-misc', "#{version}") do |t|
  t.need_tar_gz = true
  t.package_files.include `git ls-files`.split("\n")
end

destdir = ENV["DESTDIR"] || ""
sitelibdir = ENV["SITELIBDIR"] || RbConfig::CONFIG["sitelibdir"]

LIBS = FileList["lib/**/*rb"]

task :nongeminstall do
  prefix = File.join(destdir, sitelibdir)
  LIBS.each do |lib|
    dst = File.join(prefix, File.dirname(lib.sub(/\Alib\//,"")))
    mkdir_p dst
    install lib, dst, :mode => 0644
  end
end
