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.
%w(TODO FIXME OPTIMIZE DEPRECATE).freeze
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
Instance Attribute Details
#exclude ⇒ Object
Exclude paths.
24 25 26 |
# File 'lib/dnote/rake/dnotetask.rb', line 24 def exclude @exclude end |
#files ⇒ Object
File paths to search.
15 16 17 |
# File 'lib/dnote/rake/dnotetask.rb', line 15 def files @files end |
#formats ⇒ Object
Formats (xml, html, rdoc, rdoc/list and so on).
21 22 23 |
# File 'lib/dnote/rake/dnotetask.rb', line 21 def formats @formats end |
#ignore ⇒ Object
Ignore paths based on any part of pathname.
27 28 29 |
# File 'lib/dnote/rake/dnotetask.rb', line 27 def ignore @ignore end |
#labels ⇒ Object
Labels to document. Defaults are: TODO, FIXME, OPTIMIZE and DEPRECATE.
18 19 20 |
# File 'lib/dnote/rake/dnotetask.rb', line 18 def labels @labels end |
#output ⇒ Object
Output directory to save notes file. Defaults to dnote/
under the project log directory (eg. log/dnote/
).
31 32 33 |
# File 'lib/dnote/rake/dnotetask.rb', line 31 def output @output end |
#title ⇒ Object
Title to use if temaplte can use it.
34 35 36 |
# File 'lib/dnote/rake/dnotetask.rb', line 34 def title @title end |
Instance Method Details
#clean ⇒ Object
Remove output files.
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/dnote/rake/dnotetask.rb', line 87 def clean 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 end |
#define ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dnote/rake/dnotetask.rb', line 49 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).
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/dnote/rake/dnotetask.rb', line 61 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 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(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 end |