dnote 1.1.4 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
data/MANIFEST DELETED
@@ -1,33 +0,0 @@
1
- HISTORY
2
- LICENSE
3
- MANIFEST
4
- README.rdoc
5
- bin/dnote
6
- lib/dnote
7
- lib/dnote.rb
8
- lib/dnote/command.rb
9
- lib/dnote/format.rb
10
- lib/dnote/notes.rb
11
- lib/dnote/site.rb
12
- lib/dnote/string.rb
13
- lib/dnote/templates
14
- lib/dnote/templates/gnu.erb
15
- lib/dnote/templates/html.erb
16
- lib/dnote/templates/markdown.erb
17
- lib/dnote/templates/rdoc.erb
18
- lib/dnote/templates/xml.erb
19
- lib/plugins
20
- lib/plugins/syckle
21
- lib/plugins/syckle/dnote.rb
22
- meta/account
23
- meta/authors
24
- meta/contact
25
- meta/name
26
- meta/released
27
- meta/repository
28
- meta/suite
29
- meta/summary
30
- meta/title
31
- meta/version
32
- test/cases
33
- test/cases/notes_case.rb
@@ -1,134 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- module DNote
4
- require 'optparse'
5
- require 'dnote'
6
-
7
- def self.run
8
- options = {}
9
- format = 'rdoc'
10
-
11
- opts = OptionParser.new do |opt|
12
-
13
- opt.banner = "Usage: dnote [OPTIONS] path1 [path2 ...]"
14
-
15
- opt.separator(" ")
16
- opt.separator("OUTPUT FORMAT: (choose one)")
17
-
18
- opt.on("--gnu", "Plain text format (default)") do
19
- options[:format] = 'gnu'
20
- end
21
-
22
- opt.on("--rdoc", "RDoc comment format") do
23
- options[:format] = 'rdoc'
24
- end
25
-
26
- opt.on("--markdown", "Markdown wiki format") do
27
- options[:format] = 'markdown'
28
- end
29
-
30
- opt.on("--soap", "SOAP XML envelope format") do
31
- options[:format] = 'soap'
32
- end
33
-
34
- opt.on("--xoxo", "XOXO microformat format") do
35
- options[:format] = 'xoxo'
36
- end
37
-
38
- opt.on("--xml", "XML markup format") do
39
- options[:format] = 'xml'
40
- end
41
-
42
- opt.on("--html", "HTML markup format") do
43
- options[:format] = 'html'
44
- end
45
-
46
- opt.on("--yaml", "YAML serialization format") do
47
- options[:format] = 'yaml'
48
- end
49
-
50
- opt.on("--json", "JSON serialization format") do
51
- options[:format] = 'json'
52
- end
53
-
54
- opt.on("--template", "-t FILE", "Use a custom Erb template") do |file|
55
- options[:format] = 'custom'
56
- options[:template] = file
57
- end
58
-
59
- opt.separator(" ")
60
- opt.separator("OTHER OPTIONS:")
61
-
62
- opt.on("--label", "labels to collect") do |lbl|
63
- options[:labels] ||= []
64
- options[:labels] << lbl
65
- end
66
-
67
- opt.on("--title", "-t [TITLE]", "title to use in headers") do |title|
68
- options[:title] = title
69
- end
70
-
71
- opt.on("--output", "-o [PATH]", "name of file or directory") do |path|
72
- options[:output] = path
73
- end
74
-
75
- opt.separator(" ")
76
- opt.separator("STANDARD OPTIONS:")
77
-
78
- #opt.on("--verbose", "-v", "extra verbose output") do
79
- # options[:verbose] = true
80
- #end
81
-
82
- opt.on("--debug", "debug mode") do
83
- $DEBUG = true
84
- end
85
-
86
- #opt.on("--quiet", "-q", "surpress non-essential output") do
87
- # options[:quiet] = true
88
- #end
89
-
90
- #opt.on("--noharm", "-n", "only pretend to write to disk") do
91
- # options[:noharm] = true
92
- #end
93
-
94
- opt.on("--dryrun", "-n", "do not actually write to disk") do
95
- options[:dryrun] = true
96
- end
97
-
98
- #opt.on("--trace", "debug and verbose modes combined") do
99
- # $DEBUG = true
100
- # options[:verbose] = true
101
- #end
102
-
103
- opt.on_tail('--help', '-h', "show this help information") do
104
- puts opt
105
- exit
106
- end
107
-
108
- end
109
-
110
- begin
111
- opts.parse!
112
- rescue => err
113
- puts err
114
- exit 1
115
- end
116
-
117
- paths = ARGV.dup
118
- paths = ['**/*.rb'] if paths.empty?
119
-
120
- notes = Notes.new(paths, options[:labels])
121
- format = Format.new(notes, options)
122
- format.render
123
-
124
- # NOTE: If DNote were a class.
125
-
126
- #if output
127
- # dnote.save(format, output)
128
- #else
129
- # dnote.display(format)
130
- #end
131
- end
132
-
133
- end
134
-
@@ -1,140 +0,0 @@
1
- module DNote
2
-
3
- require 'dnote/notes'
4
-
5
- # Site class is used to build a "pretty" output set.
6
- # The template files are saved to the +output+ directory.
7
- # Additional +formats+ can be saved to the directory
8
- # as well.
9
-
10
- class Site
11
-
12
- # Default output directory is +log/dnote/+.
13
- DEFAULT_OUTPUT = Pathname.new('log/dnote')
14
-
15
- # Title to use in any headers.
16
- attr_accessor :title
17
-
18
- # Directory to save output.
19
- attr_accessor :output
20
-
21
- # Additional Formats to supply besides the html (xml, rdoc, markdown, etc.)
22
- attr_accessor :formats
23
-
24
- # Notes object.
25
- attr_reader :notes
26
-
27
- def initialize(paths, options)
28
- initialize_defaults
29
-
30
- self.title = options[:title] if options[:title]
31
-
32
- self.output = options.delete(:output) if options[:output]
33
- self.formats = options.delete(:formats) if options[:formats]
34
-
35
- @notes = Notes.new(paths, options)
36
- end
37
-
38
- #
39
- def initialize_defaults
40
- @output = DEFAULT_OUTPUT
41
- @title = "Development Notes"
42
- @formats = ['html']
43
- end
44
-
45
- #
46
- def output=(path)
47
- raise "output cannot be root" if File.expand_path(path) == "/"
48
- @output = Pathname.new(path)
49
- end
50
-
51
- #
52
- def document
53
- fu.mkdir_p(output)
54
-
55
- # produce requested additional formats
56
- formats.each do |format|
57
- =begin
58
- tdir = tempdir(format)
59
-
60
- # copy non-erb files
61
- files = Dir.entries(tdir) - ['.', '..']
62
- files = files.reject{ |file| File.extname(file) == '.erb' }
63
- files.each do |file|
64
- dest = File.dirname(file).sub(tdir, '')
65
- fu.cp_r(File.join(tdir, file), output)
66
- end
67
-
68
- # write the erb templates
69
- templates(format).each do |temp|
70
- file = File.join(tdir, temp)
71
- erb = ERB.new(File.read(file))
72
- text = erb.result(binding)
73
- write(temp.chomp('.erb'), text)
74
- end
75
- =end
76
- text = notes.to(format)
77
- write("notes.#{format}", text)
78
- end
79
- end
80
-
81
- # Reset output directory, marking it as out-of-date.
82
- def reset
83
- if File.directory?(output)
84
- File.utime(0,0,output) unless $NOOP
85
- puts "marked #{output}"
86
- end
87
- end
88
-
89
- # Remove output directory.
90
- def clean
91
- if File.directory?(output)
92
- fu.rm_r(output)
93
- puts "removed #{output}"
94
- end
95
- end
96
-
97
- #
98
- tempdir(format)
99
- "#{__DIR__}/templates/#{format}"
100
- end
101
-
102
- # TODO: Don't use chdir.
103
- def templates(format)
104
- temps = []
105
- Dir.chdir(tempdir(format)) do
106
- temps = Dir['**/*.erb']
107
- end
108
- temps
109
- end
110
-
111
- # Save file to output.
112
- #
113
- def write(fname, text)
114
- file = output + fname
115
- fu.mkdir_p(file.parent)
116
- File.open(file, 'w') { |f| f << text } unless $NOOP
117
- end
118
-
119
- def __DIR__
120
- File.dirname(__FILE__)
121
- end
122
-
123
- #
124
- def fu
125
- @fu ||= (
126
- if $NOOP and $DEBUG
127
- FileUtils::DryRun
128
- elsif $NOOP
129
- FileUtils::Noop
130
- elsif $DEBUG
131
- FileUtils::Verbose
132
- else
133
- FileUtils
134
- end
135
- )
136
- end
137
-
138
- end
139
-
140
- end
@@ -1,8 +0,0 @@
1
- <%= title %>
2
-
3
- <% notes.each do |label, per_file| %>
4
- <%= label %>:
5
- <% per_file.each do |file, line_notes| %>
6
- <% line_notes.sort!{ |a,b| a[0] <=> b[0] } %><% line_notes.each do |line, note| %>
7
- <%= note.indent(10).sub(' ' * 10,' * ') %> (<%= file %>:<%= line %>)
8
- <% end; end; end %>
@@ -1,17 +0,0 @@
1
- <%= title %>
2
-
3
- <%= '=' * title.size %>
4
-
5
- <% notes.each do |label, per_file| %>
6
-
7
- <%= label %>
8
- <%= '-' * (label.size) %>
9
-
10
- <% per_file.each do |file, line_notes| %>
11
-
12
- ### file://<%= file %>
13
-
14
- <% line_notes.sort!{ |a,b| a[0] <=> b[0] } %><% line_notes.each do |line, note| %>
15
- * <%= note %> (<%= line %>)
16
- <% end; end; end %>
17
-