Class: DNote::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/dnote/rake/dnotetask.rb

Overview

Developmerā€™s Notes Rake Task

Constant Summary collapse

DEFAULT_LABELS =

Default note labels to looked for in source code.

['TODO', 'FIXME', 'OPTIMIZE', 'DEPRECATE']

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#excludeObject

Exclude paths.



22
23
24
# File 'lib/dnote/rake/dnotetask.rb', line 22

def exclude
  @exclude
end

#filesObject

File paths to search.



13
14
15
# File 'lib/dnote/rake/dnotetask.rb', line 13

def files
  @files
end

#formatsObject

Formats (xml, html, rdoc, rdoc/list and so on).



19
20
21
# File 'lib/dnote/rake/dnotetask.rb', line 19

def formats
  @formats
end

#ignoreObject

Ignore paths based on any part of pathname.



25
26
27
# File 'lib/dnote/rake/dnotetask.rb', line 25

def ignore
  @ignore
end

#labelsObject

Labels to document. Defaults are: TODO, FIXME, OPTIMIZE and DEPRECATE.



16
17
18
# File 'lib/dnote/rake/dnotetask.rb', line 16

def labels
  @labels
end

#outputObject

Output directory to save notes file. Defaults to dnote/ under the project log directory (eg. log/dnote/).



29
30
31
# File 'lib/dnote/rake/dnotetask.rb', line 29

def output
  @output
end

#titleObject

Title to use if temaplte can use it.



32
33
34
# File 'lib/dnote/rake/dnotetask.rb', line 32

def title
  @title
end

Instance Method Details

#cleanObject

Remove output files.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/dnote/rake/dnotetask.rb', line 96

def clean
  #if File.directory?(output)
    formats.each do |format|
      if format == 'index'
        file = (output + "index.html").to_s
      else
        ext = ::DNote::Format::EXTENSIONS[format] || format
        file = (output + "notes.#{ext}").to_s
      end
      rm(file)
      report "Removed #{output}"
    end
  #else
  #  rm(output)
  #  report "Removed #{output}"
  #end
end

#defineObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/dnote/rake/dnotetask.rb', line 50

def define
  desc "Collect Developer's Notes"
  task 'dnote' do
    document
  end
  task 'dnote:clobber' do
    clean
  end
  task :clobber => ['dnote:clobber']
end

#documentObject

Generate notes document(s).



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/dnote/rake/dnotetask.rb', line 62

def document
  abort "dnote: #{output} is not a directory" unless output.directory?

  session = ::DNote::Session.new do |s|
    s.paths   = files
    s.exclude = exclude
    s.ignore  = ignore
    s.labels  = labels #|| DEFAULT_LABELS   
    s.title   = title
    s.output  = output
    s.dryrun  = application.options.dryrun #trial?
  end

  formats.each do |format|
    if format == 'index'
      session.format = 'html'
      session.output = File.join(self.output, 'index.html')
    else
      session.format = format
    end
    session.run
    report "Updated #{output.to_s.sub(Dir.pwd+'/','')}" unless trial?
  end
end

#initObject



40
41
42
43
44
45
46
47
# File 'lib/dnote/rake/dnotetask.rb', line 40

def init
  require 'dnote'
  require 'dnote/format'
  @files   = "**/*.rb"
  @output  = 'log/dnote'
  @formats = ['index']
  @labels  = nil #DEFAULT_LABELS
end

#resetObject

Reset output directory, marking it as out-of-date.



88
89
90
91
92
93
# File 'lib/dnote/rake/dnotetask.rb', line 88

def reset
  #if File.directory?(output)
    File.utime(0,0,output) unless $NOOP
    puts "Marked #{output} as out-of-date"
  #end
end