task/publish in ratch-0.4.0 vs task/publish in ratch-0.4.1
- old
+ new
@@ -1,8 +1,8 @@
#!/usr/bin/env ratch
-# Publish website to rubyforge
+# publish website to rubyforge
#
# This task publishes the source dir (deafult 'doc')
# to a rubyforge website.
main :publish do
@@ -10,13 +10,20 @@
project = config['project']
subdir = config['subdir']
source = config['source'] || "doc"
username = config['username'] || ENV['RUBYFORGE_USERNAME']
- protect = %w{usage statcvs statsvn robot.txt wiki}
- exclude = %w{.svn}
+ 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)
@@ -25,27 +32,26 @@
end
dir = source.chomp('/') + '/'
url = "#{username}@rubyforge.org:/var/www/gforge-projects/#{destination}"
- op = ['-rLvz', '--delete'] # maybe -p ?
+ op = ['-rLvz', '--delete-after'] # maybe -p ?
- # add filter options. The commandline version didn't seem
+ # Using commandline filter options didn't seem
# to work, so I opted for creating an .rsync_filter file for
# all cases.
- filter_file = File.join(source,'.rsync-filter')
-
- unless file?(filter_file)
- File.open(filter_file, 'w') do |f|
- exclude.map{|e| f << "- #{e}\n"}
- protect.map{|e| f << "P #{e}\n"}
+ 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
- op << "--filter='dir-merge #{filter_file}' --delete-after"
-
args = op + [dir, url]
rsync(*args.to_params)
end
-