diff options
Diffstat (limited to 'tasks')
-rw-r--r-- | tasks/csts.rake | 72 | ||||
-rw-r--r-- | tasks/gem.rake | 22 | ||||
-rw-r--r-- | tasks/rcov.rake | 9 | ||||
-rw-r--r-- | tasks/rdoc.rake | 17 | ||||
-rw-r--r-- | tasks/show.rake | 21 | ||||
-rw-r--r-- | tasks/stats.rake | 25 | ||||
-rw-r--r-- | tasks/test.rake | 12 | ||||
-rw-r--r-- | tasks/todo.rake | 6 |
8 files changed, 184 insertions, 0 deletions
diff --git a/tasks/csts.rake b/tasks/csts.rake new file mode 100644 index 0000000..be656e3 --- /dev/null +++ b/tasks/csts.rake @@ -0,0 +1,72 @@ + +# GLOBAL CONFIG +F_CHMOD = 0644 +D_CHMOD = 0755 + +# VERSION +RUBY_1_9 = RUBY_VERSION =~ /^1\.9/ +WIN = (RUBY_PLATFORM =~ /mswin|cygwin/) +SUDO = (WIN ? "" : "sudo" ) + +# EXTENSIONS +HAVE_EXT = File.directory? "#{EXT_DIR}" +EXT_CONF_FILES = FileList["#{EXT_DIR}/**/extconf.rb"] +EXT_SRC_FILES = FileList["#{EXT_DIR}/**/*.{c,h}"] +EXT_FILES = EXT_SRC_FILES + EXT_CONF_FILES + +# FILES +RAKE_FILES = FileList[RAKEFILE, PRJ_FILE, GEM_SPEC_FILE, SETUP_FILE, "#{RAKE_DIR}/*"] +BIN_FILES = FileList["#{BIN_DIR}/**/*"] +LIB_FILES = FileList["#{LIB_DIR}/**/*.rb"] +TEST_FILES = FileList["#{TEST_DIR}/**/test_*.rb"] +RDOC_FILES = FileList[README, CHANGES, LICENSE] + +# DIST FILES +DIST_FILES = FileList[] +DIST_FILES.include(RAKE_FILES) +DIST_FILES.include(BIN_FILES) +DIST_FILES.include(LIB_FILES) +DIST_FILES.include(TEST_FILES) +DIST_FILES.include(RDOC_FILES) +DIST_FILES.include(DATA_FILES) +DIST_FILES.include(EXT_FILES) if HAVE_EXT +DIST_FILES.include("#{RDOC_DIR}/**/*.{html,css}", 'man/*.[0-9]') +DIST_FILES.exclude('**/tmp_*', '**/*.tmp') + +# +CLEAN.include( 'README' ) if File.exist? 'README.rb' +CLEAN.include( 'CHANGES' ) if File.exist? 'CHANGES.rb' +CLEAN.include( FileList["#{EXT_DIR}/**/*.{o,so}","#{EXT_DIR}/**/Makefile"], '.config' ) if HAVE_EXT + +# LOADPATH +REQUIRE_PATHS = [LIB_DIR] +REQUIRE_PATHS << FileList["#{EXT_DIR}/**"] if HAVE_EXT +#$LOAD_PATH.concat REQUIRE_PATHS + +# C EXTENSIONS TASKS +if HAVE_EXT + CONFIG_OPTS = ENV['CONFIG'] + file_create '.config' do + ruby "setup.rb -q config #{CONFIG_OPTS}" + end + + desc 'Configure and make C extensions. The CONFIG variable is passed to \'setup.rb config\'' + task :make_ext => '.config' do + ruby "setup.rb -q setup" + end + + task :test_ext => :make_ext + desc 'Run test after making the extensions.' + task :test => :make_ext do + Rake::Task[:test_ext].invoke + end +end + +# CERTIFICATE +cert_dir = ENV['CERT_DIR'] ||= File.expand_path(File.join('~', '.gem')) +HAVE_CERT = File.readable?(File.join(cert_dir, 'gem-private_key.pem')) and File.readable?(File.join(cert_dir, 'gem-public_cert.pem')) +if HAVE_CERT + CERT_PRIVATE = File.join(cert_dir, 'gem-private_key.pem') + CERT_PUBLIC = File.join(cert_dir, 'gem-public_cert.pem') +end + diff --git a/tasks/gem.rake b/tasks/gem.rake new file mode 100644 index 0000000..f22f722 --- /dev/null +++ b/tasks/gem.rake @@ -0,0 +1,22 @@ +# GEM TASK +Rake::GemPackageTask.new(GEM_SPEC) { |pkg| + pkg.need_zip = true + pkg.need_tar = true + puts "Signed with #{CERT_PRIVATE}" if HAVE_CERT +} + +desc "if dir chmod #{D_CHMOD} if file chmod #{F_CHMOD}" +task :chmod =>RDOC_FILES do + Dir.glob('**/*'){ |p| + open(p){ |f| f.chmod(F_CHMOD) } if File.file? p + open(p){ |f| f.chmod(D_CHMOD) } if File.directory? p + } +end + +task :release => [:clobber, :chmod] do + puts "Preparing release of #{PROJECT_NAME} version #{PROJECT_VERSION}" + Rake::Task[:test].invoke +# Rake::Task[:rdoc].invoke + Rake::Task[:package].invoke +end + diff --git a/tasks/rcov.rake b/tasks/rcov.rake new file mode 100644 index 0000000..b1ad8bb --- /dev/null +++ b/tasks/rcov.rake @@ -0,0 +1,9 @@ + +require 'rcov/rcovtask' + +# RCOV TASK +Rcov::RcovTask.new do |t| + t.output_dir = RCOV_DIR + t.verbose = true + t.rcov_opts = [ "--charset utf8", "-T", "-i ^test", "-i ^bin", "-i ^lib", "-x ^/home", "-x ^#{ENV['GEM_HOME']}"] +end diff --git a/tasks/rdoc.rake b/tasks/rdoc.rake new file mode 100644 index 0000000..7ceaba1 --- /dev/null +++ b/tasks/rdoc.rake @@ -0,0 +1,17 @@ + +require 'rake/rdoctask' + +# RDOC +GENERAL_RDOC_OPTS = { + "--title" => "#{PROJECT_NAME} API documentation", + "--main" => README +} + +# RDOC TASK +Rake::RDocTask.new(:rdoc) do |t| + t.rdoc_files = RDOC_FILES + LIB_FILES + t.title = GENERAL_RDOC_OPTS['--title'] + t.main = GENERAL_RDOC_OPTS['--main'] + t.rdoc_dir = RDOC_DIR + t.options += [ "--inline-source", "--line-numbers" ] +end diff --git a/tasks/show.rake b/tasks/show.rake new file mode 100644 index 0000000..f653ba8 --- /dev/null +++ b/tasks/show.rake @@ -0,0 +1,21 @@ +# TASK SHOW +def enum_files( label, files=[] ) + puts "#{label}\t:" #{files.length==0 ? 'nil' : ''}" + files.each{ |f| puts "\t #{f}" } +end + +desc 'Show current configuration of this project' +task :show do + puts "built on #{GEM_SPEC.date.strftime('%d-%m-%Y')}" + puts "project\t: #{PROJECT_NAME} #{UNIX_NAME}-#{PROJECT_VERSION} [ #{PROJECT_SUMMARY} ]" + puts "owner\t: #{USER_NAME} [#{RUBYFORGE_USER}] #{USER_EMAIL}" + enum_files 'rake', RAKE_FILES + enum_files 'bin', BIN_FILES + enum_files 'lib', LIB_FILES + enum_files EXT_DIR, EXT_FILES + enum_files 'test', TEST_FILES + enum_files 'rdoc', RDOC_FILES + enum_files 'data', DATA_FILES + enum_files 'paths', REQUIRE_PATHS +end + diff --git a/tasks/stats.rake b/tasks/stats.rake new file mode 100644 index 0000000..19ffd8e --- /dev/null +++ b/tasks/stats.rake @@ -0,0 +1,25 @@ + +desc 'lines and words count of real ruby code ( no empty lines or comments )' +task :stats do + pattern = Regexp.new("^\s*(?:#.*)?$") +# count_proc = Proc.new do |path| +# Dir[path].collect { |f| File.open(f).readlines.reject { |l| l =~ pattern }.size }.inject(0) { |sum,n| sum+=n } +# end + stat_proc = Proc.new do |files,name| + lines=0 + words=0 + files.each { |fn| open(fn){ |f| f.each{ |line| + begin + lines += 1 + words += line.split(' ').size + end if not pattern.match(line) + } } } + puts "#{ format('%10s',name)} => #{format('%7d',lines)} code lines, #{format('%7d',words)} words." + end + stat_proc.call BIN_FILES, 'bin' + stat_proc.call LIB_FILES, 'lib' + stat_proc.call TEST_FILES, 'test' + stat_proc.call EXT_FILES, 'ext' + +end + diff --git a/tasks/test.rake b/tasks/test.rake new file mode 100644 index 0000000..149706d --- /dev/null +++ b/tasks/test.rake @@ -0,0 +1,12 @@ + +require 'rake/testtask' + +# TEST TASK +test_task_name = HAVE_EXT ? :test_ext : :test +Rake::TestTask.new( test_task_name ) do |t| + t.libs = REQUIRE_PATHS + t.test_files = TEST_FILES + t.verbose = false +end + +task :test_ext => :make_ext if HAVE_EXT diff --git a/tasks/todo.rake b/tasks/todo.rake new file mode 100644 index 0000000..430936d --- /dev/null +++ b/tasks/todo.rake @@ -0,0 +1,6 @@ + +require 'todotask' + +# TODO TASK +ToDoTask.new + |