--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Rakefile Wed Jan 06 14:36:04 2016 -0800
@@ -0,0 +1,141 @@
+#!/usr/bin/env rake
+#
+
+require 'rubygems'
+require 'pathname'
+
+require 'rake'
+require 'rspec'
+require 'rspec/core/rake_task'
+require 'rake/packagetask'
+require 'rake/gempackagetask'
+require 'rubygems/installer'
+require 'rubygems/uninstaller'
+
+
+######################################################################
+### P A T H S A N D F I L E S
+######################################################################
+
+BASEDIR = Pathname.new( __FILE__ ).expand_path.dirname.relative_path_from( Pathname.getwd )
+
+TEXT_FILES = %w{ Rakefile README LICENSE }.collect {|f| BASEDIR + f }
+
+SPECDIR = BASEDIR + 'spec'
+SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' )
+
+LIBDIR = BASEDIR + 'lib'
+LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb')
+
+RELEASE_FILES = TEXT_FILES + LIB_FILES + SPEC_FILES
+
+
+######################################################################
+### H E L P E R S
+######################################################################
+
+### Given a +file+ path, find the first captured match of +pattern+,
+### or the string 'UNKNOWN' if not found. (easy to notice something is wrong.)
+###
+def find_pattern( file, pattern )
+ ver = nil
+ File.open( file ) do |f|
+ ver = f.each do |line|
+ break $1 if line =~ pattern
+ end
+ end
+ return ver.is_a?( String ) ? ver : 'UNKNOWN'
+end
+
+
+######################################################################
+### P A C K A G E C O N S T A N T S
+######################################################################
+
+PKG_NAME = 'chunker'
+PKG_VERSION = find_pattern( LIBDIR + 'chunker.rb', /VERSION = ['"](.+)['"]/ )
+PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
+
+
+######################################################################
+### T A S K S
+######################################################################
+
+task :test => 'test:spec'
+task :default => :test
+# task :default => [ :test, :package ]
+
+
+### Tasks: testing via rspec
+###
+namespace :test do
+ desc 'Generate verbose and pretty output'
+ RSpec::Core::RakeTask.new( :spec ) do |task|
+ task.pattern = SPEC_FILES
+ task.rspec_opts = ['-b', '-fd', '-c']
+ end
+
+ desc 'Generate quiet non-colored plain-text output'
+ RSpec::Core::RakeTask.new( :quiet ) do |task|
+ task.pattern = SPEC_FILES
+ task.rspec_opts = ['-f', 'p']
+ end
+end
+
+
+### Task: generate ctags
+### This assumes exuberant ctags, since ctags 'native' doesn't support ruby anyway.
+###
+desc "Generate a ctags 'tags' file from Chunker source"
+task :ctags do
+ sh "ctags -R #{LIBDIR}"
+end
+
+
+### Task: Create gem from source
+###
+gem = Gem::Specification.new do |gem|
+ gem.summary = "A convenience library for parsing __END__ tokens consistently."
+ gem.name = PKG_NAME
+ gem.version = PKG_VERSION
+ gem.author = 'Mahlon E. Smith'
+ gem.email = 'mahlon@martini.nu'
+ gem.homepage = 'http://projects.martini.nu/ruby-modules/wiki/Chunker'
+ gem.has_rdoc = true
+ gem.extra_rdoc_files = ['README']
+ gem.rdoc_options << '--main' << 'README'
+
+
+ gem.files = RELEASE_FILES.
+ collect {|f| f.relative_path_from(BASEDIR).to_s }
+ gem.test_files = SPEC_FILES.
+ collect {|f| f.relative_path_from(BASEDIR).to_s }
+
+ gem.description = "Embed arbitrary data and multiple, distinct documents within ruby files."
+end
+
+Rake::GemPackageTask.new( gem ) do |pkg|
+ pkg.need_zip = true
+ pkg.need_tar = true
+ pkg.need_tar_bz2 = true
+end
+
+
+### Task: install
+###
+task :install_gem => [ :package ] do
+ $stderr.puts
+ installer = Gem::Installer.new( "pkg/#{PKG_FILE_NAME}.gem" )
+ installer.install
+end
+task :install => [ :install_gem ]
+
+
+### Task: uninstall
+###
+task :uninstall_gem do
+ uninstaller = Gem::Uninstaller.new( PKG_NAME )
+ uninstaller.uninstall
+end
+task :uninstall => [ :uninstall_gem ]
+