Hoe::Publish

Publish plugin for hoe.

Tasks Provided:

announce

Create news email file and post to rubyforge.

debug_email

Generate email announcement file.

post_blog

Post announcement to blog.

post_news

Post announcement to rubyforge.

publish_docs

Publish RDoc to RubyForge.

ridocs

Generate ri locally for testing.

Extra Configuration Options:

publish_on_announce

Run publish_docs when you run release.

blogs

An array of hashes of blog settings.

Attributes

blog_categories[RW]

Optional: An array of the project’s blog categories. Defaults to project name.

local_rdoc_dir[RW]

Optional: Name of destination directory for RDoc generated files.

need_rdoc[RW]

Optional: Should RDoc and ri generation tasks be defined? [default: true]

Allows you to define custom RDoc tasks then use the publish_rdoc task to upload them all. See also local_rdoc_dir

rdoc_locations[RW]

Optional: An array of remote (rsync) paths to copy rdoc to.

eg:

    rdoc_locations << "user@server:Sites/rdoc/#{remote_rdoc_dir}"
remote_rdoc_dir[RW]

Optional: Name of RDoc destination directory on Rubyforge. [default: name]

rsync_args[RW]

Optional: Flags for RDoc rsync. [default: “-av —delete”]

Public Instance Methods

define_publish_tasks() click to toggle source

Define tasks for plugin.

     # File lib/hoe/publish.rb, line 97
 97:   def define_publish_tasks
 98:     if need_rdoc then
 99:       Rake::RDocTask.new(:docs) do |rd|
100:         rd.main = readme_file
101:         rd.options << '-d' if (`which dot` =~ /\/dot/) unless
102:           ENV['NODOT'] || Hoe::WINDOZE
103:         rd.rdoc_dir = 'doc'
104: 
105:         rd.rdoc_files += spec.require_paths
106:         rd.rdoc_files += spec.extra_rdoc_files
107: 
108:         title = spec.rdoc_options.grep(/^(-t|--title)=?$/).first
109: 
110:         if title then
111:           rd.options << title
112: 
113:           unless title =~ /\=/ then # for ['-t', 'title here']
114:             title_index = spec.rdoc_options.index(title)
115:             rd.options << spec.rdoc_options[title_index + 1]
116:           end
117:         else
118:           title = "#{name}-#{version} Documentation"
119:           title = "#{rubyforge_name}'s " + title if rubyforge_name != name
120:           rd.options << '--title' << title
121:         end
122:       end
123: 
124:       desc 'Generate ri locally for testing.'
125:       task :ridocs => :clean do
126:         sh %{ rdoc --ri -o ri . }
127:       end
128:     end
129: 
130:     desc "Publish RDoc to wherever you want."
131:     task :publish_docs => [:clean, :docs] do
132:       warn "no rdoc_location values" if rdoc_locations.empty?
133:       self.rdoc_locations.each do |dest|
134:         sh %{rsync #{rsync_args} #{local_rdoc_dir}/ #{dest}}
135:       end
136:     end
137: 
138:     # no doco for this one
139:     task :publish_on_announce do
140:       with_config do |config, _|
141:         Rake::Task['publish_docs'].invoke if config["publish_on_announce"]
142:       end
143:     end
144: 
145:     desc 'Generate email announcement file.'
146:     task :debug_email do
147:       puts generate_email
148:     end
149: 
150:     desc 'Post announcement to blog.'
151:     task :post_blog do
152:       require 'xmlrpc/client'
153: 
154:       with_config do |config, path|
155:         break unless config['blogs']
156: 
157:         subject, title, body, urls = announcement
158:         body += "\n\n#{urls}"
159: 
160:         config['blogs'].each do |site|
161:           server = XMLRPC::Client.new2(site['url'])
162:           content = site['extra_headers'].merge(:title => title,
163:                                                 :description => body,
164:                                                 :categories => blog_categories)
165: 
166:           result = server.call('metaWeblog.newPost',
167:                                site['blog_id'],
168:                                site['user'],
169:                                site['password'],
170:                                content,
171:                                true)
172:         end
173:       end
174:     end
175: 
176:     desc 'Post announcement to rubyforge.'
177:     task :post_news do
178:       require 'rubyforge'
179:       subject, title, body, urls = announcement
180: 
181:       rf = RubyForge.new.configure
182:       rf.login
183:       rf.post_news(rubyforge_name, subject, "#{title}\n\n#{body}")
184:       puts "Posted to rubyforge"
185:     end
186: 
187:     desc 'Announce your release.'
188:     task :announce => [:post_blog, :publish_on_announce ]
189:   end
generate_email(full = nil) click to toggle source
     # File lib/hoe/publish.rb, line 191
191:   def generate_email full = nil
192:     require 'time'
193: 
194:     abort "No email 'to' entry. Run `rake config_hoe` to fix." unless
195:       !full || email_to
196: 
197:     from_name, from_email      = author.first, email.first
198:     subject, title, body, urls = announcement
199: 
200:     [
201:      full && "From: #{from_name} <#{from_email}>",
202:      full && "To: #{email_to.join(", ")}",
203:      full && "Date: #{Time.now.rfc2822}",
204:      "Subject: [ANN] #{subject}",
205:      "", title,
206:      "", urls,
207:      "", body,
208:     ].compact.join("\n")
209:   end
initialize_publish() click to toggle source

Initialize variables for plugin.

    # File lib/hoe/publish.rb, line 85
85:   def initialize_publish
86:     self.blog_categories ||= [self.name]
87:     self.local_rdoc_dir  ||= 'doc'
88:     self.need_rdoc       ||= true
89:     self.rdoc_locations  ||= []
90:     self.remote_rdoc_dir ||= self.name
91:     self.rsync_args      ||= '-av --delete'
92:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.