Sha256: 5fcfcac8714327f5a4abbe448bc90ad43a92d2626b87673e7fe7fc998b79d5a1

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'rake'
require 'rtfm'

namespace :man do
  desc "Display your man files in man."
  task :debug do
    require 'tempfile'
    require 'rtfm'
    RTFM::ManPage.all_pages.each do |page|
      Tempfile.open("#{page.name}.#{page.section}") do |f|
        f << page.to_groff
        f.flush
        system("man #{f.path}")
      end
    end
  end
  
  desc "Generate your manual files in the man/ directory"
  task :gen do
    FileUtils.makedirs "man/"
    RTFM::ManPage.all_pages.each do |page|
      File.open("man/#{page.name}.#{page.section}", "w") do |f|
        f << page.to_groff
      end
    end
  end
  
  desc "Install your manual files globally"
  task :install => :gen do
    if Rake.application.unix?
      Dir["man/*"].each do |manfile|
        section = manfile.split(".").last
        begin
          FileUtils.cp(manfile, "/usr/share/man/man#{section}/")
        rescue Errno::EACCES
          puts "I'm sorry, but you need root privileges to install man pages with this version"+
               " of RTFM."
        end
      end
    else
      raise "Can't install man pages without a unix-based OS."
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rtfm-0.5.2 lib/rtfm/tasks.rb
rtfm-0.5.1 lib/rtfm/tasks.rb
rtfm-0.5.0 lib/rtfm/tasks.rb