module 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.

The blogs entry can either look like:

- path: ~/Work/p4/zss/www/blog.zenspider.com/releases
  type: zenweb
  cmd: rake sync    (optional)

or:

- url: http://example.com/cgi-bin/blog.cgi
  blog_id: 1
  user: username
  password: passwd
  extra_headers:
    blah: whatever

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.

default: doc
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

activate_publish_deps() click to toggle source

Declare a dependency on rdoc, IF NEEDED.

# File lib/hoe/publish.rb, line 103
def activate_publish_deps
  dependency "rdoc", "~> 4.0", :developer if need_rdoc
end
define_publish_tasks() click to toggle source

Define tasks for plugin.

# File lib/hoe/publish.rb, line 110
def define_publish_tasks
  if need_rdoc then
    task :isolate # ensure it exists

    desc "Generate rdoc"
    task :docs => [:clobber_docs, :isolate] do
      sh(*make_rdoc_cmd)
    end

    desc "Generate rdoc coverage report"
    task :dcov => :isolate do
      sh(*make_rdoc_cmd('-C'))
    end

    desc "Remove RDoc files"
    task :clobber_docs do
      rm_rf local_rdoc_dir
    end

    task :clobber => :clobber_docs

    desc 'Generate ri locally for testing.'
    task :ridocs => [:clean, :isolate] do
      ruby(*make_rdoc_cmd('--ri', '-o', 'ri'))
    end
  end

  desc "Publish RDoc to wherever you want."
  task :publish_docs => [:clean, :docs] do
    warn "no rdoc_location values" if rdoc_locations.empty?
    self.rdoc_locations.each do |dest|
      sh %Q{rsync #{rsync_args} #{local_rdoc_dir}/ #{dest}}
    end
  end

  # no doco for this one
  task :publish_on_announce do
    with_config do |config, _|
      Rake::Task['publish_docs'].invoke if config["publish_on_announce"]
    end
  end

  desc 'Generate email announcement file.'
  task :debug_email do
    puts generate_email
  end

  desc 'Post announcement to blog. Uses the "blogs" array in your hoerc.'
  task :post_blog do
    with_config do |config, path|
      break unless config['blogs']

      config['blogs'].each do |site|
        if site['path'] then
          msg = "post_blog_#{site['type']}"
          send msg, site
          system site["cmd"] if site["cmd"]
        else
          require 'xmlrpc/client'

          _, title, body, urls = announcement
          body += "\n\n#{urls}"

          server = XMLRPC::Client.new2(site['url'])
          content = site['extra_headers'].merge(:title => title,
                                                :description => body,
                                                :categories => blog_categories)

          server.call('metaWeblog.newPost',
                      site['blog_id'],
                      site['user'],
                      site['password'],
                      content,
                      true)
        end
      end
    end
  end

  desc 'Announce your release.'
  task :announce => [:post_blog, :publish_on_announce ]
end
initialize_publish() click to toggle source

Initialize variables for plugin.

# File lib/hoe/publish.rb, line 91
def initialize_publish
  self.blog_categories ||= [self.name]
  self.local_rdoc_dir  ||= 'doc'
  self.need_rdoc       ||= true
  self.rdoc_locations  ||= []
  self.remote_rdoc_dir ||= self.name
  self.rsync_args      ||= '-av -O --delete'
end