chunker/Rakefile
author Mahlon E. Smith <mahlon@martini.nu>
Sat, 22 Jan 2011 01:55:55 -0800
branchruby-modules
changeset 8 fe38422c10a4
parent 6 62a5ac525ce8
permissions -rw-r--r--
Added signature for changeset 62a5ac525ce8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
     1
#!/usr/bin/env rake
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
     2
#
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
     3
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
     4
require 'rubygems'
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
     5
require 'pathname'
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
     6
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
     7
require 'rake'
4
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
     8
require 'rspec'
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
     9
require 'rspec/core/rake_task'
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    10
require 'rake/packagetask'
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    11
require 'rake/gempackagetask'
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    12
require 'rubygems/installer'
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    13
require 'rubygems/uninstaller'
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    14
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    15
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    16
######################################################################
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    17
### P A T H S  A N D  F I L E S
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    18
######################################################################
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    19
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    20
BASEDIR = Pathname.new( __FILE__ ).expand_path.dirname.relative_path_from( Pathname.getwd )
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    21
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    22
TEXT_FILES = %w{ Rakefile README LICENSE }.collect {|f| BASEDIR + f }
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    23
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    24
SPECDIR    = BASEDIR + 'spec'
4
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    25
SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' )
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    26
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    27
LIBDIR    = BASEDIR + 'lib'
4
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    28
LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb')
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    29
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    30
RELEASE_FILES = TEXT_FILES + LIB_FILES + SPEC_FILES
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    31
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    32
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    33
######################################################################
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    34
### H E L P E R S
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    35
######################################################################
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    36
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    37
### Given a +file+ path, find the first captured match of +pattern+,
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    38
### or the string 'UNKNOWN' if not found. (easy to notice something is wrong.)
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    39
###
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    40
def find_pattern( file, pattern )
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    41
	ver = nil
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    42
	File.open( file ) do |f|
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    43
		ver = f.each do |line|
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    44
			break $1 if line =~ pattern
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    45
		end
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    46
	end
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    47
	return ver.is_a?( String ) ? ver : 'UNKNOWN'
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    48
end
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    49
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    50
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    51
######################################################################
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    52
### P A C K A G E   C O N S T A N T S
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    53
######################################################################
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    54
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    55
PKG_NAME      = 'chunker'
4
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    56
PKG_VERSION   = find_pattern( LIBDIR + 'chunker.rb', /VERSION = ['"](.+)['"]/ )
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    57
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    58
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    59
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    60
######################################################################
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    61
### T A S K S
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    62
######################################################################
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    63
4
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    64
task :test    => 'test:spec'
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    65
task :default => :test
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    66
# task :default => [ :test, :package ]
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    67
6
62a5ac525ce8 Update copyright, make description shorter so it'll look nicer when
Mahlon E. Smith <mahlon@martini.nu>
parents: 4
diff changeset
    68
62a5ac525ce8 Update copyright, make description shorter so it'll look nicer when
Mahlon E. Smith <mahlon@martini.nu>
parents: 4
diff changeset
    69
### Tasks: testing via rspec
62a5ac525ce8 Update copyright, make description shorter so it'll look nicer when
Mahlon E. Smith <mahlon@martini.nu>
parents: 4
diff changeset
    70
###
4
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    71
namespace :test do
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    72
	desc 'Generate verbose and pretty output'
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    73
	RSpec::Core::RakeTask.new( :spec ) do |task|
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    74
		task.pattern = SPEC_FILES
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    75
		task.rspec_opts  = ['-b', '-fd', '-c']
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    76
	end
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    77
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    78
	desc 'Generate quiet non-colored plain-text output'
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    79
	RSpec::Core::RakeTask.new( :quiet ) do |task|
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    80
		task.pattern = SPEC_FILES
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    81
		task.rspec_opts  = ['-f', 'p']
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
    82
	end
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    83
end
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    84
6
62a5ac525ce8 Update copyright, make description shorter so it'll look nicer when
Mahlon E. Smith <mahlon@martini.nu>
parents: 4
diff changeset
    85
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    86
### Task: generate ctags
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    87
### This assumes exuberant ctags, since ctags 'native' doesn't support ruby anyway.
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    88
###
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    89
desc "Generate a ctags 'tags' file from Chunker source"
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    90
task :ctags do
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    91
	sh "ctags -R #{LIBDIR}"
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    92
end
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    93
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    94
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    95
### Task: Create gem from source
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    96
###
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
    97
gem = Gem::Specification.new do |gem|
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    98
	gem.summary           = "A convenience library for parsing __END__ tokens consistently."
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
    99
	gem.name              = PKG_NAME
4
01a3332bfe0a Bump Chunker to 1.0.0 (release), updates for rspec 2.
Mahlon E. Smith <mahlon@martini.nu>
parents: 3
diff changeset
   100
	gem.version           = PKG_VERSION
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   101
	gem.author            = 'Mahlon E. Smith'
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   102
	gem.email             = 'mahlon@martini.nu'
3
233041485364 Require spec implicitly.
mahlon
parents: 2
diff changeset
   103
	gem.homepage          = 'http://projects.martini.nu/ruby-modules/wiki/Chunker'
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   104
	gem.has_rdoc          = true
6
62a5ac525ce8 Update copyright, make description shorter so it'll look nicer when
Mahlon E. Smith <mahlon@martini.nu>
parents: 4
diff changeset
   105
	gem.extra_rdoc_files  = ['README']
62a5ac525ce8 Update copyright, make description shorter so it'll look nicer when
Mahlon E. Smith <mahlon@martini.nu>
parents: 4
diff changeset
   106
	gem.rdoc_options      << '--main' << 'README'
62a5ac525ce8 Update copyright, make description shorter so it'll look nicer when
Mahlon E. Smith <mahlon@martini.nu>
parents: 4
diff changeset
   107
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   108
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   109
	gem.files = RELEASE_FILES.
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   110
		collect {|f| f.relative_path_from(BASEDIR).to_s }
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   111
	gem.test_files	= SPEC_FILES.
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   112
		collect {|f| f.relative_path_from(BASEDIR).to_s }
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   113
6
62a5ac525ce8 Update copyright, make description shorter so it'll look nicer when
Mahlon E. Smith <mahlon@martini.nu>
parents: 4
diff changeset
   114
	gem.description = "Embed arbitrary data and multiple, distinct documents within ruby files."
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   115
end
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   116
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   117
Rake::GemPackageTask.new( gem ) do |pkg|
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   118
	pkg.need_zip     = true
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   119
	pkg.need_tar     = true
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   120
	pkg.need_tar_bz2 = true
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   121
end
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   122
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   123
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   124
### Task: install
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   125
###
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   126
task :install_gem => [ :package ] do
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   127
	$stderr.puts
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   128
	installer = Gem::Installer.new( "pkg/#{PKG_FILE_NAME}.gem" )
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   129
	installer.install
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   130
end
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   131
task :install => [ :install_gem ]
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   132
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   133
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   134
### Task: uninstall
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   135
###
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   136
task :uninstall_gem do
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   137
	uninstaller = Gem::Uninstaller.new( PKG_NAME )
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   138
	uninstaller.uninstall
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   139
end
2
e5c705047540 * Rename 'markers' to 'token'
mahlon
parents: 1
diff changeset
   140
task :uninstall => [ :uninstall_gem ]
1
9e127bf6e84f Initial commit of chunker, a ruby module to aid with data blocks.
mahlon
parents:
diff changeset
   141