lib/reap/task/publish.rb in reap-4.3.2 vs lib/reap/task/publish.rb in reap-4.3.3

- old
+ new

@@ -1,42 +1,68 @@ #!/usr/bin/env ruby require 'reap/task' +# ___ _ _ _ _ _____ _ +# | _ \_ _| |__| (_)__| |_ |_ _|_ _ __| |__ +# | _/ || | '_ \ | (_-< ' \ | |/ _` (_-< / / +# |_| \_,_|_.__/_|_/__/_||_| |_|\__,_/__/_\_\ # -# Publish Task -# + +# = Publish Task + class Reap::Publish < Reap::Task section_required true task_desc "Publish documents to the web." - attr_accessor :host, :type, :dir, :project, :username - attr_accessor :exclude # not using yet + task_help %{ + reap publish + + Publish documents to hosting service. + Currently only supports web publishing to Rubyforge. + Working on generalizing this more in future. + + dir Directory of files to publish. + exclude Files not to include from directory. + project Project name. + username Username for host. + + } + + #attr_accessor :host, :type, :dir, :project, :username + #attr_accessor :exclude # not using yet + + task_attr :pub + + # Setup the publishing task. + def init - @type ||= 'www' - @host ||= 'rubyforge.org' - @project ||= master['rubyforge']['project'] || master['name'] - @username ||= master['rubyforge']['username'] - @exclude ||= [] + pub.type ||= 'www' + pub.host ||= 'rubyforge.org' + pub.project ||= master.rubyforge.project || master.name + pub.username ||= master.rubyforge.username + pub.exclude ||= [] end + # Run the publishing task. + def run cmd = ''; skip = false - case @host + case pub.host when 'rubyforge', 'rubyforge.org' - case @type + case pub.type when 'www', 'web' - cmd = %{scp -r #{@dir}/* #{@username}@rubyforge.org:/var/www/gforge-projects/#{@project}/} + cmd = %{scp -r #{pub.dir}/* #{pub.username}@rubyforge.org:/var/www/gforge-projects/#{pub.project}/} else - puts %{Unrecognized publishing kind '#{@type}' for host '#{@host}'. Skipped.} + puts %{Unrecognized publishing kind '#{pub.type}' for host '#{pub.host}'. Skipped.} skip = true end else - puts %{Unrecognized publishing host '#{@host}'. Skipped.} + puts %{Unrecognized publishing host '#{pub.host}'. Skipped.} skip = true end unless skip puts "Reap is shelling out publishing work..."