dnote 1.1.4 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/HISTORY +29 -0
  2. data/bin/dnote +2 -2
  3. data/lib/dnote.rb +2 -3
  4. data/lib/dnote/format.rb +26 -69
  5. data/lib/dnote/note.rb +57 -0
  6. data/lib/dnote/notes.rb +158 -97
  7. data/lib/dnote/session.rb +277 -0
  8. data/lib/dnote/templates/html.erb +4 -4
  9. data/lib/dnote/templates/html/file.erb +40 -0
  10. data/lib/dnote/templates/html/label.erb +41 -0
  11. data/lib/dnote/templates/html/list.erb +33 -0
  12. data/lib/dnote/templates/json.erb +8 -0
  13. data/lib/dnote/templates/json/file.erb +8 -0
  14. data/lib/dnote/templates/json/label.erb +8 -0
  15. data/lib/dnote/templates/json/list.erb +8 -0
  16. data/lib/dnote/templates/md.erb +18 -0
  17. data/lib/dnote/templates/md/file.erb +13 -0
  18. data/lib/dnote/templates/md/label.erb +18 -0
  19. data/lib/dnote/templates/md/list.erb +9 -0
  20. data/lib/dnote/templates/rdoc.erb +3 -3
  21. data/lib/dnote/templates/rdoc/file.erb +9 -0
  22. data/lib/dnote/templates/rdoc/label.erb +11 -0
  23. data/lib/dnote/templates/rdoc/list.erb +6 -0
  24. data/lib/dnote/templates/soap.erb +4 -0
  25. data/lib/dnote/templates/soap/file.erb +4 -0
  26. data/lib/dnote/templates/soap/label.erb +4 -0
  27. data/lib/dnote/templates/soap/list.erb +4 -0
  28. data/lib/dnote/templates/text.erb +11 -0
  29. data/lib/dnote/templates/text/file.erb +10 -0
  30. data/lib/dnote/templates/text/label.erb +11 -0
  31. data/lib/dnote/templates/text/list.erb +7 -0
  32. data/lib/dnote/templates/xml.erb +6 -6
  33. data/lib/dnote/templates/xml/file.erb +15 -0
  34. data/lib/dnote/templates/xml/label.erb +15 -0
  35. data/lib/dnote/templates/xml/list.erb +6 -0
  36. data/lib/dnote/templates/xoxo.erb +4 -0
  37. data/lib/dnote/templates/xoxo/file.erb +4 -0
  38. data/lib/dnote/templates/xoxo/label.erb +4 -0
  39. data/lib/dnote/templates/xoxo/list.erb +6 -0
  40. data/lib/dnote/templates/yaml.erb +1 -0
  41. data/lib/dnote/templates/yaml/file.erb +1 -0
  42. data/lib/dnote/templates/yaml/label.erb +1 -0
  43. data/lib/dnote/templates/yaml/list.erb +1 -0
  44. data/lib/plugins/syckle/dnote.rb +35 -8
  45. data/meta/version +1 -1
  46. data/test/cases/notes_case.rb +20 -31
  47. metadata +44 -14
  48. data/MANIFEST +0 -33
  49. data/lib/dnote/command.rb +0 -134
  50. data/lib/dnote/site.rb +0 -140
  51. data/lib/dnote/templates/gnu.erb +0 -8
  52. data/lib/dnote/templates/markdown.erb +0 -17
@@ -0,0 +1,18 @@
1
+ <%= title %>
2
+
3
+ <%= '=' * title.size %>
4
+
5
+ <% notes.by_label_file.each do |label, per_file| %>
6
+
7
+ <%= label %>
8
+
9
+ <%= '-' * (label.size) %>
10
+
11
+ <% per_file.each do |file, line_notes| %>
12
+
13
+ ### file://<%= file %>
14
+
15
+ <% line_notes.each do |note| %>
16
+ * <%= note %> (<%= note.line %>)
17
+ <% end; end; end %>
18
+
@@ -0,0 +1,13 @@
1
+ <%= title %>
2
+
3
+ <%= '=' * title.size %>
4
+
5
+ <% notes.by_file.each do |file, list| %>
6
+
7
+ file://<%= file %>
8
+ <%= '-' * (file.size + 7) %>
9
+
10
+ <% list.each do |note| %>
11
+ * <%= note %> (<%= note.line %>)
12
+ <% end; end %>
13
+
@@ -0,0 +1,18 @@
1
+ <%= title %>
2
+
3
+ <%= '=' * title.size %>
4
+
5
+ <% notes.by_label_file.each do |label, per_file| %>
6
+
7
+ <%= label %>
8
+
9
+ <%= '-' * (label.size) %>
10
+
11
+ <% per_file.each do |file, line_notes| %>
12
+
13
+ ### file://<%= file %>
14
+
15
+ <% line_notes.each do |note| %>
16
+ * <%= note %> (<%= note.line %>)
17
+ <% end; end; end %>
18
+
@@ -0,0 +1,9 @@
1
+ <%= title %>
2
+
3
+ <%= '=' * title.size %>
4
+
5
+
6
+ <% notes.each_with_index do |note, index| %>
7
+ <%= "%s" % [index+1] %>. <%= note.label %>: <%= h note.textline %> (<%= note.file %>: <%= note.line %>)
8
+ <% end %>
9
+
@@ -1,11 +1,11 @@
1
- = <%= title %><% notes.each do |label, per_file| %>
1
+ = <%= title %><% notes.by_label_file.each do |label, per_file| %>
2
2
 
3
3
  == <%= label %>
4
4
  <% per_file.each do |file, line_notes| %>
5
5
 
6
6
  === file://<%= file %>
7
7
 
8
- <% line_notes.sort!{ |a,b| a[0] <=> b[0] } %><% line_notes.each do |line, note| %>
9
- * <%= note %> (<%= line %>)
8
+ <% line_notes.each do |note| %>
9
+ * <%= note %> (<%= note.line %>)
10
10
  <% end; end; end %>
11
11
 
@@ -0,0 +1,9 @@
1
+ = <%= title %>
2
+ <% notes.by_file.each do |file, list| %>
3
+
4
+ == file://<%= file %>
5
+
6
+ <% list.each do |note| %>
7
+ * <%= note %> (<%= note.line %>)
8
+ <% end; end %>
9
+
@@ -0,0 +1,11 @@
1
+ = <%= title %><% notes.by_label_file.each do |label, per_file| %>
2
+
3
+ == <%= label %>
4
+ <% per_file.each do |file, line_notes| %>
5
+
6
+ === file://<%= file %>
7
+
8
+ <% line_notes.each do |note| %>
9
+ * <%= note %> (<%= note.line %>)
10
+ <% end; end; end %>
11
+
@@ -0,0 +1,6 @@
1
+ = <%= title %>
2
+
3
+ <% notes.each_with_index do |note, index| %>
4
+ * <%= note.label %>: <%= h note.textline %> (<%= note.file %>: <%= note.line %>)
5
+ <% end %>
6
+
@@ -0,0 +1,4 @@
1
+ <%=
2
+ require 'soap/marshal'
3
+ ::SOAP::Marshal.marshal(notes.to_a)
4
+ %>
@@ -0,0 +1,4 @@
1
+ <%=
2
+ require 'soap/marshal'
3
+ ::SOAP::Marshal.marshal(notes.by_file)
4
+ %>
@@ -0,0 +1,4 @@
1
+ <%=
2
+ require 'soap/marshal'
3
+ ::SOAP::Marshal.marshal(notes.by_label)
4
+ %>
@@ -0,0 +1,4 @@
1
+ <%=
2
+ require 'soap/marshal'
3
+ ::SOAP::Marshal.marshal(notes.to_a)
4
+ %>
@@ -0,0 +1,11 @@
1
+ <%= title %>
2
+
3
+ <% notes.by_label.each do |label, line_notes| %>
4
+
5
+ <%= label %>
6
+
7
+
8
+ <% line_notes.each_with_index do |note, i| %>
9
+ <%= note.text.indent(6).sub(' ' * 6,(" %3s. " % [i+1])) %> (<%= note.file %>:<%= note.line %>)
10
+ <% end; end %>
11
+
@@ -0,0 +1,10 @@
1
+ <%= title %>
2
+
3
+ <% notes.by_file.each do |file, line_notes| %>
4
+
5
+ <%= file %>:
6
+
7
+ <% line_notes.sort!{ |a,b| a.line <=> b.line } %><% line_notes.each do |note| %>
8
+ <%= note.to_s.indent(10).sub(' ' * 10,' * ') %> (<%= note.line %>)
9
+ <% end; end %>
10
+
@@ -0,0 +1,11 @@
1
+ <%= title %>
2
+
3
+ <% notes.by_label.each do |label, line_notes| %>
4
+
5
+ <%= label %>
6
+
7
+
8
+ <% line_notes.each_with_index do |note, i| %>
9
+ <%= note.text.indent(6).sub(' ' * 6,(" %3s. " % [i+1])) %> (<%= note.file %>:<%= note.line %>)
10
+ <% end; end %>
11
+
@@ -0,0 +1,7 @@
1
+ <%= title %>
2
+
3
+
4
+ <% notes.each_with_index do |note, index| %>
5
+ <%= "%4s %s %s" % [index+1, note.label, note.text.gsub("\n", ' ')] %> (<%= note.file %>:<%= note.line %>)
6
+ <% end %>
7
+
@@ -1,15 +1,15 @@
1
1
  <?xml version="1.0" ?>
2
2
  <notes>
3
- <% notes.each do |label, per_file| %>
4
- <set label="<%= label %>">
3
+ <% notes.by_label_file.each do |label, per_file| %>
4
+ <label name="<%= label %>">
5
5
  <% per_file.each do |file, line_notes| %>
6
6
  <file src="<%= file %>">
7
- <% line_notes.sort!{ |a,b| a[0] <=> b[0] } %>
8
- <% line_notes.each do |line, note| %>
9
- <note line="<%= line %>" type="<%= label %>"><%= h note %></note>
7
+ <% line_notes.sort!{ |a,b| a.line <=> b.line } %>
8
+ <% line_notes.each do |note| %>
9
+ <note line="<%= note.line %>" type="<%= label %>"><%= h note.textline %></note>
10
10
  <% end %>
11
11
  </file>
12
12
  <% end %>
13
- </set>
13
+ </label>
14
14
  <% end %>
15
15
  </notes>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" ?>
2
+ <notes>
3
+ <% notes.by_file_label.each do |file, per_label| %>
4
+ <file src="<%= file %>">
5
+ <% per_label.each do |label, lnotes| %>
6
+ <label name="<%= label %>">
7
+ <% line_notes.sort!{ |a,b| a.line <=> b.line } %>
8
+ <% line_notes.each do |note| %>
9
+ <note line="<%= note.line %>" type="<%= label %>"><%= h note.textline %></note>
10
+ <% end %>
11
+ </label>
12
+ <% end %>
13
+ </file>
14
+ <% end %>
15
+ </notes>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" ?>
2
+ <notes>
3
+ <% notes.by_label_file.each do |label, per_file| %>
4
+ <label name="<%= label %>">
5
+ <% per_file.each do |file, line_notes| %>
6
+ <file src="<%= file %>">
7
+ <% line_notes.sort!{ |a,b| a.line <=> b.line } %>
8
+ <% line_notes.each do |note| %>
9
+ <note line="<%= note.line %>" type="<%= label %>"><%= h note.textline %></note>
10
+ <% end %>
11
+ </file>
12
+ <% end %>
13
+ </label>
14
+ <% end %>
15
+ </notes>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" ?>
2
+ <notes>
3
+ <% notes.each do |note| %>
4
+ <note file="<%= note.file %>" line="<%= note.line %>" type="<%= label %>"><%= h note.textline %></note>
5
+ <% end %>
6
+ </notes>
@@ -0,0 +1,4 @@
1
+ <%=
2
+ require 'xoxo'
3
+ notes.by_label.to_xoxo
4
+ %>
@@ -0,0 +1,4 @@
1
+ <%=
2
+ require 'xoxo'
3
+ notes.by_file.to_xoxo
4
+ %>
@@ -0,0 +1,4 @@
1
+ <%=
2
+ require 'xoxo'
3
+ notes.by_label.to_xoxo
4
+ %>
@@ -0,0 +1,6 @@
1
+ <%=
2
+ require 'xoxo'
3
+ notes.map{ |n|
4
+ { 'label'=>n.label, 'text'=>n.textline, 'file'=>n.file, 'line'=>n.line }
5
+ }.to_xoxo
6
+ %>
@@ -0,0 +1 @@
1
+ <%= require 'yaml'; notes.map{ |n| n.to_h_raw }.to_yaml %>
@@ -0,0 +1 @@
1
+ <%= require 'yaml'; notes.by_file.to_yaml %>
@@ -0,0 +1 @@
1
+ <%= require 'yaml'; notes.by_label.to_yaml %>
@@ -0,0 +1 @@
1
+ <%= require 'yaml'; notes.map{ |n| n.to_h_raw }.to_yaml %>
@@ -40,14 +40,20 @@ module Syckle::Plugins
40
40
  end
41
41
 
42
42
  # Default note labels to looked for in source code.
43
- #DEFAULT_LABELS = ['TODO', 'FIXME', 'OPTIMIZE', 'DEPRECATE']
43
+ DEFAULT_LABELS = ['TODO', 'FIXME', 'OPTIMIZE', 'DEPRECATE']
44
44
 
45
- # Paths to search.
45
+ # File paths to search.
46
46
  attr_accessor :files
47
47
 
48
48
  # Labels to document. Defaults are: TODO, FIXME, OPTIMIZE and DEPRECATE.
49
49
  attr_accessor :labels
50
50
 
51
+ # Exclude paths.
52
+ attr_accessor :exclude
53
+
54
+ # Ignore paths based on any part of pathname.
55
+ attr_accessor :ignore
56
+
51
57
  # Output directory to save notes file. Defaults to <tt>dnote/</tt> under
52
58
  # the project log directory (eg. <tt>log/dnote/</tt>).
53
59
  attr_accessor :output
@@ -73,16 +79,37 @@ module Syckle::Plugins
73
79
  # TODO: Is #trial? correct?
74
80
  #++
75
81
  def document
76
- notes = ::DNote::Notes.new(files, labels)
77
- [formats].flatten.each do |format|
82
+ session = ::DNote::Session.new do |s|
83
+ s.paths = files
84
+ s.exclude = exclude
85
+ s.ignore = ignore
86
+ s.labels = labels #|| DEFAULT_LABELS
87
+ s.title = title
88
+ s.output = output
89
+ s.dryrun = trial?
90
+ end
91
+ formats.each do |format|
78
92
  if format == 'index'
79
- format = 'html'
80
- output = File.join(self.output, 'index.html')
93
+ session.format = 'html'
94
+ session.output = File.join(self.output, 'index.html')
95
+ else
96
+ session.format = format
81
97
  end
82
- format = ::DNote::Format.new(notes, :format=>format, :output=>output.to_s, :title=>title, :dryrun=>trial?)
83
- format.render
98
+ session.run
84
99
  report "Updated #{output.to_s.sub(Dir.pwd+'/','')}" unless trial?
85
100
  end
101
+
102
+ #files = files.map{ |f| Dir[f] }.flatten
103
+ #notes = ::DNote::Notes.new(files, :labels=>labels)
104
+ #[formats].flatten.each do |format|
105
+ # if format == 'index'
106
+ # format = 'html'
107
+ # output = File.join(self.output, 'index.html')
108
+ # end
109
+ # format = ::DNote::Format.new(notes, :format=>format, :output=>output.to_s, :title=>title, :dryrun=>trial?)
110
+ # format.render
111
+ # report "Updated #{output.to_s.sub(Dir.pwd+'/','')}" unless trial?
112
+ #end
86
113
  end
87
114
 
88
115
  # Reset output directory, marking it as out-of-date.
@@ -1 +1 @@
1
- 1.1.4
1
+ 1.2.0
@@ -2,54 +2,43 @@ require 'dnote/notes'
2
2
 
3
3
  Case DNote::Notes do
4
4
 
5
- Concern "Full coverage of DNote::Notes class."
6
-
7
- Unit :paths
5
+ Concern "Basic coverage of DNote::Notes class."
8
6
 
9
7
  Unit :labels => 'returns the list of labels' do
10
- notes = DNote::Notes.new([])
11
- notes.labels.assert == DNote::Notes::DEFAULT_LABELS
12
- end
13
-
14
- Unit :labels= => 'changes the list of labels' do
15
- notes = DNote::Notes.new([])
16
- notes.labels = [:CHOICE]
17
- notes.labels.assert == ['CHOICE']
8
+ notes = DNote::Notes.new([], :labels=>['TODO'])
9
+ notes.labels.assert == ['TODO'] #DNote::Notes::DEFAULT_LABELS
18
10
  end
19
11
 
20
- Unit :paths => 'returns the paths attribute' do
12
+ Unit :files => 'returns the files attribute' do
21
13
  notes = DNote::Notes.new(["example1.rb"])
22
- notes.assert.paths == ["example1.rb"]
14
+ notes.assert.files == ["example1.rb"]
23
15
  notes = DNote::Notes.new([], :paths => ["example2.rb"])
24
- notes.assert.paths == ["example2.rb"]
16
+ notes.assert.files == ["example2.rb"]
25
17
  end
26
18
 
27
- Unit :paths= => 'changes the paths attribute' do
19
+ Unit :files= => 'changes the paths attribute' do
28
20
  notes = DNote::Notes.new([])
29
- notes.paths = ["example1.rb"]
30
- notes.assert.paths == ["example1.rb"]
21
+ notes.files = ["example1.rb"]
22
+ notes.assert.files == ["example1.rb"]
31
23
  end
32
24
 
33
- Unit :files
34
-
35
- Unit :match_arbitrary => '' do
25
+ Unit :match_general => '' do
36
26
  notes = DNote::Notes.new([])
37
27
  line, lineno, file = "# TODO: Do something or another!", 1, "foo.rb"
38
- rec = notes.match_arbitrary(line, lineno, file)
39
- rec.assert == {'label'=>"TODO",'file'=>file,'line'=>lineno,'note'=>"Do something or another!"}
28
+ rec = notes.match_general(line, lineno, file)
29
+ rec.to_h.assert == {'label'=>"TODO",'file'=>file,'line'=>lineno,'text'=>"Do something or another!"}
40
30
  end
41
31
 
42
- Unit :match_common
43
- Unit :to_xml
32
+ Unit :match_specail => '' do
33
+ notes = DNote::Notes.new([], :labels=>['TODO'])
34
+ line, lineno, file = "# TODO: Do something or another!", 1, "foo.rb"
35
+ rec = notes.match_special(line, lineno, file)
36
+ rec.to_h.assert == {'label'=>"TODO",'file'=>file,'line'=>lineno,'text'=>"Do something or another!"}
37
+ end
38
+
39
+ Unit :counts
44
40
  Unit :notes
45
- Unit :to
46
- Unit :initialize_defaults
47
41
  Unit :parse
48
- Unit :to_yaml
49
- Unit :to_json
50
- Unit :counts
51
- Unit :organize
52
- Unit :display
53
42
 
54
43
  end
55
44
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
8
- - 4
9
- version: 1.1.4
7
+ - 2
8
+ - 0
9
+ version: 1.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Thomas Sawyer
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-12 00:00:00 -05:00
17
+ date: 2010-02-18 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -27,22 +27,49 @@ extensions: []
27
27
  extra_rdoc_files: []
28
28
 
29
29
  files:
30
- - HISTORY
31
- - LICENSE
32
- - MANIFEST
33
- - README.rdoc
34
30
  - bin/dnote
35
- - lib/dnote.rb
36
- - lib/dnote/command.rb
37
31
  - lib/dnote/format.rb
32
+ - lib/dnote/note.rb
38
33
  - lib/dnote/notes.rb
39
- - lib/dnote/site.rb
34
+ - lib/dnote/session.rb
40
35
  - lib/dnote/string.rb
41
- - lib/dnote/templates/gnu.erb
36
+ - lib/dnote/templates/html/file.erb
37
+ - lib/dnote/templates/html/label.erb
38
+ - lib/dnote/templates/html/list.erb
42
39
  - lib/dnote/templates/html.erb
43
- - lib/dnote/templates/markdown.erb
40
+ - lib/dnote/templates/json/file.erb
41
+ - lib/dnote/templates/json/label.erb
42
+ - lib/dnote/templates/json/list.erb
43
+ - lib/dnote/templates/json.erb
44
+ - lib/dnote/templates/md/file.erb
45
+ - lib/dnote/templates/md/label.erb
46
+ - lib/dnote/templates/md/list.erb
47
+ - lib/dnote/templates/md.erb
48
+ - lib/dnote/templates/rdoc/file.erb
49
+ - lib/dnote/templates/rdoc/label.erb
50
+ - lib/dnote/templates/rdoc/list.erb
44
51
  - lib/dnote/templates/rdoc.erb
52
+ - lib/dnote/templates/soap/file.erb
53
+ - lib/dnote/templates/soap/label.erb
54
+ - lib/dnote/templates/soap/list.erb
55
+ - lib/dnote/templates/soap.erb
56
+ - lib/dnote/templates/text/file.erb
57
+ - lib/dnote/templates/text/label.erb
58
+ - lib/dnote/templates/text/list.erb
59
+ - lib/dnote/templates/text.erb
60
+ - lib/dnote/templates/xml/file.erb
61
+ - lib/dnote/templates/xml/label.erb
62
+ - lib/dnote/templates/xml/list.erb
45
63
  - lib/dnote/templates/xml.erb
64
+ - lib/dnote/templates/xoxo/file.erb
65
+ - lib/dnote/templates/xoxo/label.erb
66
+ - lib/dnote/templates/xoxo/list.erb
67
+ - lib/dnote/templates/xoxo.erb
68
+ - lib/dnote/templates/yaml/file.erb
69
+ - lib/dnote/templates/yaml/label.erb
70
+ - lib/dnote/templates/yaml/list.erb
71
+ - lib/dnote/templates/yaml.erb
72
+ - lib/dnote.rb
46
73
  - lib/plugins/syckle/dnote.rb
47
74
  - meta/account
48
75
  - meta/authors
@@ -55,6 +82,9 @@ files:
55
82
  - meta/title
56
83
  - meta/version
57
84
  - test/cases/notes_case.rb
85
+ - LICENSE
86
+ - README.rdoc
87
+ - HISTORY
58
88
  has_rdoc: true
59
89
  homepage:
60
90
  licenses: []
@@ -82,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
112
  requirements: []
83
113
 
84
114
  rubyforge_project: dnote
85
- rubygems_version: 1.3.6.pre.2
115
+ rubygems_version: 1.3.6.pre.3
86
116
  signing_key:
87
117
  specification_version: 3
88
118
  summary: Extract developer notes from source code.