chunker/Rakefile
branchruby-modules
changeset 4 01a3332bfe0a
parent 3 233041485364
child 6 62a5ac525ce8
equal deleted inserted replaced
3:233041485364 4:01a3332bfe0a
     1 #!/usr/bin/env rake
     1 #!/usr/bin/env rake
     2 #
       
     3 # Chunker Rakefile
       
     4 #
     2 #
     5 
     3 
     6 require 'rubygems'
     4 require 'rubygems'
     7 require 'pathname'
     5 require 'pathname'
     8 
     6 
     9 require 'rake'
     7 require 'rake'
    10 require 'spec'
     8 require 'rspec'
    11 require 'rake/testtask'
     9 require 'rspec/core/rake_task'
    12 require 'rake/packagetask'
    10 require 'rake/packagetask'
    13 require 'rake/gempackagetask'
    11 require 'rake/gempackagetask'
    14 require 'spec/rake/spectask'
       
    15 require 'rubygems/installer'
    12 require 'rubygems/installer'
    16 require 'rubygems/uninstaller'
    13 require 'rubygems/uninstaller'
    17 
    14 
    18 
    15 
    19 ######################################################################
    16 ######################################################################
    23 BASEDIR = Pathname.new( __FILE__ ).expand_path.dirname.relative_path_from( Pathname.getwd )
    20 BASEDIR = Pathname.new( __FILE__ ).expand_path.dirname.relative_path_from( Pathname.getwd )
    24 
    21 
    25 TEXT_FILES = %w{ Rakefile README LICENSE }.collect {|f| BASEDIR + f }
    22 TEXT_FILES = %w{ Rakefile README LICENSE }.collect {|f| BASEDIR + f }
    26 
    23 
    27 SPECDIR    = BASEDIR + 'spec'
    24 SPECDIR    = BASEDIR + 'spec'
    28 SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).reject {|f| f =~ /^\.svn/ }
    25 SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' )
    29 
    26 
    30 LIBDIR    = BASEDIR + 'lib'
    27 LIBDIR    = BASEDIR + 'lib'
    31 LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb').reject {|i| i =~ /\.svn/ }
    28 LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb')
    32 
    29 
    33 RELEASE_FILES = TEXT_FILES + LIB_FILES + SPEC_FILES
    30 RELEASE_FILES = TEXT_FILES + LIB_FILES + SPEC_FILES
    34 
    31 
    35 
    32 
    36 ######################################################################
    33 ######################################################################
    54 ######################################################################
    51 ######################################################################
    55 ### P A C K A G E   C O N S T A N T S
    52 ### P A C K A G E   C O N S T A N T S
    56 ######################################################################
    53 ######################################################################
    57 
    54 
    58 PKG_NAME      = 'chunker'
    55 PKG_NAME      = 'chunker'
    59 PKG_VERSION   = find_pattern( LIBDIR + 'chunker.rb', /VERSION = ['"](\d\.\d(?:\/\d)?)['"]/ )
    56 PKG_VERSION   = find_pattern( LIBDIR + 'chunker.rb', /VERSION = ['"](.+)['"]/ )
    60 PKG_REVISION  = find_pattern( LIBDIR + 'chunker.rb', /SVNRev = .+Rev: (\d+)/ )
    57 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
    61 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}.#{PKG_REVISION}"
       
    62 
    58 
    63 
    59 
    64 ######################################################################
    60 ######################################################################
    65 ### T A S K S
    61 ### T A S K S
    66 ######################################################################
    62 ######################################################################
    67 
    63 
    68 task :default => [ :test, :package ]
    64 task :test    => 'test:spec'
       
    65 task :default => :test
       
    66 # task :default => [ :test, :package ]
    69 
    67 
       
    68 namespace :test do
       
    69 	desc 'Generate verbose and pretty output'
       
    70 	RSpec::Core::RakeTask.new( :spec ) do |task|
       
    71 		task.pattern = SPEC_FILES
       
    72 		task.rspec_opts  = ['-b', '-fd', '-c']
       
    73 	end
    70 
    74 
    71 ### Task: run rspec tests
    75 	desc 'Generate quiet non-colored plain-text output'
    72 ###
    76 	RSpec::Core::RakeTask.new( :quiet ) do |task|
    73 desc "Run tests"
    77 		task.pattern = SPEC_FILES
    74 Spec::Rake::SpecTask.new('test') do |task|
    78 		task.rspec_opts  = ['-f', 'p']
    75 	task.spec_files = SPEC_FILES
    79 	end
    76 	task.spec_opts  = %w{ -c -fs }
       
    77 end
    80 end
    78 
       
    79 
    81 
    80 ### Task: generate ctags
    82 ### Task: generate ctags
    81 ### This assumes exuberant ctags, since ctags 'native' doesn't support ruby anyway.
    83 ### This assumes exuberant ctags, since ctags 'native' doesn't support ruby anyway.
    82 ###
    84 ###
    83 desc "Generate a ctags 'tags' file from Chunker source"
    85 desc "Generate a ctags 'tags' file from Chunker source"
    87 
    89 
    88 
    90 
    89 ### Task: Create gem from source
    91 ### Task: Create gem from source
    90 ###
    92 ###
    91 gem = Gem::Specification.new do |gem|
    93 gem = Gem::Specification.new do |gem|
    92 	pkg_build = PKG_REVISION || 0
       
    93 
       
    94 	gem.summary           = "A convenience library for parsing __END__ tokens consistently."
    94 	gem.summary           = "A convenience library for parsing __END__ tokens consistently."
    95 	gem.name              = PKG_NAME
    95 	gem.name              = PKG_NAME
    96 	gem.version           = "%s.%s" % [ PKG_VERSION, pkg_build ]
    96 	gem.version           = PKG_VERSION
    97 	gem.author            = 'Mahlon E. Smith'
    97 	gem.author            = 'Mahlon E. Smith'
    98 	gem.email             = 'mahlon@martini.nu'
    98 	gem.email             = 'mahlon@martini.nu'
    99 	gem.homepage          = 'http://projects.martini.nu/ruby-modules/wiki/Chunker'
    99 	gem.homepage          = 'http://projects.martini.nu/ruby-modules/wiki/Chunker'
   100 	gem.rubyforge_project = 'mahlon'
       
   101 	gem.has_rdoc          = true
   100 	gem.has_rdoc          = true
   102 
   101 
   103 	gem.files = RELEASE_FILES.
   102 	gem.files = RELEASE_FILES.
   104 		collect {|f| f.relative_path_from(BASEDIR).to_s }
   103 		collect {|f| f.relative_path_from(BASEDIR).to_s }
   105 	gem.test_files	= SPEC_FILES.
   104 	gem.test_files	= SPEC_FILES.