dnote 1.1.1 → 1.1.2
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.
- data/MANIFEST +1 -0
- data/lib/dnote.rb +1 -1
- data/lib/dnote/format.rb +1 -0
- data/lib/dnote/notes.rb +5 -1
- data/lib/dnote/string.rb +68 -0
- data/lib/dnote/templates/gnu.erb +1 -1
- data/lib/dnote/templates/markdown.erb +9 -3
- data/lib/dnote/templates/rdoc.erb +1 -1
- data/meta/version +1 -1
- metadata +2 -1
data/MANIFEST
CHANGED
data/lib/dnote.rb
CHANGED
data/lib/dnote/format.rb
CHANGED
data/lib/dnote/notes.rb
CHANGED
data/lib/dnote/string.rb
ADDED
@@ -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
|
+
|
data/lib/dnote/templates/gnu.erb
CHANGED
@@ -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
|
-
*
|
7
|
+
<%= note.indent(10).sub(' ' * 10,' * ') %> (<%= file %>:<%= line %>)
|
8
8
|
<% end; end; end %>
|
@@ -1,11 +1,17 @@
|
|
1
|
-
|
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
|
15
|
+
* <%= note %> (<%= line %>)
|
10
16
|
<% end; end; end %>
|
11
17
|
|
data/meta/version
CHANGED
@@ -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.
|
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
|