Class: Reap::Publish

Inherits:
Task
  • Object
show all
Defined in:
lib/reap/task/publish.rb

Overview

Publish Task

Constant Summary

Constants inherited from Task

Task::RUBY

Instance Method Summary collapse

Methods inherited from Task

#ask, #execute, inherited, #initialize, #initiate, master, #master, #provide_setup_rb, #section, section_required, section_required?, #section_required?, #sh, #task, task_attr, #task_desc, task_desc, #task_help, task_help, task_list, #task_name, task_name, #tell, #use_subsection, verify?

Constructor Details

This class inherits a constructor from Reap::Task

Instance Method Details

#run(target = nil, copy_from = nil, copy_to = nil) ⇒ Object

Run the publishing task.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/reap/task/publish.rb', line 69

def run( target=nil, copy_from=nil, copy_to=nil )

  return nil if target and target != pub.target

  # setup

  pub.type     ||= 'web'
  pub.host     ||= 'rubyforge.org'
  pub.root     ||= 'var/www/gforge-projects/'
  pub.project  ||= master.rubyforge.project || master.name
  pub.username ||= master.rubyforge.username
  pub.copy     ||= [ "#{pub.dir}/*" ]

  if copy_from
    pub.copy = [ "#{copy_from} #{copy_to}".strip ]
  end

  # validate

  unless pub.project
    puts "Project not specified." ; return nil
  end

  unless pub.username
    puts "Username not specified." ; return nil
  end

  # publish

  puts "Reap is shelling out publishing work..."

  case pub.type

  when 'web', 'www'
    case pub.host
    when 'rubyforge', 'rubyforge.org'
      pub.host = "rubyforge.org"
      pub.root = "/var/www/gforge-projects/#{pub.project}"
      run_scp
    else
      puts %{Unrecognized publishing host '#{pub.host}'. Skipped.}
      return nil
    end

  when 'scp'
    run_scp

  when 'ftp'
    run_ftp

  else
    puts %{Unrecognized publishing type '#{pub.type}'. Skipped.}
    return nil
  end

end