ronn 0.4

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.
@@ -0,0 +1,69 @@
1
+ Gem::Specification.new do |s|
2
+ s.specification_version = 2 if s.respond_to? :specification_version=
3
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
+
5
+ s.name = 'ronn'
6
+ s.version = '0.4'
7
+ s.date = '2010-03-08'
8
+
9
+ s.description = "The opposite of roff"
10
+ s.summary = "The opposite of roff"
11
+
12
+ s.authors = ["Ryan Tomayko"]
13
+ s.email = "rtomayko@gmail.com"
14
+
15
+ # = MANIFEST =
16
+ s.files = %w[
17
+ COPYING
18
+ README.md
19
+ Rakefile
20
+ bin/ron
21
+ bin/ronn
22
+ lib/ronn.rb
23
+ lib/ronn/document.rb
24
+ lib/ronn/layout.html
25
+ lib/ronn/roff.rb
26
+ man/markdown.5
27
+ man/markdown.5.ronn
28
+ man/ronn.1
29
+ man/ronn.1.ronn
30
+ man/ronn.5
31
+ man/ronn.5.ronn
32
+ man/ronn.7
33
+ man/ronn.7.ronn
34
+ ronn.gemspec
35
+ test/angle_bracket_syntax.html
36
+ test/angle_bracket_syntax.ronn
37
+ test/basic_document.html
38
+ test/basic_document.ronn
39
+ test/custom_title_document.html
40
+ test/custom_title_document.ronn
41
+ test/definition_list_syntax.html
42
+ test/definition_list_syntax.ronn
43
+ test/document_test.rb
44
+ test/entity_encoding_test.html
45
+ test/entity_encoding_test.roff
46
+ test/entity_encoding_test.ronn
47
+ test/middle_paragraph.html
48
+ test/middle_paragraph.roff
49
+ test/middle_paragraph.ronn
50
+ test/ronn_test.rb
51
+ test/titleless_document.html
52
+ test/titleless_document.ronn
53
+ ]
54
+ # = MANIFEST =
55
+
56
+ s.executables = ['ronn', 'ron']
57
+ s.test_files = s.files.select { |path| path =~ /^test\/.*_test.rb/ }
58
+
59
+ s.extra_rdoc_files = %w[COPYING]
60
+ s.add_dependency 'hpricot', '~> 0.8.2'
61
+ s.add_dependency 'rdiscount', '~> 1.5.8'
62
+ s.add_development_dependency 'contest', '~> 0.1'
63
+
64
+ s.has_rdoc = true
65
+ s.homepage = "http://rtomayko.github.com/ronn/"
66
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ronn"]
67
+ s.require_paths = %w[lib]
68
+ s.rubygems_version = '1.1.1'
69
+ end
@@ -0,0 +1,13 @@
1
+ <h2 id='NAME'>NAME</h2>
2
+ <p><code>angle_bracket_syntax</code> -- angle bracket syntax test</p>
3
+
4
+ <p>A <var>WORD</var> in angle brackets is converted to <var>WORD</var>,</p>
5
+
6
+ <pre><code>except when &lt;WORD> is
7
+ part of a preformatted
8
+ code block,
9
+ </code></pre>
10
+
11
+ <p>or when <code>&lt;WORD></code> is enclosed in backticks.</p>
12
+
13
+ <p>or when <var>WORD</var> has a &lt;dot.> or &lt;foo:colon>.</p>
@@ -0,0 +1,12 @@
1
+ angle_bracket_syntax(5) -- angle bracket syntax test
2
+ ====================================================
3
+
4
+ A <WORD> in angle brackets is converted to <var>WORD</var>,
5
+
6
+ except when <WORD> is
7
+ part of a preformatted
8
+ code block,
9
+
10
+ or when `<WORD>` is enclosed in backticks.
11
+
12
+ or when <WORD> has a <dot.> or <foo:colon>.
@@ -0,0 +1,4 @@
1
+ <h2 id='NAME'>NAME</h2>
2
+ <p><code>simple</code> -- a simple ron example</p>
3
+
4
+ <p>This document created by ron.</p>
@@ -0,0 +1,4 @@
1
+ simple(7) -- a simple ron example
2
+ =================================
3
+
4
+ This document created by ron.
@@ -0,0 +1,4 @@
1
+ <h1>custom_title_document -- This is a custom title</h1>
2
+
3
+ <p>It doesn't define the name or section of this manual page and is
4
+ output as a simple <code>&lt;h1&gt;</code> instead of a <code>NAME</code> section.</p>
@@ -0,0 +1,5 @@
1
+ This is a custom title
2
+ ======================
3
+
4
+ It doesn't define the name or section of this manual page and is
5
+ output as a simple `<h1>` instead of a `NAME` section.
@@ -0,0 +1,16 @@
1
+ <h2 id='NAME'>NAME</h2>
2
+ <p><code>defition_list_syntax</code> -- hiya</p>
3
+
4
+ <p>Definition lists look like unordered lists:</p>
5
+
6
+ <dl>
7
+ <dt class="flush">term</dt><dd><p>definition</p></dd>
8
+ <dt>another one</dt><dd><p>The definition may span
9
+ multiple lines and even</p>
10
+
11
+ <p>start</p>
12
+
13
+ <p>new paragraphs</p></dd>
14
+ <dt><code>--somearg</code>=<var>VALUE</var></dt><dd><p>We can do that too.</p></dd>
15
+ </dl>
16
+
@@ -0,0 +1,18 @@
1
+ defition_list_syntax(5) -- hiya
2
+ ===============================
3
+
4
+ Definition lists look like unordered lists:
5
+
6
+ * term:
7
+ definition
8
+
9
+ * another one:
10
+ The definition may span
11
+ multiple lines and even
12
+
13
+ start
14
+
15
+ new paragraphs
16
+
17
+ * `--somearg`=<VALUE>:
18
+ We can do that too.
@@ -0,0 +1,88 @@
1
+ require 'contest'
2
+ require 'ronn/document'
3
+
4
+ class DocumentTest < Test::Unit::TestCase
5
+ SIMPLE_FILE = "#{File.dirname(__FILE__)}/basic_document.ronn"
6
+
7
+ test "new with path" do
8
+ doc = Ronn::Document.new(SIMPLE_FILE)
9
+ assert_equal File.read(SIMPLE_FILE), doc.data
10
+ end
11
+
12
+ test "new with path and block" do
13
+ doc = Ronn::Document.new('hello.1.ronn') { "# hello(1) -- hello world" }
14
+ assert_equal "# hello(1) -- hello world", doc.data
15
+ end
16
+
17
+ test "new with path and block but missing name section" do
18
+ doc = Ronn::Document.new('foo.7.ronn') { '' }
19
+ assert_equal 'foo', doc.name
20
+ assert_equal '7', doc.section
21
+ end
22
+
23
+ test "new with non conventional path and missing name section" do
24
+ doc = Ronn::Document.new('bar.ronn') { '' }
25
+ assert_equal 'bar', doc.name
26
+ assert_equal nil, doc.section
27
+ assert_equal "./bar.html", doc.path_for('html')
28
+ assert_equal "./bar", doc.path_for('roff')
29
+ assert_equal "./bar", doc.path_for('')
30
+ assert_equal "./bar", doc.path_for(nil)
31
+ end
32
+
33
+ test "new with path and name section mismatch" do
34
+ doc = Ronn::Document.new('foo/rick.7.ronn') { "# randy(3) -- I'm confused." }
35
+ assert_equal 'randy', doc.name
36
+ assert_equal 'rick', doc.path_name
37
+ assert_equal '3', doc.section
38
+ assert_equal '7', doc.path_section
39
+ assert_equal 'rick.7', doc.basename
40
+ assert_equal 'foo/rick.7.bar', doc.path_for(:bar)
41
+ end
42
+
43
+ test "new with no path and a name section" do
44
+ doc = Ronn::Document.new { "# brandy(5) -- wootderitis" }
45
+ assert_equal nil, doc.path_name
46
+ assert_equal nil, doc.path_section
47
+ assert_equal 'brandy', doc.name
48
+ assert_equal '5', doc.section
49
+ assert_equal 'brandy.5', doc.basename
50
+ assert_equal 'brandy.5.foo', doc.path_for(:foo)
51
+ end
52
+
53
+ context "simple conventionally named document" do
54
+ setup do
55
+ @doc = Ronn::Document.new('hello.1.ronn') { "# hello(1) -- hello world" }
56
+ end
57
+
58
+ should "load data" do
59
+ assert_equal "# hello(1) -- hello world", @doc.data
60
+ end
61
+
62
+ should "extract the manual page name from the filename or document" do
63
+ assert_equal 'hello', @doc.name
64
+ end
65
+
66
+ should "extract the manual page section from the filename or document" do
67
+ assert_equal '1', @doc.section
68
+ end
69
+
70
+ should "convert to an HTML fragment" do
71
+ assert_equal %[<h2 id='NAME'>NAME</h2>\n<p><code>hello</code> -- hello world</p>\n],
72
+ @doc.to_html_fragment
73
+ end
74
+
75
+ should "convert to HTML with a layout" do
76
+ assert_match %r{^<!DOCTYPE html.*}m, @doc.to_html
77
+ assert_match %[<h2 id='NAME'>NAME</h2>\n<p><code>hello</code> -- hello world</p>],
78
+ @doc.to_html
79
+ end
80
+
81
+ should "construct a path to related documents" do
82
+ assert_equal "./hello.1.html", @doc.path_for(:html)
83
+ assert_equal "./hello.1", @doc.path_for(:roff)
84
+ assert_equal "./hello.1", @doc.path_for('')
85
+ assert_equal "./hello.1", @doc.path_for(nil)
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,10 @@
1
+ <h2 id='NAME'>NAME</h2>
2
+ <p><code>hello</code> -- hello world</p>
3
+
4
+ <p>Your output &lt;i&gt;might&lt;/i&gt; look like this:</p>
5
+
6
+ <pre><code>* Chris
7
+ *
8
+ * &amp;lt;b&amp;gt;GitHub&amp;lt;/b&amp;gt;
9
+ * &lt;b&gt;GitHub&lt;/b&gt;
10
+ </code></pre>
@@ -0,0 +1,19 @@
1
+ .TH "HELLO" "1" "January 1979" "" ""
2
+ .
3
+ .SH "NAME"
4
+ \fBhello\fR \-\- hello world
5
+ .
6
+ .P
7
+ Your output <i>might</i> look like this:
8
+ .
9
+ .IP "" 4
10
+ .
11
+ .nf
12
+ * Chris
13
+ *
14
+ * &lt;b&gt;GitHub&lt;/b&gt;
15
+ * <b>GitHub</b>
16
+ .
17
+ .fi
18
+ .
19
+ .IP "" 0
@@ -0,0 +1,8 @@
1
+ # hello(1) -- hello world
2
+
3
+ Your output &lt;i&gt;might&lt;/i&gt; look like this:
4
+
5
+ * Chris
6
+ *
7
+ * &lt;b&gt;GitHub&lt;/b&gt;
8
+ * <b>GitHub</b>
@@ -0,0 +1,10 @@
1
+ <h2 id='NAME'>NAME</h2>
2
+ <p><code>test</code> -- just a ron test</p>
3
+
4
+ <h2>TEST</h2>
5
+
6
+ <p>Foo</p>
7
+
8
+ <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>
9
+
10
+ <p>Bar</p>
@@ -0,0 +1,13 @@
1
+ .TH "TEST" "1" "January 1979" "" ""
2
+ .
3
+ .SH "NAME"
4
+ \fBtest\fR \-\- just a ron test
5
+ .
6
+ .SH "TEST"
7
+ Foo
8
+ .
9
+ .P
10
+ 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
+ .P
13
+ Bar
@@ -0,0 +1,10 @@
1
+ test(1) -- just a ron test
2
+ ==========================
3
+
4
+ ## TEST
5
+
6
+ Foo
7
+
8
+ Always use `attr_reader`, `attr_writer` or `attr_accessor`. Do not use `for...in`; use each instead. Do not use `and`/`or`; use `&&`/`||` instead.
9
+
10
+ Bar
@@ -0,0 +1,78 @@
1
+ require 'contest'
2
+
3
+ class RonnTest < Test::Unit::TestCase
4
+ testdir = File.dirname(__FILE__)
5
+
6
+ # setup PATH so that we execute the right ronn command
7
+ bindir = File.dirname(testdir) + "/bin"
8
+ ENV['PATH'] = "#{bindir}:#{ENV['PATH']}"
9
+
10
+ # make sure the load path is setup correctly
11
+ libdir = File.expand_path("#{testdir}/../lib")
12
+ $:.unshift(libdir) unless $:.any? { |path| File.expand_path(path) == libdir }
13
+ ENV['RUBYLIB'] = $:.join(':')
14
+
15
+ require 'ronn'
16
+
17
+ test "takes ronn text on stdin and produces roff on stdout" do
18
+ output = `echo '# hello(1) -- hello world' | ronn --date=2009-11-23`
19
+ lines = output.split("\n")
20
+ assert_equal 7, lines.size
21
+ assert_equal %[.\\" generated with Ronn/v#{Ronn::VERSION}], lines.shift
22
+ assert_equal %[.\\" http://github.com/rtomayko/ronn/], 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
28
+ assert_equal 0, lines.size
29
+ end
30
+
31
+ test "produces html instead of roff with the --html argument" do
32
+ output = `echo '# hello(1) -- hello world' | ronn --html`
33
+ assert_match(/<h2 id='NAME'>NAME<\/h2>/, output)
34
+ end
35
+
36
+ test "produces html fragment with the --fragment argument" do
37
+ output = `echo '# hello(1) -- hello world' | ronn --fragment`
38
+ assert_equal "<h2 id='NAME'>NAME</h2>\n<p><code>hello</code> -- hello world</p>\n",
39
+ output
40
+ end
41
+
42
+ # ronn -> HTML file based tests
43
+ Dir[testdir + '/*.ronn'].each do |source|
44
+ dest = source.sub(/ronn$/, 'html')
45
+ next unless File.exist?(dest)
46
+ wrong = dest + '.wrong'
47
+ test File.basename(source, '.ronn') + ' HTML' do
48
+ output = `ronn --html --fragment #{source}`
49
+ expected = File.read(dest) rescue ''
50
+ if expected != output
51
+ File.open(wrong, 'wb') { |f| f.write(output) }
52
+ diff = `diff -u #{dest} #{wrong} 2>/dev/null`
53
+ flunk diff
54
+ elsif File.exist?(wrong)
55
+ File.unlink(wrong)
56
+ end
57
+ end
58
+ end
59
+
60
+ # ronn -> roff file based tests
61
+ Dir[testdir + '/*.ronn'].each do |source|
62
+ dest = source.sub(/ronn$/, 'roff')
63
+ next unless File.exist?(dest)
64
+ wrong = dest + '.wrong'
65
+ test File.basename(source, '.ronn') + ' roff' do
66
+ output = `ronn --date=1979-01-01 #{source}`.
67
+ split("\n", 4).last # remove ronn version comments
68
+ expected = File.read(dest) rescue ''
69
+ if expected != output
70
+ File.open(wrong, 'wb') { |f| f.write(output) }
71
+ diff = `diff -u #{dest} #{wrong} 2>/dev/null`
72
+ flunk diff
73
+ elsif File.exist?(wrong)
74
+ File.unlink(wrong)
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,2 @@
1
+ <p>This is a document without a level 1 heading. It doesn't output
2
+ a <code>NAME</code> section or custom <code>&lt;h1&gt;</code>.</p>
@@ -0,0 +1,2 @@
1
+ This is a document without a level 1 heading. It doesn't output
2
+ a `NAME` section or custom `<h1>`.
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ronn
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 4
8
+ version: "0.4"
9
+ platform: ruby
10
+ authors:
11
+ - Ryan Tomayko
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2010-03-08 00:00:00 -08:00
17
+ default_executable:
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: hpricot
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ segments:
27
+ - 0
28
+ - 8
29
+ - 2
30
+ version: 0.8.2
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: rdiscount
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 1
42
+ - 5
43
+ - 8
44
+ version: 1.5.8
45
+ type: :runtime
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
48
+ name: contest
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ - 1
57
+ version: "0.1"
58
+ type: :development
59
+ version_requirements: *id003
60
+ description: The opposite of roff
61
+ email: rtomayko@gmail.com
62
+ executables:
63
+ - ronn
64
+ - ron
65
+ extensions: []
66
+
67
+ extra_rdoc_files:
68
+ - COPYING
69
+ files:
70
+ - COPYING
71
+ - README.md
72
+ - Rakefile
73
+ - bin/ron
74
+ - bin/ronn
75
+ - lib/ronn.rb
76
+ - lib/ronn/document.rb
77
+ - lib/ronn/layout.html
78
+ - lib/ronn/roff.rb
79
+ - man/markdown.5
80
+ - man/markdown.5.ronn
81
+ - man/ronn.1
82
+ - man/ronn.1.ronn
83
+ - man/ronn.5
84
+ - man/ronn.5.ronn
85
+ - man/ronn.7
86
+ - man/ronn.7.ronn
87
+ - ronn.gemspec
88
+ - test/angle_bracket_syntax.html
89
+ - test/angle_bracket_syntax.ronn
90
+ - test/basic_document.html
91
+ - test/basic_document.ronn
92
+ - test/custom_title_document.html
93
+ - test/custom_title_document.ronn
94
+ - test/definition_list_syntax.html
95
+ - test/definition_list_syntax.ronn
96
+ - test/document_test.rb
97
+ - test/entity_encoding_test.html
98
+ - test/entity_encoding_test.roff
99
+ - test/entity_encoding_test.ronn
100
+ - test/middle_paragraph.html
101
+ - test/middle_paragraph.roff
102
+ - test/middle_paragraph.ronn
103
+ - test/ronn_test.rb
104
+ - test/titleless_document.html
105
+ - test/titleless_document.ronn
106
+ has_rdoc: true
107
+ homepage: http://rtomayko.github.com/ronn/
108
+ licenses: []
109
+
110
+ post_install_message:
111
+ rdoc_options:
112
+ - --line-numbers
113
+ - --inline-source
114
+ - --title
115
+ - Ronn
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ segments:
123
+ - 0
124
+ version: "0"
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ segments:
130
+ - 0
131
+ version: "0"
132
+ requirements: []
133
+
134
+ rubyforge_project:
135
+ rubygems_version: 1.3.6
136
+ signing_key:
137
+ specification_version: 2
138
+ summary: The opposite of roff
139
+ test_files:
140
+ - test/document_test.rb
141
+ - test/ronn_test.rb