Sha256: 069ed9dcbcf267641adc6fb8b79247638092f42965f69a07ecb187a2d7f7d684

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

module Reap

  class Manager

    # Create web index.html from README. (Not yet used)

    def html
      require 'rdoc/markup/simple_markup'
      require 'rdoc/markup/simple_markup/to_html'

      options = configure_options(options, 'html')

      output = options['output']
      files  = options['files']
      style  = options['css']

      output ||= 'doc'
      files  ||= '[A-Z]*'
      style  ||= Dir.glob('*.css').first

      files = Dir.glob(files)

      s = SM::SimpleMarkup.new
      h = SM::ToHtml.new

      files.each do |file|
        unless File.exist?(file)
          puts "Warning: file does not exist -- #{file}"
        end
      end

      mkdir_p(output) unless dryrun?

      files.each do |file|
        name = file.downcase.chomp('.txt')
        if /^readme/ =~ name
          name = "index"
        end
        path = File.join(output, name + '.html')

        if dryrun?
          puts "[DRYRUN] Create #{path}"
        else
          next unless out_of_date?(path, file)

          title = "#{package.title} #{name.upcase}"

          input  = File.read(file)
          output = s.convert(input, h)

          File.open(path, 'w') do |f|
            f << %{<html>}
            f << %{<head>}
            f << %{  <title>#{title}<title>}
            f << %{  <link rel="stylesheet" TYPE="text/css" HREF="#{style}">} if style
            f << %{</head>}
            f << %{<body>}
            f << output
            f << %{</body>}
            f << %{</html>}
          end
          puts "Created #{path}"
        end
      end
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reap-9.2.0 lib/reap/manager/html.rb
reap-9.2.1 lib/reap/manager/html.rb