Publish plugin for hoe.
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 | |
ridocs | Generate ri locally for testing. |
publish_on_announce | Run publish_docs when you run release. |
blogs | An array of hashes of blog settings. |
The blogs entry can either look like:
* path: ~/Work/p4/zss/www/blog.zenspider.com/releases type: zenweb
or:
* url: http://example.com/cgi-bin/blog.cgi blog_id: 1 user: username password: passwd extra_headers: blah: whatever
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
# File lib/hoe/publish.rb, line 99 99: def activate_publish_deps 100: dependency "rdoc", "~> 3.10", :developer if need_rdoc 101: end
Define tasks for plugin.
# File lib/hoe/publish.rb, line 106 106: def define_publish_tasks 107: if need_rdoc then 108: task :isolate # ensure it exists 109: 110: desc "Generate rdoc" 111: task :docs => [:clobber_docs, :isolate] do 112: sh(*make_rdoc_cmd) 113: end 114: 115: desc "Generate rdoc coverage report" 116: task :dcov => :isolate do 117: sh(*make_rdoc_cmd('-C')) 118: end 119: 120: desc "Remove RDoc files" 121: task :clobber_docs do 122: rm_rf local_rdoc_dir 123: end 124: 125: task :clobber => :clobber_docs 126: 127: desc 'Generate ri locally for testing.' 128: task :ridocs => [:clean, :isolate] do 129: ruby(*make_rdoc_cmd("--ri -o ri")) 130: end 131: end 132: 133: desc "Publish RDoc to wherever you want." 134: task :publish_docs => [:clean, :docs] do 135: warn "no rdoc_location values" if rdoc_locations.empty? 136: self.rdoc_locations.each do |dest| 137: sh %{rsync #{rsync_args} #{local_rdoc_dir}/ #{dest}} 138: end 139: end 140: 141: # no doco for this one 142: task :publish_on_announce do 143: with_config do |config, _| 144: Rake::Task['publish_docs'].invoke if config["publish_on_announce"] 145: end 146: end 147: 148: desc 'Generate email announcement file.' 149: task :debug_email do 150: puts generate_email 151: end 152: 153: desc 'Post announcement to blog. Uses the "blogs" array in your hoerc.' 154: task :post_blog do 155: with_config do |config, path| 156: break unless config['blogs'] 157: 158: config['blogs'].each do |site| 159: if site['path'] then 160: msg = "post_blog_#{site['type']}" 161: send msg, site 162: else 163: require 'xmlrpc/client' 164: 165: _, title, body, urls = announcement 166: body += "\n\n#{urls}" 167: 168: server = XMLRPC::Client.new2(site['url']) 169: content = site['extra_headers'].merge(:title => title, 170: :description => body, 171: :categories => blog_categories) 172: 173: server.call('metaWeblog.newPost', 174: site['blog_id'], 175: site['user'], 176: site['password'], 177: content, 178: true) 179: end 180: end 181: end 182: end 183: 184: desc 'Announce your release.' 185: task :announce => [:post_blog, :publish_on_announce ] 186: end
# File lib/hoe/publish.rb, line 230 230: def generate_email full = nil 231: require 'time' 232: 233: abort "No email 'to' entry. Run `rake config_hoe` to fix." unless 234: !full || email_to 235: 236: from_name, from_email = author.first, email.first 237: subject, title, body, urls = announcement 238: 239: [ 240: full && "From: #{from_name} <#{from_email}>", 241: full && "To: #{email_to.join(", ")}", 242: full && "Date: #{Time.now.rfc2822}", 243: "Subject: [ANN] #{subject}", 244: "", title, 245: "", urls, 246: "", body, 247: ].compact.join("\n") 248: end
Initialize variables for plugin.
# File lib/hoe/publish.rb, line 90 90: def initialize_publish 91: self.blog_categories ||= [self.name] 92: self.local_rdoc_dir ||= 'doc' 93: self.need_rdoc ||= true 94: self.rdoc_locations ||= [] 95: self.remote_rdoc_dir ||= self.name 96: self.rsync_args ||= '-av -O --delete' 97: end
# File lib/hoe/publish.rb, line 188 188: def make_rdoc_cmd(*extra_args) 189: title = "#{name}-#{version} Documentation" 190: title = "#{rubyforge_name}'s #{title}" if rubyforge_name != name 191: rdoc = Gem.bin_wrapper "rdoc" 192: 193: ]#{rdoc} 194: --title #{title} 195: -o #{local_rdoc_dir} 196: ] + 197: spec.rdoc_options + 198: extra_args + 199: spec.require_paths + 200: spec.extra_rdoc_files 201: end
# File lib/hoe/publish.rb, line 203 203: def post_blog_zenweb site 204: dir = site["path"] 205: 206: _, title, body, urls = announcement 207: body += "\n\n#{urls}" 208: 209: Dir.chdir File.expand_path dir do 210: time = Time.at Time.now.to_i # nukes fractions 211: path = [time.strftime("%Y-%m-%d-"), 212: title.sub(/\W+$/, '').gsub(/\W+/, '-'), 213: ".html.md"].join 214: 215: header = { 216: "title" => title, 217: "categories" => blog_categories, 218: "date" => time, 219: } 220: 221: File.open path, "w" do |f| 222: f.puts header.to_yaml.gsub(/\s$/, '') 223: f.puts "..." 224: f.puts 225: f.puts body 226: end 227: end 228: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.