Commits

Michael Granger  committed cd52868

Require/space cleanup.

  • Participants
  • Parent commits 2c6e864

Comments (0)

Files changed (126)

-#!/usr/bin/ruby -*- ruby -*-
+#!/usr/bin/env ruby -*- ruby -*-
 
 BEGIN {
 	require 'pathname'
 #
 # Authors:
 #  * Michael Granger <ged@FaerieMUD.org>
-#  * Mahlon E. Smith <mahlon@martini.nu>
 #
 
 BEGIN {
+	require 'rbconfig'
 	require 'pathname'
 	basedir = Pathname.new( __FILE__ ).dirname
 
 	libdir = basedir + "lib"
-	extdir = basedir + "ext"
+	extdir = libdir + Config::CONFIG['sitearch']
 
+	$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
 	$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
 	$LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
 }
 	PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ]
 end
 
-PKG_VERSION ||= '0.0.0'
+PKG_VERSION = '0.0.0' unless defined?( PKG_VERSION ) && !PKG_VERSION.nil?
 
 PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
 GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
 
 ARTIFACTS_DIR = Pathname.new( CC_BUILD_ARTIFACTS )
 
-TEXT_FILES    = Rake::FileList.new( %w[Rakefile ChangeLog README LICENSE] )
+TEXT_FILES    = Rake::FileList.new( %w[Rakefile ChangeLog README* LICENSE] )
 BIN_FILES     = Rake::FileList.new( "#{BINDIR}/*" )
 LIB_FILES     = Rake::FileList.new( "#{LIBDIR}/**/*.rb" )
 EXT_FILES     = Rake::FileList.new( "#{EXTDIR}/**/*.{c,h,rb}" )
 end
 
 require RAKE_TASKDIR + 'helpers.rb'
+include RakefileHelpers
 
 # Set the build ID if the mercurial executable is available
 if hg = which( 'hg' )
-	id = IO.read('|-') or exec hg.to_s, 'id', '-n'
-	PKG_BUILD = 'pre' + (id.chomp[ /^[[:xdigit:]]+/ ] || '1')
+	id = `#{hg} id -n`.chomp
+	PKG_BUILD = "pre%03d" % [(id.chomp[ /^[[:xdigit:]]+/ ] || '1')]
 else
-	PKG_BUILD = 'pre0'
+	PKG_BUILD = 'pre000'
 end
 SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}"
 SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
 
 # Documentation constants
-RDOCDIR = DOCSDIR + 'api'
+API_DOCSDIR = DOCSDIR + 'api'
+README_FILE = TEXT_FILES.find {|path| path =~ /^README/ } || 'README'
 RDOC_OPTIONS = [
-	'-w', '4',
-	'-HN',
-	'-i', '.',
-	'-m', 'README',
-	'-t', PKG_NAME,
-	'-W', 'http://bitbucket.org/laika/thingfish/browser/'
+	'--tab-width=4',
+	'--show-hash',
+	'--include', BASEDIR.to_s,
+	"--main=#{README_FILE}",
+	"--title=#{PKG_NAME}",
+  ]
+YARD_OPTIONS = [
+	'--use-cache',
+	'--no-private',
+	'--protected',
+	'-r', README_FILE,
+	'--exclude', 'extconf\\.rb',
+	'--files', 'ChangeLog,LICENSE',
+	'--output-dir', API_DOCSDIR.to_s,
+	'--title', "#{PKG_NAME} #{PKG_VERSION}",
   ]
 
 # Release constants
 SMTP_PORT = 465 # SMTP + SSL
 
 # Project constants
-PROJECT_HOST = 'opensource.laika.com'
-PROJECT_PUBDIR = '/usr/local/laika/www/public/thingfish/'
+PROJECT_HOST = 'deveiate.org'
+PROJECT_PUBDIR = '/usr/local/www/public/code/'
 PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
 PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
 PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
 
+GEM_PUBHOST = 'rubygems.org'
+
 # Gem dependencies: gemname => version
 DEPENDENCIES = {
 	'pluginfactory' => '>=1.0.4',
 
 # Developer Gem dependencies: gemname => version
 DEVELOPMENT_DEPENDENCIES = {
-	'rake'        => '>= 0.8.7',
-	'rcodetools'  => '>= 0.7.0.0',
-	'rcov'        => '>= 0.8.1.2.0',
-	'rdoc'        => '>= 2.4.3',
-	'RedCloth'    => '>= 4.0.3',
-	'rspec'       => '>= 1.2.6',
-	'termios'     => '>= 0',
-	'text-format' => '>= 1.0.0',
-	'tmail'       => '>= 1.2.3.1',
-	'diff-lcs'    => '>= 1.1.2',
+	'rake'         => '>= 0.8.7',
+	'rcodetools'   => '>= 0.7.0.0',
+	'rcov'         => '>= 0.8.1.2.0',
+	'rdoc'         => '>= 2.4.3',
+	'RedCloth'     => '>= 4.0.3',
+	'rspec'        => '>= 1.2.6',
+	'ruby-termios' => '>= 0.9.6',
+	'text-format'  => '>= 1.0.0',
+	'tmail'        => '>= 1.2.3.1',
+	'diff-lcs'     => '>= 1.1.2',
 	'tidy' => '>=0',
 	'sqlite3-ruby' => '>= 1.2.4',
 	'ruby-mp3info' => '>=0',
 
 	gem.has_rdoc          = true
 	gem.rdoc_options      = RDOC_OPTIONS
-	gem.extra_rdoc_files  = %w[ChangeLog README LICENSE]
+	gem.extra_rdoc_files  = TEXT_FILES - [ 'Rakefile' ]
 
 	gem.bindir            = BINDIR.relative_path_from(BASEDIR).to_s
 	gem.executables       = BIN_FILES.select {|pn| File.executable?(pn) }.
 	gem.files             = RELEASE_FILES
 	gem.test_files        = SPEC_FILES
 
+	# signing key and certificate chain
+	gem.signing_key       = '/Volumes/Keys/ged-private_gem_key.pem'
+	gem.cert_chain        = [File.expand_path('~/.gem/ged-public_gem_cert.pem')]
+
 	DEPENDENCIES.each do |name, version|
 		version = '>= 0' if version.length.zero?
 		gem.add_runtime_dependency( name, version )
 #####################################################################
 
 ### Default task
-task :default  => [:clean, :local, :spec, :rdoc, :package]
+task :default  => [:clean, :local, :spec, :apidocs, :package]
 
 ### Task the local Rakefile can append to -- no-op by default
 task :local

File Rakefile.old

 }
 
 
-require 'rubygems'
-
 require 'rake'
 require 'tmpdir'
 require 'pathname'

File bin/ml_archiver.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
+
+require 'optparse'
+require 'ostruct'
+require 'tmail'
+require 'thingfish/client'
+require 'thingfish/resource'
+
 # 
-# Check the specified MAILDIR for new messages, delivering each to the given instance of ThingFish if any are found.
+# Check the specified MAILDIR for new messages, delivering each to the 
+# given instance of ThingFish if any are found.
 # 
 # == Synopsis
 #
 #   $ ml_archiver.rb OPTIONS MAILDIR [THINGFISH_HOST]
 # 
+class DefaultArchiver
 
-BEGIN {
-	require 'pathname'
-	
-	basedir = Pathname.new( __FILE__ ).dirname.parent
-	libdir = basedir + 'lib'
-
-	$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
-}
-
-begin
-	require 'optparse'
-	require 'ostruct'
-	require 'tmail'
-	require 'thingfish/client'
-	require 'thingfish/resource'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
-
-
-class DefaultArchiver
-	
 	@available_archivers = [ self ]
 	class << self
 		attr_reader :available_archivers
 	end
-	
-	
+
+
 	### When inherited, register the new subclass as an available archiver.
 	def self::inherited( klass )
 		@available_archivers << klass
 		super
 	end
-	
-	
+
+
 	### Return a list of human-friendly archiver names with the word "archiver"
 	### stripped off and the remainder downcased.
 	def self::archiver_names
 		available_archivers.map {|klass| klass.name.sub( /Archiver$/, '' ).downcase }
 	end
-	
-	
+
+
 	### Given a human-friendly archiver name, return the corresponding class
 	### object
 	def self::get_archiver( name )
 
 		raise "Ambiguous archiver name '#{name}'; found: #{archiver.inspect}" if
 			archiver.size > 1
-			
+
 		raise "No archiver found to match '#{name}'" if archiver.empty?
 
 		return archiver.first
 
 			oparser.separator ''
 			oparser.separator "Runtime options"
-			
+
 			oparser.on( '-v', '--verbose', FalseClass, "Turn verbose output on" ) do
 				options.verbose = true
 			end
-			
+
 			oparser.on( '-d', '--debug', FalseClass, "Turn debugging output on" ) do
 				options.debugging = true
 			end
-				
+
 			oparser.on( '-n', '--dry-run', FalseClass, "Don't actually upload anything, ",
 				"just show what would be done." ) do
 				options.dryrun = true
 			oparser.on( '-k', '--keep-going', FalseClass, "Keep going after an upload error." ) do
 				options.keepgoing = true
 			end
-			
+
 			oparser.on( '-a', '--archiver=STRING', String,
 				"Select which archiver to use.",
 				"Available archivers: ",
 		options.dryrun		= false
 		options.keepgoing	= false
 		options.archiver    = 'default'
-		
+
 		return options
 	end
 
 		# For each new mail
 		maildir.each_port do |port|
 			debug_msg "processing port in file #{port.filename}"
-			
+
 			if port.seen?
 				verbose_msg "skipping seen port"
 				next
 
 		debug_msg "Uploaded as %s" % [ resource.uuid ]
 	end
-	
-	
+
+
 	### Given a mailing list message, parse out the name of the mailing list
 	### that it was sent to
 	def parse_list_name( message )
 		$stderr.puts( msg.chomp )
 		$stderr.flush
 	end
-		
+
 
 	### Output +msg+ to STDERR and flush it if $VERBOSE is true.
 	def verbose_msg( msg )

File bin/ml_unarchiver.rb

-#!/usr/bin/ruby
-# 
-# Copy the email out of the given
-# 
-# == Synopsis
-#
-#   $ ml_unarchiver.rb maildir [message_files]
-# 
-
-require 'rubygems'
-require 'tmail'
-require 'pathname'
-
-maildir_path = ARGV.shift or
-	raise "first argument must be a Maildir"
-
-maildir = TMail::Maildir.new( maildir_path )
-
-
-ARGV.collect {|fn| Pathname.new(fn) }.each do |file|
-	$stderr.puts "Copying %s" % [ file ]
-	maildir.new_port do |fh|
-		fh.write( file.read )
-	end
-end
-
-	

File data/thingfish/plugin_templates/spec/lib/filestore_behavior.rb

 BEGIN {
 	require 'pathname'
 	basedir = Pathname.new( __FILE__ ).dirname.parent
-	
+
 	libdir = basedir + "lib"
-	
+
+	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 }
 
-begin
-	require 'spec'
-	require 'spec/lib/constants'
-	require 'spec/lib/helpers'
-	require 'thingfish'
-	require 'thingfish/constants'
-	require 'thingfish/filestore'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
+require 'spec'
+require 'spec/lib/constants'
+require 'spec/lib/helpers'
+
+require 'thingfish'
+require 'thingfish/constants'
+require 'thingfish/filestore'
 
 
 describe "A FileStore", :shared => true do
 	it "silently ignores deletes of non-existant keys" do
 		@fs.delete( 'porksausage' ).should be_false
 	end
-	
+
 	it "returns false when checking has_file? for a file it does not have" do
 		@fs.has_file?( TEST_UUID ).should be_false
 	end
 		@fs.size( TEST_UUID ).should == TEST_RESOURCE_CONTENT.length
 		@fs.size( TEST_UUID_OBJ ).should == TEST_RESOURCE_CONTENT.length
 	end
-	
+
 	it "returns nil when asked for the size of a resource it doesn't contain" do
 		@fs.size( TEST_UUID ).should == nil
 	end

File data/thingfish/plugin_templates/spec/lib/filter_behavior.rb

 BEGIN {
 	require 'pathname'
 	basedir = Pathname.new( __FILE__ ).dirname.parent
-	
+
 	libdir = basedir + "lib"
-	
+
+	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 }
 
-begin
-	require 'spec'
-	require 'spec/lib/constants'
-	require 'spec/lib/helpers'
-	require 'thingfish'
-	require 'thingfish/constants'
-	require 'thingfish/filter'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
+require 'spec'
+require 'spec/lib/constants'
+require 'spec/lib/helpers'
+
+require 'thingfish'
+require 'thingfish/constants'
+require 'thingfish/filter'
 
 
 describe "A Filter", :shared => true do
 	it "knows what its plugin name is" do
 		@filter.class.plugin_name.should be_an_instance_of( String )
 	end
-	
-	
+
+
 end
 

File data/thingfish/plugin_templates/spec/lib/handler_behavior.rb

 BEGIN {
 	require 'pathname'
 	basedir = Pathname.new( __FILE__ ).dirname.parent.parent
-	
+
 	libdir = basedir + "lib"
-	
+
+	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 }
 
-begin
-	require 'spec'
-	require 'spec/lib/constants'
-	require 'spec/lib/helpers'
-	require 'thingfish'
-	require 'thingfish/constants'
-	require 'thingfish/handler'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
+require 'spec'
+require 'spec/lib/constants'
+require 'spec/lib/helpers'
+
+require 'thingfish'
+require 'thingfish/constants'
+require 'thingfish/handler'
 
 
 describe "A Handler", :shared => true do

File data/thingfish/plugin_templates/spec/lib/helpers.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 # coding: utf-8
 
-begin
-	require 'thingfish'
-	require 'thingfish/constants'
-	require 'thingfish/utils'
-	
-	require 'digest/md5'
-	require 'net/http'
-	require 'net/protocol'
+require 'spec/lib/constants'
 
-	require 'spec/lib/constants'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
+require 'digest/md5'
+require 'net/http'
+require 'net/protocol'
+
+require 'thingfish'
+require 'thingfish/constants'
+require 'thingfish/utils'
+
 
 include ThingFish::TestConstants
 include ThingFish::Constants
 		end
 		return response
 	end
-	
-	
+
+
 	### Return the correct Net::HTTPResponse class for the given +code+ (because it's
 	### private in Net::HTTPResponse itself)
 	def response_class_for_httpcode( code )
 		Net::HTTPResponse::CODE_CLASS_TO_OBJ[code[0,1]] or
 		HTTPUnknownResponse
 	end
-	
-	
+
+
 	### Return a Net::HTTPSuccess object with empty contents, as if from a HEAD 
 	### request.
 	def with_fixtured_http_head_response
 		end
 		return response
 	end
-	
+
 	### Create a temporary working directory and return
 	### a Pathname object for it.
 	###
 		  ]
 		tempdir = Pathname.new( Dir.tmpdir ) + dirname
 		tempdir.mkpath
-		
+
 		return tempdir
 	end
-	
+
 
 	### Reset the logging subsystem to its default state.
 	def reset_logging
 		ThingFish.reset_logger
 	end
-	
-	
+
+
 	### Alter the output of the default log formatter to be pretty in SpecMate output
 	def setup_logging( level=Logger::FATAL )
 
 		if ThingFish::Loggable::LEVEL.key?( level )
 			level = ThingFish::Loggable::LEVEL[ level ]
 		end
-		
+
 		logger = Logger.new( $stderr )
 		ThingFish.logger = logger
 		ThingFish.logger.level = level
 			ThingFish.logger.formatter = ThingFish::HtmlLogFormatter.new( logger )
 		end
 	end
-	
+
 end
 
 # Override the badly-formatted output of the RSpec HTML formatter
 class Spec::Runner::Formatter::HtmlFormatter
 	def example_failed( example, counter, failure )
 		failure_style = failure.pending_fixed? ? 'pending_fixed' : 'failed'
-		
+
 		unless @header_red
 			@output.puts "    <script type=\"text/javascript\">makeRed('rspec-header');</script>"
 			@header_red = true
 		end
-		
+
 		unless @example_group_red
 			css_class = 'example_group_%d' % [current_example_group_number || 0]
 			@output.puts "    <script type=\"text/javascript\">makeRed('#{css_class}');</script>"
 			@example_group_red = true
 		end
-		
+
 		move_progress()
-		
+
 		@output.puts "    <dd class=\"spec #{failure_style}\">",
 		             "      <span class=\"failed_spec_name\">#{h(example.description)}</span>",
 		             "      <div class=\"failure\" id=\"failure_#{counter}\">"
 		if failure.exception
 			backtrace = format_backtrace( failure.exception.backtrace )
 			message = failure.exception.message
-			
+
 			@output.puts "        <div class=\"message\"><code>#{h message}</code></div>",
 			             "        <div class=\"backtrace\"><pre>#{backtrace}</pre></div>"
 		end
 		if extra = extra_failure_content( failure )
 			@output.puts( extra )
 		end
-		
+
 		@output.puts "      </div>",
 		             "    </dd>"
 		@output.flush
 
 
 	alias_method :default_global_styles, :global_styles
-	
+
 	def global_styles
 		css = default_global_styles()
 		css << %Q{
 				color:  white;
 			}
 		}
-		
+
 		return css
 	end
 end

File data/thingfish/plugin_templates/spec/lib/metastore_behavior.rb

 
 	libdir = basedir + "lib"
 
+	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 }
 
-begin
-	require 'spec'
-	require 'spec/lib/constants'
-	require 'spec/lib/helpers'
-	require 'thingfish'
-	require 'thingfish/constants'
-	require 'thingfish/metastore'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
+require 'spec'
+require 'spec/lib/constants'
+require 'spec/lib/helpers'
+
+require 'thingfish'
+require 'thingfish/constants'
+require 'thingfish/metastore'
 
 
 describe "A MetaStore", :shared => true do

File data/thingfish/plugin_templates/spec/thingfish/filestore/TEMPLATE_spec.rb.erb

 	libdir = basedir + 'lib'
 
 	$LOAD_PATH.unshift( pluginlibdir ) unless $LOAD_PATH.include?( pluginlibdir )
+	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 }
 
-begin
-	require 'rbconfig'
+require 'spec'
+require 'spec/lib/constants'
+require 'spec/lib/helpers'
+require 'spec/lib/filestore_behavior'
 
-	require 'spec/runner'
-	require 'spec/lib/constants'
-	require 'spec/lib/helpers'
-	require 'spec/lib/filestore_behavior'
+require 'rbconfig'
 
-	require 'thingfish'
-	require 'thingfish/filestore'
-	require 'thingfish/filestore/<%= @name %>'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
-
+require 'thingfish'
+require 'thingfish/filestore'
+require 'thingfish/filestore/<%= @name %>'
 
 
 #####################################################################

File data/thingfish/plugin_templates/spec/thingfish/filter/TEMPLATE_spec.rb.erb

 	libdir = basedir + 'lib'
 
 	$LOAD_PATH.unshift( pluginlibdir ) unless $LOAD_PATH.include?( pluginlibdir )
+	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 }
 
-begin
-	require 'rbconfig'
+require 'spec'
+require 'spec/lib/constants'
+require 'spec/lib/helpers'
+require 'spec/lib/filter_behavior'
 
-	require 'spec/runner'
-	require 'spec/lib/constants'
-	require 'spec/lib/helpers'
-	require 'spec/lib/filter_behavior'
+require 'rbconfig'
 
-	require 'thingfish'
-	require 'thingfish/filter'
-	require 'thingfish/filter/<%= @name %>'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
-
+require 'thingfish'
+require 'thingfish/filter'
+require 'thingfish/filter/<%= @name %>'
 
 
 #####################################################################
 	before( :all ) do
 		setup_logging( :fatal )
 	end
-		
+
 	before( :each ) do
 		@<%= @type %> = ThingFish::<%= @type.capitalize %>.create( '<%= @name %>' )
 	end
 	after( :all ) do
 		reset_logging()
 	end
-	
+
 	### Shared behaviors
 	it_should_behave_like "A Filter"
-	
+
 	### Implementation-specific Examples
 	it "is well tested"
 

File data/thingfish/plugin_templates/spec/thingfish/handler/TEMPLATE_spec.rb.erb

 	libdir = basedir + 'lib'
 
 	$LOAD_PATH.unshift( pluginlibdir ) unless $LOAD_PATH.include?( pluginlibdir )
+	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 }
 
-begin
-	require 'pathname'
-	require 'stringio'
-	require 'spec/runner'
-	require 'spec/lib/constants'
-	require 'spec/lib/helpers'
-	require 'spec/lib/handler_behavior'
+require 'spec'
+require 'spec/lib/constants'
+require 'spec/lib/helpers'
+require 'spec/lib/handler_behavior'
 
-	require 'thingfish/constants'
-	require 'thingfish/handler/<%= @name %>'
-	require 'thingfish/exceptions'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
+require 'pathname'
+require 'stringio'
+
+require 'thingfish/constants'
+require 'thingfish/handler/<%= @name %>'
+require 'thingfish/exceptions'
+
 
 include ThingFish::Constants,
 		ThingFish::TestConstants,

File data/thingfish/plugin_templates/spec/thingfish/metastore/TEMPLATE_spec.rb.erb

 	libdir = basedir + 'lib'
 
 	$LOAD_PATH.unshift( pluginlibdir ) unless $LOAD_PATH.include?( pluginlibdir )
+	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 }
 
-begin
-	require 'pathname'
-	require 'spec/runner'
-	require 'spec/lib/constants'
-	require 'spec/lib/helpers'
-	require 'spec/lib/metastore_behavior'
-	
-	require 'thingfish/metastore/<%= @name %>'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
+require 'spec'
+require 'spec/lib/constants'
+require 'spec/lib/helpers'
+require 'spec/lib/metastore_behavior'
+
+require 'pathname'
+
+require 'thingfish/metastore/<%= @name %>'
 
 
 

File docs/manual/lib/api-filter.rb

-#!/usr/bin/ruby 
+#!/usr/bin/env ruby 
 # 
 # A manual filter to generate links from the Darkfish API.
 # 

File docs/manual/lib/editorial-filter.rb

-#!/usr/bin/ruby 
+#!/usr/bin/env ruby 
 # 
 # A manual filter to highlight content that needs editorial help.
 # 

File docs/manual/lib/examples-filter.rb

-#!/usr/bin/ruby 
+#!/usr/bin/env ruby 
 # 
 # A collection of standard filters for the manual generation tasklib.
 # 
 ### caption::
 ###   A small blurb to put below the pulled-out example in the HTML.
 class ExamplesFilter < Manual::Page::Filter
-	
+
 	DEFAULTS = {
 		:language     => :ruby,
 		:line_numbers => :inline,
 			)?
 		\?>
 	  }x
-	
+
 	EndPI = %r{ <\? end (?: \s+ example )? \s* \?> }x
 
 
 			raise
 		end
 	end
-	
-	
+
+
 	######
 	public
 	######
 	### Process the given +source+ for <?example ... ?> processing-instructions, calling out
 	def process( source, page, metadata )
 		scanner = StringScanner.new( source )
-		
+
 		buffer = ''
 		until scanner.eos?
 			startpos = scanner.pos
-			
+
 			# If we find an example
 			if scanner.skip_until( ExamplePI )
 				contents = ''
-				
+
 				# Append the interstitial content to the buffer
 				if ( scanner.pos - startpos > scanner.matched.length )
 					offset = scanner.pos - scanner.matched.length - 1
 				# Append everything up to it to the buffer and save the contents of
 				# the tag
 				params = scanner[1]
-				
+
 				# Now find the end of the example or complain
 				contentpos = scanner.pos
 				scanner.skip_until( EndPI ) or
 					raise "Unterminated example at line %d" % 
 						[ scanner.string[0..scanner.pos].count("\n") ]
-				
+
 				# Now build the example and append to the buffer
 				if ( scanner.pos - contentpos > scanner.matched.length )
 					offset = scanner.pos - scanner.matched.length - 1
 		end
 		buffer << scanner.rest
 		scanner.terminate
-		
+
 		return buffer
 	end
-	
-	
+
+
 	### Filter out 'example' macros, doing syntax highlighting, and running
 	### 'testable' examples through a validation process appropriate to the
 	### language the example is in.
 		caption = options.delete( :caption )
 		content = ''
 		lang = options.delete( :language ).to_s
-		
+
 		# Test it if it's testable
 		if options[:testable]
 			content = test_content( body, lang, page )
 		end
 		return DEFAULTS.merge( args )
 	end
-	
+
 
 	### Test the given +content+ with a rule specific to the given +language+.
 	def test_content( body, language, page )
 			return body
 		end
 	end
-	
-		
+
+
 	### Test the specified Ruby content for valid syntax
 	def test_ruby_content( source, page )
 		# $stderr.puts "Testing ruby content..."
 		return "%s while testing: %s\n  %s" %
 			[ err.class.name, err.message, err.backtrace.join("\n  ") ]
 	end
-	
-	
+
+
 	### Test the specified YAML content for valid syntax
 	def test_yaml_content( source, metadata )
 		YAML.load( source )
 	else
 		return source
 	end
-	
-	
+
+
 	### Highlights the given +content+ in language +lang+.
 	def highlight( content, options, lang )
 		source = ERB::Util.html_escape( content )
 		return %Q{\n\n<pre class="brush:#{lang}">#{source}</pre>\n\n}
 	end
-	
+
 end
 

File experiments/TEMPLATE.rb.tpl

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # #{vars[:description]}
 # 

File experiments/bench-uuid-parse.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # Benchmark UUIDTools' UUID parser vs. the one in the FilesystemFileStore plugin.
 # 
 	libdir = basedir + "lib"
 
 	$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
-	
+
 	Pathname.glob( basedir + 'plugins' + '*' + 'lib' ) do |pluginlib|
 		$LOAD_PATH.unshift( pluginlib.to_s )
 	end
 	include UtilityFunctions
 }
 
-
 require 'rubygems'
 require 'benchmark'
 require 'uuidtools'

File experiments/clientapi.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # Trying to figure out what the client API should do
 # 

File experiments/content-negotiation-spike.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # ThingFish HTTP Content-negotiation spike
 # 

File experiments/convert_to_8spec.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'fileutils'
 

File experiments/dc-rdf-model.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # Load the Dublin Core and the RDF namespace and schema into a model and drop into IRB
 # 

File experiments/net-https.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'net/https'
 

File experiments/rdf-classgen.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 # 
 # Spike to test out class and mixin generation from RDF specs/schemas
 #

File experiments/rdf-metastore-spike.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 # 
 # Spike to work out how the RDF metastore will work
 #

File lib/monkeypatches.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
+
+require 'thingfish/mixins'
+require 'thingfish/constants'
+
 #
-# This file
-# includes various necessary modifications to libraries we depend on. It pains us to
-# do it, but sometimes you just gotta patch the monkey.
+# This file includes various necessary modifications to libraries we
+# depend on. It pains us to do it, but sometimes you just gotta patch
+# the monkey.
 #
 # == Version
 #
 #
 #
 
-require 'thingfish/mixins'
-require 'thingfish/constants'
-
 ### Add HTML output to the core Object
 class Object
 	include ThingFish::HtmlInspectableObject

File lib/thingfish.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
+
+require 'logger'
+require 'pluginfactory'
+require 'uuidtools'
+
 #
 # Network-accessable searchable datastore
 #
 #---
 #
 # Please see the file LICENSE in the top-level directory for licensing details.
-
 #
-
-begin
-	require 'logger'
-	require 'pluginfactory'
-	require 'uuidtools'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
-
-
-
-### Toplevel namespace module
 module ThingFish
 
 	# VCS Revision

File lib/thingfish/acceptparam.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'thingfish'
 require 'thingfish/exceptions'

File lib/thingfish/client.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'net/http'
 require 'net/https'

File lib/thingfish/config.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
+
+require 'tmpdir'
+require 'pathname'
+require 'forwardable'
+require 'yaml'
+require 'logger'
+
+require 'thingfish'
+require 'thingfish/constants'
+require 'thingfish/mixins'
+require 'thingfish/utils'
+require 'thingfish/filter'
+require 'thingfish/filestore'
+require 'thingfish/metastore'
+require 'thingfish/urimap'
+
 #
 # The ThingFish config reader/writer class
 #
 #
 # Please see the file LICENSE in the top-level directory for licensing details.
 #
-
-require 'tmpdir'
-require 'pathname'
-require 'forwardable'
-require 'yaml'
-require 'logger'
-
-require 'thingfish'
-require 'thingfish/constants'
-require 'thingfish/mixins'
-require 'thingfish/utils'
-require 'thingfish/filter'
-require 'thingfish/filestore'
-require 'thingfish/metastore'
-require 'thingfish/urimap'
-
-
-### The configuration reader/writer class for ThingFish::Daemon.
 class ThingFish::Config
 	extend Forwardable
 
 		### Handle calls to key-methods
 		def method_missing( sym, *args )
 			key = sym.to_s.sub( /(=|\?)$/, '' ).to_sym
-			return nil unless sym.to_s =~ /=$/ || @hash.key?( key )
 
 			self.class.class_eval {
 				define_method( key ) {
-					if @hash[ key ].is_a?( Hash )
+					if !@hash[ key] || @hash[ key ].is_a?( Hash )
 						@hash[ key ] = ConfigStruct.new( @hash[key] )
 					end
 

File lib/thingfish/connectionmanager.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'thingfish'
 require 'thingfish/mixins'

File lib/thingfish/constants.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 # coding: utf-8
 
 require 'pathname'

File lib/thingfish/daemon.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'socket'
 require 'uuidtools'

File lib/thingfish/exceptions.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # A collection of exceptions for exceptional error handling.  har!
 #

File lib/thingfish/filestore.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # The abstract base filestore class for ThingFish
 #

File lib/thingfish/filestore/memory.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # An in-memory filestore plugin for ThingFish.
 #

File lib/thingfish/filter.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # The base filter type for ThingFish
 #

File lib/thingfish/filter/html.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # An HTML conversion filter for ThingFish
 #

File lib/thingfish/filter/ruby.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # A Marshalled Ruby object filter for ThingFish
 #

File lib/thingfish/filter/yaml.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # A YAML conversion filter for ThingFish
 #

File lib/thingfish/handler.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
+
+require 'pathname'
+require 'pluginfactory'
+
+require 'thingfish'
+require 'thingfish/mixins'
+require 'thingfish/constants'
+require 'thingfish/daemon'
+
+
 #
 # The base HTTP handler type for ThingFish
 #
 #
 # Please see the file LICENSE in the top-level directory for licensing details.
 #
-
-begin
-	require 'pathname'
-	require 'pluginfactory'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
-
-require 'thingfish'
-require 'thingfish/mixins'
-require 'thingfish/constants'
-require 'thingfish/daemon'
-
-
-### Base class for ThingFish Handler plugins
 class ThingFish::Handler
 	include PluginFactory,
 		ThingFish::Loggable,

File lib/thingfish/handler/simplemetadata.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
+
+require 'thingfish'
+require 'thingfish/metastore/simple'
+require 'thingfish/constants'
+require 'thingfish/handler'
+require 'thingfish/mixins'
+
 #
 # A metadata handler for the thingfish daemon. This handler provides
 # a REST interface to metadata information when the daemon is configured
 #---
 #
 # Please see the file LICENSE in the top-level directory for licensing details.
-
-begin
-	require 'thingfish'
-	require 'thingfish/metastore/simple'
-	require 'thingfish/constants'
-	require 'thingfish/handler'
-	require 'thingfish/mixins'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
-
-### The default metadata handler for the thingfish daemon when configured with
-### a ThingFish::SimpleMetaStore.
 class ThingFish::SimpleMetadataHandler < ThingFish::Handler
 	include ThingFish::Constants,
 		ThingFish::Constants::Patterns,

File lib/thingfish/handler/simplesearch.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # A search handler for the thingfish daemon. This handler provides a REST
 # interface to searching for resources which match criteria concerning their

File lib/thingfish/handler/staticcontent.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # The static resources handler -- serves static content from a directory. This is the
 # handler that's installed by the ThingFish::StaticResourcesHandler mixin ahead of

File lib/thingfish/metastore.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'pluginfactory'
 require 'thingfish'

File lib/thingfish/metastore/memory.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'thingfish/metastore/simple'
 require 'thingfish/constants'

File lib/thingfish/metastore/simple.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # A metastore that uses simple key/value pairs for ThingFish
 #

File lib/thingfish/mixins.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # A collection of mixins shared between ThingFish classes
 #

File lib/thingfish/request.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'uri'
 require 'forwardable'

File lib/thingfish/resource.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'thingfish'
 require 'thingfish/exceptions'

File lib/thingfish/response.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'thingfish'
 require 'thingfish/mixins'

File lib/thingfish/urimap.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # ThingFish::UriMap -- a map of the server's urispace which determines
 # which handlers are invoked for any URI.

File lib/thingfish/utils.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
+
+require 'forwardable'
+require 'logger'
+require 'erb'
+
+require 'thingfish'
+require 'thingfish/constants'
+require 'thingfish/mixins'
+
+
 #
 # A collection of little utility classes used elsewhere throughout the code
 #
 #---
 #
 # Please see the file LICENSE in the top-level directory for licensing details.
-
 #
-
-require 'forwardable'
-require 'logger'
-require 'erb'
-
-require 'thingfish'
-require 'thingfish/constants'
-require 'thingfish/mixins'
-
-
 module ThingFish # :nodoc:
 
 	### A case-insensitive multivalue hash that allows access via Symbol or String.
 BEGIN {
 	require 'pathname'
 	basedir = Pathname.new( __FILE__ ).expand_path.dirname
-	
+
 	libdir = basedir + 'lib'
 	pluginsdir = basedir + 'plugins'
-	pluginlibs = Pathname.glob( pluginsdir + '*/lib' )
-	
+	pluginlibs = Pathname.glob( (pluginsdir + '*/lib').to_s )
+
 	$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
 	pluginlibs.each do |dir|
 		$LOAD_PATH.unshift( dir.to_s ) unless $LOAD_PATH.include?( dir.to_s )

File plugins/thingfish-filestore-filesystem/lib/thingfish/filestore/filesystem.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 
 require 'tmpdir'
 require 'pathname'

File plugins/thingfish-filestore-filesystem/spec/thingfish/filestore/filesystem_spec.rb

 	libdir = basedir + "lib"
 	pluglibdir = plugindir + "lib"
 
+	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 	$LOAD_PATH.unshift( pluglibdir ) unless $LOAD_PATH.include?( pluglibdir )
 }
 
-begin
-	require 'pathname'
-	require 'tmpdir'
-	require 'thingfish/filestore/filesystem'
-	require 'spec'
-	require 'spec/lib/constants'
-	require 'spec/lib/helpers'
-	require 'spec/lib/filestore_behavior'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
+require 'spec'
+require 'spec/lib/constants'
+require 'spec/lib/helpers'
+require 'spec/lib/filestore_behavior'
+
+require 'pathname'
+require 'tmpdir'
+require 'thingfish/filestore/filesystem'
+
 
 #####################################################################
 ###	C O N T E X T S

File plugins/thingfish-filter-basicauth/lib/thingfish/filter/basicauth.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
+
+require 'thingfish'
+require 'thingfish/mixins'
+require 'thingfish/constants'
+require 'thingfish/acceptparam'
+require 'thingfish/filter'
+
 #
 # A basicauth filter for ThingFish
 #
 #---
 #
 # Please see the file LICENSE in the top-level directory for licensing details.
-
 #
-
-begin
-	require 'thingfish'
-	require 'thingfish/mixins'
-	require 'thingfish/constants'
-	require 'thingfish/acceptparam'
-	require 'thingfish/filter'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
-
-
-### A basicauth filter for ThingFish
 class ThingFish::BasicAuthFilter < ThingFish::Filter
 	include ThingFish::Loggable,
 		ThingFish::Constants

File plugins/thingfish-filter-basicauth/spec/thingfish/filter/basicauth_spec.rb

 	libdir = basedir + 'lib'
 
 	$LOAD_PATH.unshift( pluginlibdir ) unless $LOAD_PATH.include?( pluginlibdir )
+	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 }
 
-begin
-	require 'rbconfig'
+require 'spec'
+require 'spec/lib/constants'
+require 'spec/lib/helpers'
+require 'spec/lib/filter_behavior'
 
-	require 'spec'
-	require 'spec/lib/constants'
-	require 'spec/lib/helpers'
-	require 'spec/lib/filter_behavior'
+require 'rbconfig'
 
-	require 'thingfish'
-	require 'thingfish/filter'
-	require 'thingfish/filter/basicauth'
-rescue LoadError
-	unless Object.const_defined?( :Gem )
-		require 'rubygems'
-		retry
-	end
-	raise
-end
-
+require 'thingfish'
+require 'thingfish/filter'
+require 'thingfish/filter/basicauth'
 
 
 #####################################################################

File plugins/thingfish-filter-exif/lib/thingfish/filter/exif.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
 #
 # An EXIF metadata-extraction filter for ThingFish, using ruby's exifr module.
 # http://exifr.rubyforge.org/

File plugins/thingfish-filter-exif/spec/thingfish/filter/exif_spec.rb

 	libdir = basedir + "lib"
 	pluglibdir = plugindir + "lib"
 
+	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 	$LOAD_PATH.unshift( pluglibdir ) unless $LOAD_PATH.include?( pluglibdir )
 }
 
 require 'pathname'
 require 'tmpdir'
-require 'spec/runner'
+require 'spec'
 require 'spec/lib/constants'
 require 'spec/lib/helpers'
 require 'spec/lib/filter_behavior'

File plugins/thingfish-filter-image/lib/thingfish/filter/image.rb

-#!/usr/bin/ruby
+#!/usr/bin/env ruby
+
+require 'RMagick'
+
+require 'thingfish'
+require 'thingfish/mixins'
+require 'thingfish/constants'
+require 'thingfish/acceptparam'
+
 #
 # An image conversion/extraction filter for ThingFish
 #