* Rename 'markers' to 'token'

* Fix up the Rakefile's gem generation
* Add LICENSE
* Add a real README
This commit is contained in:
mahlon 2008-11-09 00:27:36 +00:00
parent f4051c5a35
commit 194fadda98
5 changed files with 183 additions and 138 deletions

View file

@ -7,19 +7,30 @@ require 'rubygems'
require 'pathname'
require 'rake'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'spec/rake/spectask'
require 'rubygems/installer'
require 'rubygems/uninstaller'
######################################################################
### P A T H S
### 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 )
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'
LIBDIR = BASEDIR + 'lib'
SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).reject {|f| f =~ /^\.svn/ }
LIBDIR = BASEDIR + 'lib'
LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb').reject {|i| i =~ /\.svn/ }
RELEASE_FILES = TEXT_FILES + LIB_FILES + SPEC_FILES
######################################################################
### H E L P E R S
######################################################################
@ -37,6 +48,7 @@ def find_pattern( file, pattern )
return ver.is_a?( String ) ? ver : 'UNKNOWN'
end
######################################################################
### P A C K A G E C O N S T A N T S
######################################################################
@ -44,31 +56,21 @@ end
PKG_NAME = 'chunker'
PKG_VERSION = find_pattern( LIBDIR + 'chunker.rb', /VERSION = ['"](\d\.\d(?:\/\d)?)['"]/ )
PKG_REVISION = find_pattern( LIBDIR + 'chunker.rb', /SVNRev = .+Rev: (\d+)/ )
PKG_VERSION = begin
ver = nil
File.open( LIBDIR + 'chunker.rb' ) do |f|
ver = f.each do |line|
break $1 if line =~ /VERSION = ['"](\d\.\d(?:\/\d)?)['"]/
end
end
ver.is_a?( String ) ? ver : 'UNKNOWN'
end
RELEASE_NAME = "REL #{PKG_VERSION}"
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}.#{PKG_REVISION}"
######################################################################
### T A S K S
######################################################################
task :default => [:test]
task :default => [ :test, :package ]
### Task: run rspec tests
###
desc "Run tests"
Spec::Rake::SpecTask.new('test') do |task|
task.spec_files = FileList['spec/**/*.rb']
task.spec_files = SPEC_FILES
task.spec_opts = %w{ -c -fs }
end
@ -85,118 +87,70 @@ end
### Task: Create gem from source
###
gem = Gem::Specification.new do |gem|
pkg_build = PKG_REVISION || 0
gem.summary = "A convenience library for parsing __END__ tokens consistently."
gem.name = PKG_NAME
gem.version = "%s.%s" % [ PKG_VERSION, pkg_build ]
gem.author = 'Mahlon E. Smith'
gem.email = 'mahlon@martini.nu'
gem.homepage = 'http://projects.martini.nu/ruby-modules/wiki/chunker'
gem.rubyforge_project = 'mahlon'
gem.has_rdoc = true
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 = <<-EOF
Ruby provides an automatic constant called DATA, which is an IO object
that references all text in the current file under an __END__ token.
I find it convenient to use the __END__ area to store all sorts of
stuff, rather than have to worry about distributing separate files.
The DATA constant is determined from whatever ruby believes $0 to be.
It doesn't work inside of other required libraries, so you'll see stuff
like this all the time:
END = File.open( __FILE__ ).read.split( /^__END__/, 2 ).last
It works, but it's more work than I want to do.
Chunker solves this by parsing __END__ tokens for you, and making it
available in the form of a 'DATA_END' constant. It installs this
constant into the class that includes Chunker, so you can use it again
and again, assuming you use a different file for each class.
It also automatically parses out other things that look like tokens, so
you can easily have multiple, distinct documents all embedded into the
__END__ block.
EOF
end
Rake::GemPackageTask.new( gem ) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
__END__
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.summary = "Ruby based make-like utility."
s.name = 'rake'
s.version = PKG_VERSION
s.requirements << 'none'
s.require_path = 'lib'
s.autorequire = 'rake'
s.files = PKG_FILES
s.description = <<EOF
Rake is a Make-like program implemented in Ruby. Tasks
and dependencies are specified in standard Ruby syntax.
EOF
end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
require 'rake/packagetask'
require 'rake/gempackagetask'
### Task: gem
gemspec = Gem::Specification.new do |gem|
pkg_build = get_svn_rev( BASEDIR ) || 0
gem.name = PKG_NAME
gem.version = "%s.%s" % [ PKG_VERSION, pkg_build ]
gem.summary = "ThingFish - A highly-accessable network datastore"
gem.description = "ThingFish is a network-accessable, searchable, extensible " +
"datastore. It can be used to store chunks of data on the " +
"network in an application-independent way, associate the chunks " +
"with other chunks through metadata, and then search for the chunk " +
"you need later and fetch it again, all through a REST API over HTTP."
gem.authors = "Michael Granger and Mahlon E. Smith"
gem.email = "mgranger@laika.com, mahlon@laika.com"
gem.homepage = "http://opensource.laika.com/wiki/ThingFish"
gem.rubyforge_project = 'laika'
gem.has_rdoc = true
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.executables = BIN_FILES .
collect {|f| f.relative_path_from(BINDIR).to_s }
gem.add_dependency( 'uuidtools', '>= 1.0.0' )
gem.add_dependency( 'pluginfactory', '>= 1.0.3' )
end
Rake::GemPackageTask.new( gemspec ) do |task|
task.gem_spec = gemspec
task.need_tar = false
task.need_tar_gz = true
task.need_tar_bz2 = true
task.need_zip = true
end
desc "Build the ThingFish gem and gems for all the standard plugins"
task :gems => [:gem] do
log "Building gems for plugins in: %s" % [PLUGINS.join(', ')]
PLUGINS.each do |plugindir|
log plugindir.basename
cp BASEDIR + 'LICENSE', plugindir
Dir.chdir( plugindir ) do
system 'rake', 'gem'
end
fail unless $?.success?
pkgdir = plugindir + 'pkg'
gems = Pathname.glob( pkgdir + '*.gem' )
cp gems, PKGDIR
end
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} )
###
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 => [:clean] do
uninstaller = Gem::Uninstaller.new( PKG_FILE_NAME )
###
task :uninstall_gem do
uninstaller = Gem::Uninstaller.new( PKG_NAME )
uninstaller.uninstall
end
task :uninstall => [ :uninstall_gem ]