Class: Rake::XForge::NewsPublisher

Inherits:
Base
  • Object
show all
Defined in:
lib/rake/contrib/xforge/news_publisher.rb

Overview

This Rake task publishes news entries for a project. Publishing news is a good way to make your project visible on the main RubyForge page.

project = MetaProject::Project::XForge::RubyForge.new('xforge')
# Create a new news item for the xforge project on Rubyforge.
task :news => [:gem] do
  Rake::XForge::NewsPublisher.new(project) {}
end

The previous example will use defaults where it can. It will prompt you for your xForge user name and password before it posts a news item about the project with a default subject and news details.

While defaults are nice, you may want a little more control. You can specify additional attributes:

  • #user_name

  • #password

  • #changes_file

  • #version

  • #subject

  • #details

Example:

project = MetaProject::Project::XForge::RubyForge.new('xforge')
task :news => [:gem] do
  Rake::XForge::NewsPublisher.new(project) do |xf|
    # Never hardcode user name and password in the Rakefile!
    xf.user_name = ENV['RUBYFORGE_USER']
    xf.password = ENV['RUBYFORGE_PASSWORD']
    xf.subject = "XForge 0.1 Released"
    xf.details = "Today, XForge 0.1 was released to the ..."
  end
end

This can be invoked from the command line:

rake news RUBYFORGE_USER=myuser \
          RUBYFORGE_PASSWORD=mypassword

If you don’t like blocks, you can do like this:

task :news => [:gem] do
  xf = Rake::XForge::NewsPublisher.new(project)
  ... # Set additional attributes
  xf.execute
end

Instance Attribute Summary collapse

Attributes inherited from Base

#changes_file, #version

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Rake::XForge::Base

Instance Attribute Details

#detailsObject

The plain-text news to be published. Hyperlinks are usually converted to hyperlinks by the xForge software.



55
56
57
# File 'lib/rake/contrib/xforge/news_publisher.rb', line 55

def details
  @details
end

#subjectObject

A plain-text headline for the news byte to be published.



52
53
54
# File 'lib/rake/contrib/xforge/news_publisher.rb', line 52

def subject
  @subject
end

Instance Method Details

#executeObject

Runs the news publisher task.



58
59
60
61
62
63
# File 'lib/rake/contrib/xforge/news_publisher.rb', line 58

def execute
  raise "'details' not defined." unless @details
  raise "'subject' not defined." unless @subject
  session = @project.(user_name, password)
  session.publish_news(@subject, @details)
end