<NME> tasks.rb
<BEF> #!/usr/bin/env nake
# encoding: utf-8

begin
  require File.expand_path("../.bundle/environment", __FILE__)
rescue LoadError
  require "bundler"
  Bundler.setup
end

$LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))

require "nake/tasks/gem"
require "nake/tasks/release"

load "code-cleaner.nake"
Task["hooks:whitespace:install"].define do
  ARGV.clear.push(".git/hooks/pre-commit")
  ARGF.inplace_mode = ""
  while line = ARGF.gets
    puts %{export PATH="script:$PATH"} if ARGF.lineno.eql?(2)
    puts line
  end
end

unless File.exist?(".git/hooks/pre-commit")
  warn "If you want to contribute to Rango, please run ./tasks.rb hooks:whitespace:install to get Git pre-commit hook for removing trailing whitespace"
    task.config[:path] = "script"
    task.config[:encoding] = "utf-8"
    task.config[:whitelist] = '(bin/[^/]+|Gemfile|.+\.(rb|rake|nake|thor|task|gemspec))$'
  end
rescue LoadError
  warn "If you want to contribute to Rango, please install code-cleaner and then run ./tasks.rb hooks:whitespace:install to get Git pre-commit hook for removing trailing whitespace."
end

require_relative "lib/rango"

# Setup encoding, so all the operations
Task[:release].config[:name] = "rango"
Task[:release].config[:version] = Rango::VERSION

# http://github.com/somebee/rbench/tree/master
Task.new(:bm) do |task|
  task.description = "Run all benchmarks"
  task.define do
    abort "Benchmarks doesn't work at the moment"
    require "rbench"
    Dir["#{Dir.pwd}/benchmarks/bm/*.rb"].each do |benchmark|
      load benchmark
    end
  end
end

<MSG> Default setup for hooks:whitespace:install task

<DFF> @@ -14,14 +14,6 @@ require "nake/tasks/spec"
 require "nake/tasks/release"
 
 load "code-cleaner.nake"
-Task["hooks:whitespace:install"].define do
-  ARGV.clear.push(".git/hooks/pre-commit")
-  ARGF.inplace_mode = ""
-  while line = ARGF.gets
-    puts %{export PATH="script:$PATH"} if ARGF.lineno.eql?(2)
-    puts line
-  end
-end
 
 unless File.exist?(".git/hooks/pre-commit")
   warn "If you want to contribute to Rango, please run ./tasks.rb hooks:whitespace:install to get Git pre-commit hook for removing trailing whitespace"
@@ -39,6 +31,12 @@ Task[:prerelease].config[:gemspec] = "rango.pre.gemspec"
 Task[:release].config[:name] = "rango"
 Task[:release].config[:version] = Rango::VERSION
 
+Nake::Task["hooks:whitespace:install"].tap do |task|
+  task.config[:path] = "script"
+  task.config[:encoding] = "utf-8"
+  task.config[:whitelist] = '(bin/[^/]+|.+\.(rb|rake|nake|thor|task))$'
+end
+
 # http://github.com/somebee/rbench/tree/master
 Task.new(:bm) do |task|
   task.description = "Run all benchmarks"

Default setup for hooks:whitespace:install task