require 'reap/task' require 'facet/gem/self/gempath' class Reap::Template < Reap::Task task_desc "Create a ProjectInfo template." task_help %{ reap template Creates an empty PrjectInfo file in the current directory. It will not overwrite a PrjectInfo file if one is already present. } task_available { ! Reap.projectfile? } # Copies the file from lib/data to the current dir. def run f = nil if ::ProjectInfo::INFO_FILES.any?{ |f| File.exists?(f) } puts "Project file '#{f}' already exists." return end filename = 'ProjectInfo' # if using gems if dir = Gem.gempath('reap') dir = File.join( dir, 'data', 'reap', 'scaffold', 'standard' ) else dir = File.join( ::Config::CONFIG['datadir'], 'reap', 'scaffold', 'standard' ) end f = File.join( dir, filename ) raise "ProjectInfo template file #{f} is missing." unless File.file?( f ) # copy FileUtils.install( f, '.' ) tell "#{filename} created. You'll need to fill it out." return nil end end