Commits

Michael Granger  committed a442044

Updated tests for RSpec2; updated build system.

  • Participants
  • Parent commits adb6098

Comments (0)

Files changed (6)

-Copyright (c) 2009 Michael Granger
+Copyright (c) 2009-2010 Michael Granger
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
-#!rake
+#!rake -*- ruby -*-
 #
 # RoninShell rakefile
 #
 # Based on various other Rakefiles, especially one by Ben Bleything
 #
-# Copyright (c) 2007-2009 The FaerieMUD Consortium
+# Copyright (c) 2007-2010 The FaerieMUD Consortium
 #
 # Authors:
 #  * Michael Granger <ged@FaerieMUD.org>
 #
 
 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 )
 }
 	end
 end
 
+begin
+	require 'rubygems'
+rescue LoadError
+	module Gem
+		class Specification; end
+	end
+end
+
+require 'pathname'
 require 'rbconfig'
 require 'rake'
 require 'rake/testtask'
 	PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] + '.' + buildrev
 elsif VERSION_FILE.exist?
 	PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ]
-else
-	PKG_VERSION = '0.0.0'
 end
 
+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}" )
 
 RELEASE_FILES << LOCAL_RAKEFILE.to_s if LOCAL_RAKEFILE.exist?
 
+RELEASE_ANNOUNCE_ADDRESSES = [
+	"Ruby-Talk List <ruby-talk@ruby-lang.org>",
+]
+
 COVERAGE_MINIMUM = ENV['COVERAGE_MINIMUM'] ? Float( ENV['COVERAGE_MINIMUM'] ) : 85.0
 RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib'
 RCOV_OPTS = [
 
 	if ans =~ /^y/i
 		$stderr.puts "Okay, fetching #{RAKE_TASKLIBS_URL} into #{RAKE_TASKDIR}..."
-		system 'hg', 'clone', RAKE_TASKLIBS_URL, RAKE_TASKDIR
+		system 'hg', 'clone', RAKE_TASKLIBS_URL, "./#{RAKE_TASKDIR}"
 		if ! $?.success?
 			fail "Damn. That didn't work. Giving up; maybe try manually fetching?"
 		end
 end
 
 require RAKE_TASKDIR + 'helpers.rb'
+include RakefileHelpers
 
-# Define some constants that depend on the 'svn' tasklib
+# 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 = id.chomp[ /^[[:xdigit:]]+/ ]
+	id = `#{hg} id -n`.chomp
+	PKG_BUILD = (id.chomp[ /^[[:xdigit:]]+/ ] || '1')
 else
-	PKG_BUILD = 0
+	PKG_BUILD = '0'
 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://deveiate.org/roninsh.html/browser/'
+	'--tab-width=4',
+	'--show-hash',
+	'--include', BASEDIR.to_s,
+	"--main=#{README_FILE}",
+	"--title=#{PKG_NAME}",
+  ]
+YARD_OPTIONS = [
+	'--use-cache',
+	'--protected',
+	'-r', README_FILE,
+	'--exclude', 'extconf\\.rb',
+	'--files', 'ChangeLog,LICENSE',
+	'--output-dir', API_DOCSDIR.to_s,
+	'--title', "#{PKG_NAME} #{PKG_VERSION}",
   ]
 
 # Release constants
-SMTP_HOST = 'mail.faeriemud.org'
+SMTP_HOST = "mail.faeriemud.org"
 SMTP_PORT = 465 # SMTP + SSL
 
 # Project constants
 PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
 PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
 
-# Rubyforge stuff
-RUBYFORGE_GROUP = 'deveiate'
-RUBYFORGE_PROJECT = 'roninsh'
+GEM_PUBHOST = 'rubygems.org'
 
 # Gem dependencies: gemname => version
 DEPENDENCIES = {
+	'pluginfactory' => '>= 1.0.4',
 	'columnize' => '>= 0.3.1',
-	'pluginfactory' => '>= 1.0.4',
+	'genki-ruby-terminfo' => '>= 0.1.1',
 	'arika-ruby-termios' => '>= 0.9.6',
-	'genki-ruby-terminfo' => '>= 0.1.1',
 }
 
 # 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',
-	'rubyforge'   => '>= 0',
-	'termios'     => '>= 0',
-	'text-format' => '>= 1.0.0',
-	'tmail'       => '>= 1.2.3.1',
+	'rake'          => '~> 0.8.7',
+	'rcodetools'    => '~> 0.7.0.0',
+	'rcov'          => '~> 0.8.1.2.0',
+	'yard'          => '~> 0.6.1',
+	'RedCloth'      => '~> 4.2.3',
+	'rspec'         => '~> 2.0.1',
+	'ruby-termios'  => '~> 0.9.6',
+	'text-format'   => '~> 1.0.0',
+	'tmail'         => '~> 1.2.3.1',
 }
 
 # Non-gem requirements: packagename => version
 		"To fire up the shell, run 'roninsh'.",
 	  ].join( "\n" )
 
-	gem.authors           = "Michael Granger"
+	gem.authors           = ["Michael Granger"]
 	gem.email             = ["ged@FaerieMUD.org"]
 	gem.homepage          = 'http://deveiate.org/roninsh.html'
-	gem.rubyforge_project = RUBYFORGE_PROJECT
+	gem.licenses          = ["BSD"]
 
 	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')]
+
+
+	gem.required_ruby_version = '>= 1.9.2'
+
 	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
 
 ### Task: clean
-CLEAN.include 'coverage'
-CLOBBER.include 'artifacts', 'coverage.info', PKGDIR
+CLEAN.include 'coverage', '**/*.orig', '**/*.rej'
+CLOBBER.include 'artifacts', 'coverage.info', 'ChangeLog', PKGDIR
 
 ### Task: changelog
 file 'ChangeLog' do |task|
 --- 
-excluded_pkgfiles: []
-
-project_pubdir: /usr/local/www/public/code/
-project_pubhost: deveiate
+project_name: RoninShell
 project_homepage: http://deveiate.org/roninsh.html
-rubyforge_group: deveiate
-project_requirements: {}
-
+project_summary: An experimental object-oriented command shell.
 project_description: "This is an experimental object-oriented command shell, in the same vein as rush (http://rush.heroku.com/) or\n\
   Windows \"PowerShell\". "
+project_pubhost: deveiate
+project_pubdir: /usr/local/www/public/code/
+project_licenses: 
+- BSD
+gem_pubhost: rubygems.org
+release_mailto: Ruby-Talk List <ruby-talk@ruby-lang.org>
+release_smtphost: mail.faeriemud.org
+post_install_message: To fire up the shell, run 'roninsh'.
+authors: 
+  Michael Granger: ged@FaerieMUD.org
 project_dependencies: 
   pluginfactory: ">= 1.0.4"
   columnize: ">= 0.3.1"
   genki-ruby-terminfo: ">= 0.1.1"
   arika-ruby-termios: ">= 0.9.6"
-project_summary: An experimental object-oriented command shell.
-version_file: roninshell.rb
+dev_dependencies: {}
+
+project_requirements: {}
+
 additional_pkgfiles: []
 
-dev_dependencies: {}
+excluded_pkgfiles: []
 
-authors: 
-  Michael Granger: ged@FaerieMUD.org
-post_install_message: To fire up the shell, run 'roninsh'.
-project_name: RoninShell
-rubyforge_project: roninsh
+required_ruby_version: ">= 1.9.2"
+version_file: roninshell.rb

File spec/lib/helpers.rb

 
 	libdir = basedir + "lib"
 
+	$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 )
 }
 
+require 'rspec'
+
+require 'spec/lib/constants'
+
 require 'roninshell'
-require 'spec/lib/constants'
 
 
 ### RSpec helper functions.
 end
 
 
+RSpec.configure do |config|
+	config.mock_with( :rspec )
+	config.include( RoninShell::SpecHelpers )
+end
+
 # vim: set nosta noet ts=4 sw=4:
 

File spec/roninshell/mixins_spec.rb

 	libdir = basedir + "lib"
 	extdir = basedir + "ext"
 
+	$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
-	$LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
 }
 
-require 'spec'
+require 'rspec'
+
 require 'spec/lib/constants'
 require 'spec/lib/helpers'
 
 require 'roninshell'
 require 'roninshell/mixins'
 
-include RoninShell::TestConstants
-include RoninShell::Constants
 
 #####################################################################
 ###	C O N T E X T S

File spec/roninshell_spec.rb

 	basedir = Pathname.new( __FILE__ ).dirname.parent
 
 	libdir = basedir + "lib"
+
+	$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
 	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
 }
 
-require 'spec'
+require 'rspec'
+
 require 'spec/lib/constants'
 require 'spec/lib/helpers'
 
 require 'roninshell'
 require 'roninshell/cli'
 
-include RoninShell::TestConstants
-include RoninShell::Constants
 
 #####################################################################
 ###	C O N T E X T S
 #####################################################################
 
 describe RoninShell do
-	include RoninShell::SpecHelpers
-
 
 	before( :all ) do
 		setup_logging( :debug )