1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#!/usr/bin/env ruby
# publish website to rubyforge
#
# This task publishes the source dir (deafult 'doc')
# to a rubyforge website.
def publish
username = ENV['RUBYFORGE_USERNAME']
location = 'facets'
abort "RUBYFORGE_USERNAME environment variable required" unless username
cmd = "rsync -rLvz --delete-after --filter='dir-merge doc/.rsync-filter' doc/ #{username}@rubyforge.org:/var/www/gforge-projects/#{location}"
if ARGV.include?('--dryrun')
puts cmd
else
system cmd
end
end
# Go!
if $0 == __FILE__
publish
end
__END__
# PUBLISH_PROJECT = 'facets'
#
# main :publish do
# config = configuration['publish']
#
# project = config['project']
# subdir = config['subdir']
# source = config['source'] || "doc"
# username = config['username'] || ENV['RUBYFORGE_USERNAME']
# clear = config['clear']
#
# if clear
# protect = config['protect'].to_a
# exclude = config['exclude'].to_a
# else
# protect = %w{usage statcvs statsvn robot.txt wiki} + config['protect'].to_a
# exclude = %w{.svn} + config['exclude'].to_a
# end
#
# abort "no project" unless project
# abort "no username" unless username
#
# if subdir
# destination = File.join(project, subdir)
# else
# destination = project
# end
#
# dir = source.chomp('/') + '/'
# url = "#{username}@rubyforge.org:/var/www/gforge-projects/#{destination}"
#
# op = ['-rLvz', '--delete-after'] # maybe -p ?
#
# # Using commandline filter options didn't seem
# # to work, so I opted for creating an .rsync_filter file for
# # all cases.
#
# unless protect.empty? && exclude.empty?
# rsync_file = File.join(source,'.rsync-filter')
# unless file?(rsync_file)
# File.open(rsync_file, 'w') do |f|
# exclude.each{|e| f << "- #{e}\n"}
# protect.each{|e| f << "P #{e}\n"}
# end
# end
# op << "--filter='dir-merge #{rsync_file}'"
# end
#
# args = op + [dir, url]
#
# rsync(*args.to_params)
# end
|