Class: DNote::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- DNote::RakeTask
- 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
-
#exclude ⇒ Object
Exclude paths.
-
#files ⇒ Object
File paths to search.
-
#formats ⇒ Object
Formats (xml, html, rdoc, rdoc/list and so on).
-
#ignore ⇒ Object
Ignore paths based on any part of pathname.
-
#labels ⇒ Object
Labels to document.
-
#output ⇒ Object
Output directory to save notes file.
-
#title ⇒ Object
Title to use if temaplte can use it.
Instance Method Summary collapse
-
#clean ⇒ Object
Remove output files.
- #define ⇒ Object
-
#document ⇒ Object
Generate notes document(s).
- #init ⇒ Object
-
#reset ⇒ Object
Reset output directory, marking it as out-of-date.
Instance Attribute Details
#exclude ⇒ Object
Exclude paths.
22 23 24 |
# File 'lib/dnote/rake/dnotetask.rb', line 22 def exclude @exclude end |
#files ⇒ Object
File paths to search.
13 14 15 |
# File 'lib/dnote/rake/dnotetask.rb', line 13 def files @files end |
#formats ⇒ Object
Formats (xml, html, rdoc, rdoc/list and so on).
19 20 21 |
# File 'lib/dnote/rake/dnotetask.rb', line 19 def formats @formats end |
#ignore ⇒ Object
Ignore paths based on any part of pathname.
25 26 27 |
# File 'lib/dnote/rake/dnotetask.rb', line 25 def ignore @ignore end |
#labels ⇒ Object
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 |
#output ⇒ Object
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 |
#title ⇒ Object
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
#clean ⇒ Object
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 |
#define ⇒ Object
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 |
#document ⇒ Object
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..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 |
#init ⇒ Object
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 |
#reset ⇒ Object
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 |