Sha256: 7fc903d68322c6e17647078631f86624deea1a81dcab66fca9a679d6c0decfef

Contents?: true

Size: 1.87 KB

Versions: 3

Compression:

Stored size: 1.87 KB

Contents

module Reap

  # = Doap

  class Doap

    include TaskUtils

    attr_accessor :dir

    attr_accessor :title,
                  :name,
                  :created,
                  :summary,
                  :description,
                  :maintainer,
                  :email,
                  :homepage,
                  :wiki

    def initalize( prj )
      super

      @dir ||= '.'
    end

    def call
      write( generate )
      puts "DOAP file created at '#{File.join( @dir, "doap.xml" )}'."
    end

    # Generate a doap file.

    def generate
      x = ''
      x << %{
            |<Project xmlns="http://usefulinc.com/ns/doap#"\n
            |         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n
            |         xmlns:foaf="http://xmlns.com/foaf/0.1/">
            |   <name>#{@title}</name>
            |   <shortname>#{@name}</shortname>
            |   <homepage rdf:resource="#{@homepage}" />
            |   <wiki rdf:resource="#{@wiki}" />
            |   <created>#{@created}</created>
            |   <shortdesc xml:lang="en">
            }.margin
      x << "\n" << @summary.word_wrap(50).indent(6)
      x << %{
            |   </shortdesc>
            |   <description xml:lang="en">
            }.margin
      x << "\n" << @description.word_wrap(50).indent(6)
      x << %{
            |   </description>
            |   <maintainer>
            |     <foaf:Person>
            |       <foaf:name>#{@maintainer}</foaf:name>
            |       <foaf:email>#{@email}</foaf:name>
            |       <foaf:homepage rdf:resource="#{@homepage}" />
            |     </foaf:Person>
            |   </maintainer>
            | </Project>
            }.margin

      return x
    end

  private

    # Write the doap file.

    def write( doap )
      file = File.join( @dir, "doap.xml" )
      File.open( file, 'w' ) { |f| f << doap }
    end

  end

end #module Reap

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reap-6.0.0 lib/reap/class/doap.rb
reap-6.0.2 lib/reap/class/doap.rb
reap-6.0.1 lib/reap/class/doap.rb