ronn-ng 0.7.4 → 0.8.0.SNAPSHOT

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +12 -3
  3. data/Gemfile +2 -0
  4. data/INSTALLING.md +100 -0
  5. data/README.md +19 -1
  6. data/Rakefile +39 -49
  7. data/bin/ronn +93 -75
  8. data/completion/bash/ronn +32 -0
  9. data/completion/zsh/_ronn +24 -0
  10. data/config.ru +3 -3
  11. data/lib/ronn/document.rb +127 -106
  12. data/lib/ronn/index.rb +8 -9
  13. data/lib/ronn/roff.rb +153 -76
  14. data/lib/ronn/server.rb +19 -22
  15. data/lib/ronn/template.rb +27 -26
  16. data/lib/ronn/utils.rb +9 -7
  17. data/lib/ronn.rb +5 -3
  18. data/man/ronn-format.7 +6 -62
  19. data/man/ronn.1 +21 -123
  20. data/man/ronn.1.ronn +8 -0
  21. data/ronn-ng.gemspec +38 -13
  22. data/test/angle_bracket_syntax.html +4 -5
  23. data/test/backticks.html +14 -0
  24. data/test/backticks.ronn +10 -0
  25. data/test/basic_document.html +3 -4
  26. data/test/basic_document.ronn +2 -2
  27. data/test/circumflexes.ronn +1 -0
  28. data/test/code_blocks.7.ronn +41 -0
  29. data/test/contest.rb +56 -54
  30. data/test/custom_title_document.html +2 -2
  31. data/test/definition_list_syntax.html +13 -9
  32. data/test/definition_list_syntax.roff +2 -9
  33. data/test/definition_list_syntax.ronn +2 -2
  34. data/test/dots_at_line_start_test.roff +12 -3
  35. data/test/dots_at_line_start_test.ronn +8 -0
  36. data/test/ellipses.roff +7 -0
  37. data/test/ellipses.ronn +7 -0
  38. data/test/entity_encoding_test.html +13 -14
  39. data/test/entity_encoding_test.roff +1 -22
  40. data/test/entity_encoding_test.ronn +1 -1
  41. data/test/markdown_syntax.html +4 -5
  42. data/test/markdown_syntax.roff +1 -561
  43. data/test/middle_paragraph.html +2 -3
  44. data/test/middle_paragraph.roff +1 -5
  45. data/test/middle_paragraph.ronn +1 -1
  46. data/test/missing_spaces.roff +0 -2
  47. data/test/nested_list.ronn +19 -0
  48. data/test/nested_list_with_code.html +15 -0
  49. data/test/nested_list_with_code.roff +11 -0
  50. data/test/nested_list_with_code.ronn +6 -0
  51. data/test/page.with.periods.in.name.5.ronn +4 -0
  52. data/test/pre_block_with_quotes.roff +0 -5
  53. data/test/section_reference_links.html +2 -3
  54. data/test/section_reference_links.roff +1 -4
  55. data/test/section_reference_links.ronn +1 -1
  56. data/test/tables.ronn +24 -0
  57. data/test/test_ronn.rb +49 -35
  58. data/test/test_ronn_document.rb +81 -81
  59. data/test/test_ronn_index.rb +11 -11
  60. data/test/titleless_document.html +0 -1
  61. data/test/underline_spacing_test.roff +0 -8
  62. metadata +140 -22
  63. data/INSTALLING +0 -20
@@ -1,9 +1,9 @@
1
1
  <div class='mp'>
2
+
2
3
  <h2 id="NAME">NAME</h2>
3
4
  <p class="man-name">
4
- <code>test</code> - <span class="man-whatis">just a ron test</span>
5
+ <code>test</code> - <span class="man-whatis">just a ronn test</span>
5
6
  </p>
6
-
7
7
  <h2 id="TEST">TEST</h2>
8
8
 
9
9
  <p>Foo</p>
@@ -11,5 +11,4 @@
11
11
  <p>Always use <code>attr_reader</code>, <code>attr_writer</code> or <code>attr_accessor</code>. Do not use <code>for...in</code>; use each instead. Do not use <code>and</code>/<code>or</code>; use <code>&amp;&amp;</code>/<code>||</code> instead.</p>
12
12
 
13
13
  <p>Bar</p>
14
-
15
14
  </div>
@@ -1,13 +1,9 @@
1
1
  .TH "TEST" "1" "January 1979" "" ""
2
- .
3
2
  .SH "NAME"
4
- \fBtest\fR \- just a ron test
5
- .
3
+ \fBtest\fR \- just a ronn test
6
4
  .SH "TEST"
7
5
  Foo
8
- .
9
6
  .P
10
7
  Always use \fBattr_reader\fR, \fBattr_writer\fR or \fBattr_accessor\fR\. Do not use \fBfor\|\.\|\.\|\.in\fR; use each instead\. Do not use \fBand\fR/\fBor\fR; use \fB&&\fR/\fB||\fR instead\.
11
- .
12
8
  .P
13
9
  Bar
@@ -1,4 +1,4 @@
1
- test(1) -- just a ron test
1
+ test(1) -- just a ronn test
2
2
  ==========================
3
3
 
4
4
  ## TEST
@@ -1,8 +1,6 @@
1
1
  .TH "MISSING_SPACES" "" "January 1979" "" ""
2
- .
3
2
  .SH "NAME"
4
3
  \fBmissing_spaces\fR
5
- .
6
4
  .TP
7
5
  \fB\-S\fR \fItext\fR, \fBsearch\fR \fItext\fR
8
6
  Performs a substring search of formula names for \fItext\fR\.
@@ -0,0 +1,19 @@
1
+ nested_list test
2
+ ================
3
+
4
+ ## TEST
5
+
6
+ * foo:
7
+ Blablabla.
8
+
9
+ * bar:
10
+ Blablabla.
11
+
12
+ - bar-foo:
13
+ Bububu.
14
+
15
+ - bar-baz:
16
+ Bububu.
17
+
18
+ * baz:
19
+ Blablabla.
@@ -0,0 +1,15 @@
1
+ <div class='mp'>
2
+
3
+ <h1 id="a-1-">a(1)</h1>
4
+ <ul>
5
+ <li>
6
+ <code>toggle_status</code>
7
+
8
+ <ul>
9
+ <li>Toggle the display of the status bar.</li>
10
+ </ul>
11
+ </li>
12
+ <li>
13
+ <code>spawn &lt;executable&gt; &lt;additional args&gt;</code> TODO explain path-alike expansion</li>
14
+ </ul>
15
+ </div>
@@ -0,0 +1,11 @@
1
+ .TH "NESTED_LIST_WITH_CODE" "" "January 1979" "" ""
2
+ .IP "\[ci]" 4
3
+ \fBtoggle_status\fR
4
+ .IP "\[ci]" 4
5
+ Toggle the display of the status bar\.
6
+ .IP "" 0
7
+
8
+ .IP "\[ci]" 4
9
+ \fBspawn <executable> <additional args>\fR TODO explain path\-alike expansion
10
+ .IP "" 0
11
+
@@ -0,0 +1,6 @@
1
+ a(1)
2
+ ====
3
+
4
+ * `toggle_status`
5
+ - Toggle the display of the status bar.
6
+ * `spawn <executable> <additional args>` TODO explain path-alike expansion
@@ -0,0 +1,4 @@
1
+ Example
2
+ =======
3
+
4
+ Hello, world!
@@ -1,13 +1,8 @@
1
1
  .TH "T" "1" "January 1979" "" ""
2
- .
3
2
  .SH "NAME"
4
3
  \fBt\fR \- test
5
- .
6
4
  .SH "test"
7
- .
8
5
  .nf
9
-
10
6
  [ "$11" ]
11
- .
12
7
  .fi
13
8
 
@@ -1,9 +1,9 @@
1
1
  <div class='mp'>
2
+
2
3
  <h2 id="NAME">NAME</h2>
3
4
  <p class="man-name">
4
5
  <code>section_reference_links</code> - <span class="man-whatis">linking to sections</span>
5
6
  </p>
6
-
7
7
  <h2 id="SECTION-1">SECTION 1</h2>
8
8
 
9
9
  <p>See the following section.</p>
@@ -12,6 +12,5 @@
12
12
 
13
13
  <p>See <a href="#SECTION-1" title="SECTION 1" data-bare-link="true">SECTION 1</a>
14
14
  or <a href="#SECTION-1" title="SECTION 1" data-bare-link="true">to put it another way</a>
15
- or even <a href="#SECTION-1" data-bare-link="true">link this</a></p>
16
-
15
+ or even <a href="#SECTION-1" data-bare-link="true">like this</a></p>
17
16
  </div>
@@ -1,10 +1,7 @@
1
1
  .TH "SECTION_REFERENCE_LINKS" "1" "January 1979" "" ""
2
- .
3
2
  .SH "NAME"
4
3
  \fBsection_reference_links\fR \- linking to sections
5
- .
6
4
  .SH "SECTION 1"
7
5
  See the following section\.
8
- .
9
6
  .SH "SECTION 2"
10
- See \fISECTION 1\fR or \fIto put it another way\fR or even \fIlink this\fR
7
+ See \fISECTION 1\fR or \fIto put it another way\fR or even \fIlike this\fR
@@ -9,4 +9,4 @@ See the following section.
9
9
 
10
10
  See [SECTION 1][]
11
11
  or [to put it another way][SECTION 1]
12
- or even [link this](#SECTION-1)
12
+ or even [like this](#SECTION-1)
data/test/tables.ronn ADDED
@@ -0,0 +1,24 @@
1
+ Hello, world with tables
2
+ ========================
3
+
4
+
5
+ ## Simple table
6
+
7
+ | Syntax | Description |
8
+ | ----------- | ----------- |
9
+ | Header | Title |
10
+ | Paragraph | Text |
11
+
12
+ ## Table with column alignment
13
+
14
+ | Syntax | Description | Test Text With A Long Header Name |
15
+ | :--- | :----: | ---: |
16
+ | Header | Title | Here's this |
17
+ | Paragraph | Text | And more |
18
+
19
+ ## Table with embedded markup
20
+
21
+ | Header |
22
+ | ------ |
23
+ | Code: `some code` |
24
+ | Emphasis: *foo* and *bar* |
data/test/test_ronn.rb CHANGED
@@ -4,69 +4,77 @@ class RonnTest < Test::Unit::TestCase
4
4
  testdir = File.dirname(__FILE__)
5
5
 
6
6
  # setup PATH so that we execute the right ronn command
7
- bindir = File.dirname(testdir) + "/bin"
7
+ bindir = File.dirname(testdir) + '/bin'
8
8
  ENV['PATH'] = "#{bindir}:#{ENV['PATH']}"
9
9
 
10
10
  # make sure the load path is setup correctly
11
11
  libdir = File.expand_path("#{testdir}/../lib")
12
- $:.unshift(libdir) unless $:.any? { |path| File.expand_path(path) == libdir }
13
- ENV['RUBYLIB'] = $:.join(':')
12
+ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.any? { |path| File.expand_path(path) == libdir }
13
+ ENV['RUBYLIB'] = $LOAD_PATH.join(':')
14
14
 
15
15
  require 'ronn'
16
16
 
17
- test "takes ronn text on stdin and produces roff on stdout" do
17
+ test 'takes ronn text on stdin and produces roff on stdout' do
18
18
  output = `echo '# hello(1) -- hello world' | ronn --date=2009-11-23`
19
19
  lines = output.split("\n")
20
- assert_equal 7, lines.size
21
- assert_equal %[.\\" generated with Ronn-NG/v#{Ronn::version}], lines.shift
22
- assert_equal %[.\\" http://github.com/apjanke/ronn-ng/tree/#{Ronn::revision}], lines.shift
23
- assert_equal %[.], lines.shift
24
- assert_equal %[.TH "HELLO" "1" "November 2009" "" ""], lines.shift
25
- assert_equal %[.], lines.shift
26
- assert_equal %[.SH "NAME"], lines.shift
27
- assert_equal %[\\fBhello\\fR \\- hello world], lines.shift
20
+ assert_equal 5, lines.size
21
+ assert_equal %(.\\" generated with Ronn-NG/v#{Ronn.version}), lines.shift
22
+ assert_equal %(.\\" http://github.com/apjanke/ronn-ng/tree/#{Ronn.revision}), lines.shift
23
+ assert_equal %(.TH "HELLO" "1" "November 2009" "" ""), lines.shift
24
+ assert_equal %(.SH "NAME"), lines.shift
25
+ assert_equal %(\\fBhello\\fR \\- hello world), lines.shift
28
26
  assert_equal 0, lines.size
29
27
  end
30
28
 
31
29
  def canonicalize(text)
32
- text.
33
- gsub(/^ +/, '').
34
- gsub(/\n/m, '').
35
- gsub(/ +/, ' ').
36
- gsub(/"/, "'")
30
+ text
31
+ .gsub(/^ +/, '')
32
+ .gsub(/\n/m, '')
33
+ .gsub(/ +/, ' ')
34
+ .tr('"', "'")
37
35
  end
38
36
 
39
- test "produces html instead of roff with the --html argument" do
37
+ def flunk_with_diff(dest, wrong, output)
38
+ File.open(wrong, 'wb') { |f| f.write(output) }
39
+ if ENV['RONN_QUIET_TEST'] == '1'
40
+ flunk 'Output did not match expected.'
41
+ else
42
+ diff = `diff -u #{dest} #{wrong} 2>/dev/null`
43
+ flunk diff
44
+ end
45
+ end
46
+
47
+ test 'produces html instead of roff with the --html argument' do
40
48
  output = `echo '# hello(1) -- hello world' | ronn --html`
41
49
  output = canonicalize(output)
42
50
  assert_match(/<h2 id='NAME'>NAME<\/h2>/, output)
43
- advertising = "<meta name='generator' content='Ronn-NG/v" + Ronn::version +
44
- " (http://github.com/apjanke/ronn-ng/tree/" + Ronn::revision + ")'>"
51
+ advertising = "<meta name='generator' content='Ronn-NG/v" + Ronn.version +
52
+ ' (http://github.com/apjanke/ronn-ng/tree/' + Ronn.revision + ")'>"
45
53
  assert_match(/#{Regexp.escape(advertising)}/, output)
46
54
  end
47
55
 
48
- test "produces html fragment with the --fragment argument" do
56
+ test 'produces html fragment with the --fragment argument' do
49
57
  output = `echo '# hello(1) -- hello world' | ronn --fragment`
50
58
  assert_equal [
51
59
  "<div class='mp'>",
52
60
  "<h2 id='NAME'>NAME</h2>",
53
61
  "<p class='man-name'><code>hello</code>",
54
62
  " - <span class='man-whatis'>hello world</span>",
55
- "</p></div>"
63
+ '</p></div>'
56
64
  ].join, canonicalize(output)
57
65
  end
58
66
 
59
- test "abides by the RONN_MANUAL environment variable" do
67
+ test 'abides by the RONN_MANUAL environment variable' do
60
68
  output = `echo '# hello(1) -- hello world' | RONN_MANUAL='Some Manual' ronn --html`
61
69
  assert_match(/Some Manual/, output)
62
70
  end
63
71
 
64
- test "abides by the RONN_DATE environment variable" do
72
+ test 'abides by the RONN_DATE environment variable' do
65
73
  output = `echo '# hello(1) -- hello world' | RONN_DATE=1979-01-01 ronn --html`
66
74
  assert_match(/January 1979/, output)
67
75
  end
68
76
 
69
- test "abides by the RONN_ORGANIZATION environment variable" do
77
+ test 'abides by the RONN_ORGANIZATION environment variable' do
70
78
  output = `echo '# hello(1) -- hello world' | RONN_ORGANIZATION='GitHub' ronn --html`
71
79
  assert_match(/GitHub/, output)
72
80
  end
@@ -75,14 +83,17 @@ class RonnTest < Test::Unit::TestCase
75
83
  Dir[testdir + '/*.ronn'].each do |source|
76
84
  dest = source.sub(/ronn$/, 'html')
77
85
  next unless File.exist?(dest)
86
+
78
87
  wrong = dest + '.wrong'
79
88
  test File.basename(source, '.ronn') + ' HTML' do
80
89
  output = `ronn --pipe --html --fragment #{source}`
81
- expected = File.read(dest) rescue ''
90
+ expected = begin
91
+ File.read(dest)
92
+ rescue IOError
93
+ ''
94
+ end
82
95
  if expected != output
83
- File.open(wrong, 'wb') { |f| f.write(output) }
84
- diff = `diff -u #{dest} #{wrong} 2>/dev/null`
85
- flunk diff
96
+ flunk_with_diff(dest, wrong, output)
86
97
  elsif File.exist?(wrong)
87
98
  File.unlink(wrong)
88
99
  end
@@ -93,15 +104,18 @@ class RonnTest < Test::Unit::TestCase
93
104
  Dir[testdir + '/*.ronn'].each do |source|
94
105
  dest = source.sub(/ronn$/, 'roff')
95
106
  next unless File.exist?(dest)
107
+
96
108
  wrong = dest + '.wrong'
97
109
  test File.basename(source, '.ronn') + ' roff' do
98
- output = `ronn --pipe --roff --date=1979-01-01 #{source}`.
99
- split("\n", 4).last # remove ronn version comments
100
- expected = File.read(dest) rescue ''
110
+ output = `ronn --pipe --roff --date=1979-01-01 #{source}`
111
+ .split("\n", 3).last # remove ronn version comments
112
+ expected = begin
113
+ File.read(dest)
114
+ rescue IOError
115
+ ''
116
+ end
101
117
  if expected != output
102
- File.open(wrong, 'wb') { |f| f.write(output) }
103
- diff = `diff -u #{dest} #{wrong} 2>/dev/null`
104
- flunk diff
118
+ flunk_with_diff(dest, wrong, output)
105
119
  elsif File.exist?(wrong)
106
120
  File.unlink(wrong)
107
121
  end
@@ -2,43 +2,43 @@ require 'contest'
2
2
  require 'ronn/document'
3
3
 
4
4
  class DocumentTest < Test::Unit::TestCase
5
- SIMPLE_FILE = "#{File.dirname(__FILE__)}/basic_document.ronn"
5
+ SIMPLE_FILE = "#{File.dirname(__FILE__)}/basic_document.ronn".freeze
6
6
 
7
7
  def canonicalize(text)
8
- text.
9
- gsub(/^ +/, '').
10
- gsub(/\n/m, '').
11
- gsub(/ +/, ' ').
12
- gsub(/"/, "'")
8
+ text
9
+ .gsub(/^ +/, '')
10
+ .gsub(/\n/m, '')
11
+ .gsub(/ +/, ' ')
12
+ .tr('"', "'")
13
13
  end
14
14
 
15
- test "new with path" do
15
+ test 'new with path' do
16
16
  doc = Ronn::Document.new(SIMPLE_FILE)
17
17
  assert_equal File.read(SIMPLE_FILE), doc.data
18
18
  end
19
19
 
20
- test "new with path and block" do
21
- doc = Ronn::Document.new('hello.1.ronn') { "# hello(1) -- hello world" }
22
- assert_equal "# hello(1) -- hello world", doc.data
20
+ test 'new with path and block' do
21
+ doc = Ronn::Document.new('hello.1.ronn') { '# hello(1) -- hello world' }
22
+ assert_equal '# hello(1) -- hello world', doc.data
23
23
  end
24
24
 
25
- test "new with path and block but missing name section" do
25
+ test 'new with path and block but missing name section' do
26
26
  doc = Ronn::Document.new('foo.7.ronn') { '' }
27
27
  assert_equal 'foo', doc.name
28
28
  assert_equal '7', doc.section
29
29
  end
30
30
 
31
- test "new with non conventional path and missing name section" do
31
+ test 'new with non conventional path and missing name section' do
32
32
  doc = Ronn::Document.new('bar.ronn') { '' }
33
33
  assert_equal 'bar', doc.name
34
34
  assert_equal nil, doc.section
35
- assert_equal "./bar.html", doc.path_for('html')
36
- assert_equal "./bar", doc.path_for('roff')
37
- assert_equal "./bar", doc.path_for('')
38
- assert_equal "./bar", doc.path_for(nil)
35
+ assert_equal './bar.html', doc.path_for('html')
36
+ assert_equal './bar', doc.path_for('roff')
37
+ assert_equal './bar', doc.path_for('')
38
+ assert_equal './bar', doc.path_for(nil)
39
39
  end
40
40
 
41
- test "new with path and name section mismatch" do
41
+ test 'new with path and name section mismatch' do
42
42
  doc = Ronn::Document.new('foo/rick.7.ronn') { "# randy(3) -- I'm confused." }
43
43
  assert_equal 'randy', doc.name
44
44
  assert_equal 'rick', doc.path_name
@@ -48,8 +48,8 @@ class DocumentTest < Test::Unit::TestCase
48
48
  assert_equal 'foo/rick.7.bar', doc.path_for(:bar)
49
49
  end
50
50
 
51
- test "new with no path and a name section" do
52
- doc = Ronn::Document.new { "# brandy(5) -- wootderitis" }
51
+ test 'new with no path and a name section' do
52
+ doc = Ronn::Document.new { '# brandy(5) -- wootderitis' }
53
53
  assert_equal nil, doc.path_name
54
54
  assert_equal nil, doc.path_section
55
55
  assert_equal 'brandy', doc.name
@@ -76,111 +76,111 @@ class DocumentTest < Test::Unit::TestCase
76
76
  end
77
77
  end
78
78
 
79
- context "simple conventionally named document" do
79
+ context 'simple conventionally named document' do
80
80
  setup do
81
81
  @now = Time.now
82
- @doc = Ronn::Document.new('hello.1.ronn') { "# hello(1) -- hello world" }
82
+ @doc = Ronn::Document.new('hello.1.ronn') { '# hello(1) -- hello world' }
83
83
  @doc.date = @now
84
84
  end
85
85
 
86
- should "load data" do
87
- assert_equal "# hello(1) -- hello world", @doc.data
86
+ should 'load data' do
87
+ assert_equal '# hello(1) -- hello world', @doc.data
88
88
  end
89
89
 
90
- should "extract the manual page name from the filename or document" do
90
+ should 'extract the manual page name from the filename or document' do
91
91
  assert_equal 'hello', @doc.name
92
92
  end
93
93
 
94
- should "extract the manual page section from the filename or document" do
94
+ should 'extract the manual page section from the filename or document' do
95
95
  assert_equal '1', @doc.section
96
96
  end
97
97
 
98
- should "convert to an HTML fragment with no wrap div" do
99
- assert_equal %[<h2 id='NAME'>NAME</h2><p class='man-name'><code>hello</code> - <span class='man-whatis'>hello world</span></p>],
100
- canonicalize(@doc.to_html_fragment(wrap=nil))
98
+ should 'convert to an HTML fragment with no wrap div' do
99
+ assert_equal %(<h2 id='NAME'>NAME</h2><p class='man-name'><code>hello</code> - <span class='man-whatis'>hello world</span></p>),
100
+ canonicalize(@doc.to_html_fragment(nil))
101
101
  end
102
102
 
103
- should "convert to an HTML fragment with a wrap class" do
104
- assert_equal %[<div class='pm'><h2 id='NAME'>NAME</h2><p class='man-name'><code>hello</code> - <span class='man-whatis'>hello world</span></p></div>],
105
- canonicalize(@doc.to_html_fragment(wrap_class='pm'))
103
+ should 'convert to an HTML fragment with a wrap class' do
104
+ assert_equal %(<div class='pm'><h2 id='NAME'>NAME</h2><p class='man-name'><code>hello</code> - <span class='man-whatis'>hello world</span></p></div>),
105
+ canonicalize(@doc.to_html_fragment('pm'))
106
106
  end
107
107
 
108
- should "convert to HTML with a layout" do
108
+ should 'convert to HTML with a layout' do
109
109
  assert_match %r{^<!DOCTYPE html.*}m, @doc.to_html
110
- assert_match %[<h2 id='NAME'>NAME</h2><p class='man-name'><code>hello</code> - <span class='man-whatis'>hello world</span></p>],
111
- canonicalize(@doc.to_html)
110
+ assert_match %(<h2 id='NAME'>NAME</h2><p class='man-name'><code>hello</code> - <span class='man-whatis'>hello world</span></p>),
111
+ canonicalize(@doc.to_html)
112
112
  end
113
113
 
114
- should "construct a path to related documents" do
115
- assert_equal "./hello.1.html", @doc.path_for(:html)
116
- assert_equal "./hello.1", @doc.path_for(:roff)
117
- assert_equal "./hello.1", @doc.path_for('')
118
- assert_equal "./hello.1", @doc.path_for(nil)
114
+ should 'construct a path to related documents' do
115
+ assert_equal './hello.1.html', @doc.path_for(:html)
116
+ assert_equal './hello.1', @doc.path_for(:roff)
117
+ assert_equal './hello.1', @doc.path_for('')
118
+ assert_equal './hello.1', @doc.path_for(nil)
119
119
  end
120
120
 
121
- test "uses default styles" do
121
+ test 'uses default styles' do
122
122
  assert_equal %w[man], @doc.styles
123
123
  end
124
124
 
125
- test "converting to a hash" do
125
+ test 'converting to a hash' do
126
126
  assert_equal({
127
- "section" => "1",
128
- "name" => "hello",
129
- "date" => @now,
130
- "tagline" => "hello world",
131
- "styles" => ["man"],
132
- "toc" => [["NAME", "NAME"]],
133
- "organization" => nil,
134
- "manual" => nil
135
- }, @doc.to_h)
127
+ 'section' => '1',
128
+ 'name' => 'hello',
129
+ 'date' => @now,
130
+ 'tagline' => 'hello world',
131
+ 'styles' => ['man'],
132
+ 'toc' => [['NAME', 'NAME']],
133
+ 'organization' => nil,
134
+ 'manual' => nil
135
+ }, @doc.to_h)
136
136
  end
137
137
 
138
- test "converting to yaml" do
138
+ test 'converting to yaml' do
139
139
  require 'yaml'
140
140
  assert_equal({
141
- "section" => "1",
142
- "name" => "hello",
143
- "date" => @now,
144
- "tagline" => "hello world",
145
- "styles" => ["man"],
146
- "toc" => [["NAME", "NAME"]],
147
- "organization" => nil,
148
- "manual" => nil
149
- }, YAML.load(@doc.to_yaml))
141
+ 'section' => '1',
142
+ 'name' => 'hello',
143
+ 'date' => @now,
144
+ 'tagline' => 'hello world',
145
+ 'styles' => ['man'],
146
+ 'toc' => [['NAME', 'NAME']],
147
+ 'organization' => nil,
148
+ 'manual' => nil
149
+ }, YAML.load(@doc.to_yaml))
150
150
  end
151
151
 
152
- test "converting to json" do
152
+ test 'converting to json' do
153
153
  require 'json'
154
154
  assert_equal({
155
- "section" => "1",
156
- "name" => "hello",
157
- "date" => @now.iso8601,
158
- "tagline" => "hello world",
159
- "styles" => ["man"],
160
- "toc" => [["NAME", "NAME"]],
161
- "organization" => nil,
162
- "manual" => nil
163
- }, JSON.parse(@doc.to_json))
155
+ 'section' => '1',
156
+ 'name' => 'hello',
157
+ 'date' => @now.iso8601,
158
+ 'tagline' => 'hello world',
159
+ 'styles' => ['man'],
160
+ 'toc' => [['NAME', 'NAME']],
161
+ 'organization' => nil,
162
+ 'manual' => nil
163
+ }, JSON.parse(@doc.to_json))
164
164
  end
165
165
  end
166
166
 
167
167
  test 'extracting toc' do
168
- @doc = Ronn::Document.new(File.expand_path('../markdown_syntax.ronn', __FILE__))
168
+ @doc = Ronn::Document.new(File.expand_path('markdown_syntax.ronn', __dir__))
169
169
  expected = [
170
- ["NAME", "NAME"],
171
- ["SYNOPSIS", "SYNOPSIS"],
172
- ["DESCRIPTION", "DESCRIPTION"],
173
- ["BLOCK-ELEMENTS", "BLOCK ELEMENTS"],
174
- ["SPAN-ELEMENTS", "SPAN ELEMENTS"],
175
- ["MISCELLANEOUS", "MISCELLANEOUS"],
176
- ["AUTHOR", "AUTHOR"],
177
- ["SEE-ALSO", "SEE ALSO"]
170
+ ['NAME', 'NAME'],
171
+ ['SYNOPSIS', 'SYNOPSIS'],
172
+ ['DESCRIPTION', 'DESCRIPTION'],
173
+ ['BLOCK-ELEMENTS', 'BLOCK ELEMENTS'],
174
+ ['SPAN-ELEMENTS', 'SPAN ELEMENTS'],
175
+ ['MISCELLANEOUS', 'MISCELLANEOUS'],
176
+ ['AUTHOR', 'AUTHOR'],
177
+ ['SEE-ALSO', 'SEE ALSO']
178
178
  ]
179
179
  assert_equal expected, @doc.toc
180
180
  end
181
181
 
182
- test "passing a list of styles" do
183
- @doc = Ronn::Document.new('hello.1.ronn', :styles => %w[test boom test]) { '' }
182
+ test 'passing a list of styles' do
183
+ @doc = Ronn::Document.new('hello.1.ronn', styles: %w[test boom test]) { '' }
184
184
  assert_equal %w[man test boom], @doc.styles
185
185
  end
186
186
  end