#require 'rbconfig' #require 'reap/projectinfo' module Scaffold extend self SCMPaths => %w{ trunk branch tag scrap package } TrunkPaths = %w{ bin lib ext dev data test demo } TrunkFiles = %w{ README INSTALL COPYING ProjectInfo ChangeLog Todo RakeFile setup.rb } def go(name) ; scaffold(name) ; end # Main method. def scaffold(name=nil) name ||= 'yourlib.projectdomain.org' t = Time.now.strftime("%Y-%m-%d") libdir = File.join( 'lib', "#{@name},#{t}" ) if @scm SCMPaths.each { |d| makedir( d ) } Dir.chdir 'trunk' end TrunkPaths.each { |d| makedir( d ) } makedir_with_check( libdir ) TrunkFiles.each { |f| temlpate( f ) } end private # Copy a file from lib/data to the current dir. def template( filename ) dir = File.join(File.dirname(__FILE__), 'data' ) #dir = File.join( ::Config::CONFIG['datadir'], DATA_DIR ) f = File.join( dir, filename ) unless File.file?( f ) puts f raise "Tempfile is missing." end if File.exists?(filename) puts "#{filename} already exists." return end # copy tmpf to Reapfile FileUtils.cp( f, filename ) #puts "#{filename} created. You'll need to fill it out." end # Make a directory as long as it doesn't already exist. def makedir( dir ) FileUtils.makedir_p( dir ) unless File.directory?( dir ) end end =begin def scaffold require 'reap/scaffold' name = domain = Scaffold.go( name, domain ) end def template( file_name = ProjectInfo ) #dir = File.dirname(File.dirname(__FILE__)) dir = File.join( ::Config::CONFIG['datadir'], DATA_DIR ) tmpf = File.join( dir, 'template.yaml' ) unless File.file?( tmpf ) puts tmpf raise "Tempfile is missing." end if File.directory?(filename) puts "#{filename} a directory. Cannot comply." return elsif File.file?(filename) puts "#{filename} already exists." return end # copy tmpf to Reapfile FileUtils.cp( tmpf, filename ) puts "#{filename} created. You'll need to fill it out." end =end