dnote 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/MANIFEST CHANGED
@@ -9,6 +9,7 @@ lib/dnote/command.rb
9
9
  lib/dnote/format.rb
10
10
  lib/dnote/notes.rb
11
11
  lib/dnote/site.rb
12
+ lib/dnote/string.rb
12
13
  lib/dnote/templates
13
14
  lib/dnote/templates/gnu.erb
14
15
  lib/dnote/templates/html.erb
data/lib/dnote.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module DNote
2
- VERSION = "1.1.1" #:till: VERSION = "<%= version %>"
2
+ VERSION = "1.1.2" #:till: VERSION = "<%= version %>"
3
3
 
4
4
  require 'dnote/notes'
5
5
 
data/lib/dnote/format.rb CHANGED
@@ -12,6 +12,7 @@ module DNote
12
12
  require 'fileutils'
13
13
  require 'erb'
14
14
  require 'rexml/text'
15
+ require 'dnote/string'
15
16
 
16
17
  #DEFAULT_OUTPUT_DIR = "log/dnote"
17
18
 
data/lib/dnote/notes.rb CHANGED
@@ -94,7 +94,11 @@ module DNote
94
94
  text.strip!
95
95
  text = nil
96
96
  else
97
- text << ' ' << line.gsub(/^\s*#\s*/,'')
97
+ if text[-1,1] == "\n"
98
+ text << line.gsub(/^\s*#\s*/,'')
99
+ else
100
+ text << "\n" << line.gsub(/^\s*#\s*/,'')
101
+ end
98
102
  end
99
103
  end
100
104
  end
@@ -0,0 +1,68 @@
1
+ class Xacto
2
+
3
+ # Extensions for String class.
4
+ # These methods are taken directly from Ruby Facets.
5
+ #
6
+ module String
7
+
8
+ # Provides a margin controlled string.
9
+ #
10
+ # x = %Q{
11
+ # | This
12
+ # | is
13
+ # | margin controlled!
14
+ # }.margin
15
+ #
16
+ #
17
+ # NOTE: This may still need a bit of tweaking.
18
+ #
19
+ # CREDIT: Trans
20
+
21
+ def margin(n=0)
22
+ #d = /\A.*\n\s*(.)/.match( self )[1]
23
+ #d = /\A\s*(.)/.match( self)[1] unless d
24
+ d = ((/\A.*\n\s*(.)/.match(self)) ||
25
+ (/\A\s*(.)/.match(self)))[1]
26
+ return '' unless d
27
+ if n == 0
28
+ gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, '')
29
+ else
30
+ gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, ' ' * n)
31
+ end
32
+ end
33
+
34
+ # Preserves relative tabbing.
35
+ # The first non-empty line ends up with n spaces before nonspace.
36
+ #
37
+ # CREDIT: Gavin Sinclair
38
+
39
+ def tabto(n)
40
+ if self =~ /^( *)\S/
41
+ indent(n - $1.length)
42
+ else
43
+ self
44
+ end
45
+ end
46
+
47
+ # Indent left or right by n spaces.
48
+ # (This used to be called #tab and aliased as #indent.)
49
+ #
50
+ # CREDIT: Gavin Sinclair
51
+ # CREDIT: Trans
52
+
53
+ def indent(n)
54
+ if n >= 0
55
+ gsub(/^/, ' ' * n)
56
+ else
57
+ gsub(/^ {0,#{-n}}/, "")
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ class ::String #:nodoc:
64
+ include Xacto::String
65
+ end
66
+
67
+ end
68
+
@@ -4,5 +4,5 @@
4
4
  <%= label %>:
5
5
  <% per_file.each do |file, line_notes| %>
6
6
  <% line_notes.sort!{ |a,b| a[0] <=> b[0] } %><% line_notes.each do |line, note| %>
7
- * <%= note %> (<%= file %>:<%= line %>)
7
+ <%= note.indent(10).sub(' ' * 10,' * ') %> (<%= file %>:<%= line %>)
8
8
  <% end; end; end %>
@@ -1,11 +1,17 @@
1
- # <%= title %><% notes.each do |label, per_file| %>
1
+ <%= title %>
2
+
3
+ <%= '=' * title.size %>
4
+
5
+ <% notes.each do |label, per_file| %>
6
+
7
+ <%= label %>
8
+ <%= '-' * (label.size) %>
2
9
 
3
- ## <%= label %>
4
10
  <% per_file.each do |file, line_notes| %>
5
11
 
6
12
  ### file://<%= file %>
7
13
 
8
14
  <% line_notes.sort!{ |a,b| a[0] <=> b[0] } %><% line_notes.each do |line, note| %>
9
- * <%= note.gsub("\n", ' ') %> (<%= line %>)
15
+ * <%= note %> (<%= line %>)
10
16
  <% end; end; end %>
11
17
 
@@ -6,6 +6,6 @@
6
6
  === file://<%= file %>
7
7
 
8
8
  <% line_notes.sort!{ |a,b| a[0] <=> b[0] } %><% line_notes.each do |line, note| %>
9
- * <%= note.gsub("\n", ' ') %> (<%= line %>)
9
+ * <%= note %> (<%= line %>)
10
10
  <% end; end; end %>
11
11
 
data/meta/version CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnote
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Sawyer
@@ -32,6 +32,7 @@ files:
32
32
  - lib/dnote/format.rb
33
33
  - lib/dnote/notes.rb
34
34
  - lib/dnote/site.rb
35
+ - lib/dnote/string.rb
35
36
  - lib/dnote/templates/gnu.erb
36
37
  - lib/dnote/templates/html.erb
37
38
  - lib/dnote/templates/markdown.erb