ronn-ng 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/AUTHORS +8 -0
  3. data/CHANGES +184 -0
  4. data/INSTALLING +20 -0
  5. data/LICENSE.txt +11 -0
  6. data/README.md +113 -0
  7. data/Rakefile +163 -0
  8. data/bin/ronn +223 -0
  9. data/config.ru +15 -0
  10. data/lib/ronn.rb +50 -0
  11. data/lib/ronn/document.rb +495 -0
  12. data/lib/ronn/index.rb +183 -0
  13. data/lib/ronn/roff.rb +302 -0
  14. data/lib/ronn/server.rb +70 -0
  15. data/lib/ronn/template.rb +171 -0
  16. data/lib/ronn/template/80c.css +6 -0
  17. data/lib/ronn/template/dark.css +18 -0
  18. data/lib/ronn/template/darktoc.css +17 -0
  19. data/lib/ronn/template/default.html +41 -0
  20. data/lib/ronn/template/man.css +100 -0
  21. data/lib/ronn/template/print.css +5 -0
  22. data/lib/ronn/template/screen.css +105 -0
  23. data/lib/ronn/template/toc.css +27 -0
  24. data/lib/ronn/utils.rb +55 -0
  25. data/man/index.html +78 -0
  26. data/man/index.txt +15 -0
  27. data/man/ronn-format.7 +201 -0
  28. data/man/ronn-format.7.ronn +157 -0
  29. data/man/ronn.1 +325 -0
  30. data/man/ronn.1.ronn +306 -0
  31. data/ronn-ng.gemspec +97 -0
  32. data/test/angle_bracket_syntax.html +18 -0
  33. data/test/angle_bracket_syntax.ronn +12 -0
  34. data/test/basic_document.html +9 -0
  35. data/test/basic_document.ronn +4 -0
  36. data/test/contest.rb +68 -0
  37. data/test/custom_title_document.html +6 -0
  38. data/test/custom_title_document.ronn +5 -0
  39. data/test/definition_list_syntax.html +21 -0
  40. data/test/definition_list_syntax.roff +26 -0
  41. data/test/definition_list_syntax.ronn +18 -0
  42. data/test/dots_at_line_start_test.roff +10 -0
  43. data/test/dots_at_line_start_test.ronn +4 -0
  44. data/test/entity_encoding_test.html +35 -0
  45. data/test/entity_encoding_test.roff +61 -0
  46. data/test/entity_encoding_test.ronn +25 -0
  47. data/test/index.txt +8 -0
  48. data/test/markdown_syntax.html +957 -0
  49. data/test/markdown_syntax.roff +1467 -0
  50. data/test/markdown_syntax.ronn +881 -0
  51. data/test/middle_paragraph.html +15 -0
  52. data/test/middle_paragraph.roff +13 -0
  53. data/test/middle_paragraph.ronn +10 -0
  54. data/test/missing_spaces.roff +9 -0
  55. data/test/missing_spaces.ronn +2 -0
  56. data/test/pre_block_with_quotes.roff +13 -0
  57. data/test/pre_block_with_quotes.ronn +6 -0
  58. data/test/section_reference_links.html +17 -0
  59. data/test/section_reference_links.roff +10 -0
  60. data/test/section_reference_links.ronn +12 -0
  61. data/test/test_ronn.rb +110 -0
  62. data/test/test_ronn_document.rb +186 -0
  63. data/test/test_ronn_index.rb +73 -0
  64. data/test/titleless_document.html +10 -0
  65. data/test/titleless_document.ronn +3 -0
  66. data/test/underline_spacing_test.roff +21 -0
  67. data/test/underline_spacing_test.ronn +11 -0
  68. metadata +176 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f3b5bd87ab795aca2c2a93fa2e9fd4546bf0f487e514f08e438f7fc4db8f669a
4
+ data.tar.gz: bac6bfb79ee2a082f0920f96608f644f8573c3dc69d5852ce7ae81cbf3f5c875
5
+ SHA512:
6
+ metadata.gz: 92e0355ea7b2466ed1f31741099dc54b39032bf2a8e89fa7a385a07c329433d034ea893c84bb2e585c8223425b2330350f71332e3181430091627a852288389d
7
+ data.tar.gz: 102c172c8aabd4e942a956bde33697e762803ad63461a4dee7ab032fc3a453126ebba70412b6c7d56a5c02c5d4bae288d072c7a0ee72fa52120178e9c223c5e9
data/AUTHORS ADDED
@@ -0,0 +1,8 @@
1
+ # This is a list of people who have contributed code or ideas to ronn -- for
2
+ # copyright purposes or whatever.
3
+
4
+ Ryan Tomayko <http://github.com/rtomayko>
5
+ Chris Wanstrath <http://github.com/defunkt>
6
+ Suraj N. Kurapati <http://github.com/sunaku>
7
+ Hallison Batista <http://github.com/hallison>
8
+ Andrew Janke <http://github.com/apjanke>
data/CHANGES ADDED
@@ -0,0 +1,184 @@
1
+ Ronn-NG CHANGES
2
+ ===============
3
+
4
+ Version 0.7.4 (2018 sometime)
5
+ -----------------------------
6
+
7
+ * Forked Ronn-NG from original Ronn. (apjanke)
8
+
9
+
10
+ Original Ronn CHANGES
11
+ =====================
12
+
13
+ Version 0.7.3 (2010 June 24)
14
+ ----------------------------
15
+
16
+ * Fixed a major bug in roff output due to overly aggressive doublequote
17
+ escaping. Paragraphs and code blocks were not being displayed if they
18
+ included a double-quote character. (rtomayko, pawelz)
19
+
20
+ Version 0.7.0 (2010 June 21)
21
+ ----------------------------
22
+
23
+ * HTML: Manual references (like 'grep(1)', 'ls(1)', etc.) are now hyperlinked
24
+ based on a set of name -> URL mappings defined in an index.txt file. The index
25
+ may also define links to things that aren't manuals for use in markdown
26
+ reference-style links. See the ronn(1) manual on LINK INDEXES for more
27
+ inforation: <http://rtomayko.github.com/ronn/ronn.1.html#LINK-INDEXES>
28
+ (rtomayko)
29
+
30
+ * ROFF: Fixed a bug where multiple dot characters (.) at the beginning of a
31
+ line were not being escaped properly and were not displayed when viewed
32
+ in the terminal. (rtomayko)
33
+
34
+ * ROFF: Non-breaking space characters (&nbsp;) can now be used to control line
35
+ wrap in roff output. (rtomayko)
36
+
37
+ * ROFF: Named HTML entities like &bull;, &trade;, &copy;, and &mdash; are now
38
+ converted to their roff escaped equivalents. (rtomayko)
39
+
40
+ * An undocumented --markdown format option argument has been added to ronn(1).
41
+ When given, ronn generates a <name>.<section>.markdown file with the
42
+ post-processed markdown text. This is mostly useful for debugging but may be
43
+ useful for converting ronn-format to 100% compatible markdown text.
44
+ (rtomayko)
45
+
46
+ * The ronn(5) manpage is now known as ronn-format(7) (section 5 is limited
47
+ to configuration files and stuff like that historically). The old ronn(7)
48
+ manpage, which was really just the README, has been removed.
49
+ (rtomayko)
50
+
51
+ * Performance improvements. Fixed a few cases where HTML was being reparsed
52
+ needlessly, tuned dom selectors, ... (rtomayko)
53
+
54
+ Version 0.6.6 (2010 June 13)
55
+ ----------------------------
56
+
57
+ Small bug fix release fixes whitespace stripping between adjacent
58
+ inline elements in roff output (adamv, rtomayko)
59
+
60
+ Version 0.6 (2010 June 13)
61
+ --------------------------
62
+
63
+ Features:
64
+
65
+ * HTML: New styling system:
66
+ ronn --style=toc,print program.1.ronn
67
+ ronn -s dark,toc,/path/to/custom.css man/*.ronn
68
+
69
+ The --style (-s) option takes a list of CSS stylesheets to embed into the
70
+ generated HTML. Stylesheets are inserted in the order specified and can use
71
+ the cascade to add or remove visual elements.
72
+
73
+ Ronn ships with a few built in styles: toc, dark, 80c, and print. You can
74
+ insert your own by giving the path or manipulating the RONN_STYLE environment
75
+ variable.
76
+
77
+ See ronn(1) for full details on all of these things (rtomayko)
78
+
79
+ * HTML: It's now possible to generate a Table Of Contents of manpage sections.
80
+ The TOC is disabled by default. To enable it: ronn --style=toc file.ronn
81
+ (sunaku)
82
+
83
+ * HTML: The RONN_LAYOUT environment variable can be used to apply a custom
84
+ mustache layout template:
85
+
86
+ RONN_LAYOUT=mine.mustache ronn man/great-program.1.ronn
87
+
88
+ See lib/ronn/template/default.html for default markup and features
89
+ (defunkt)
90
+
91
+ * HTML: All heading elements include page anchor id attributes to make
92
+ it possible to link to a specific manpage section (sunaku)
93
+
94
+ * HTML: Markdown reference links can be used to refer to sections. To link
95
+ to the SEE ALSO section of the current manpage, use: [SEE ALSO][], or [to
96
+ control the link text][SEE ALSO], or even [use the relative URL](#SEE-ALSO).
97
+ (rtomayko)
98
+
99
+ * HTML: 80 character terminal style: ronn -s 80c file.ronn -- precisely
100
+ emulates a 80c terminal (sunaku)
101
+
102
+ * HTML: Various appearance changes to the default stylesheet: smaller type
103
+ with consistent vertical baseline; darker type for more contrast; em, var,
104
+ and u are italic instead of underline (rtomayko)
105
+
106
+ * HTML: Various print stylesheet tweaks, including hyperlinks and layout
107
+ enhancements (sunaku)
108
+
109
+ * ROFF: ronn --warnings (-w) shows troff warnings on stderr when building
110
+ or viewing manuals. (rtomayko)
111
+
112
+ * ROFF: Ordered lists. (sunaku)
113
+
114
+ * ROFF: URLs for hyperlinks are shown immediately after hyperlink text.
115
+ (sunaku)
116
+
117
+ * The RONN_MANUAL, RONN_ORGANIZATION, and RONN_DATE environment variables
118
+ establish the default values of the --manual, --organization, and --date
119
+ options (rtomayko)
120
+
121
+ Bugs:
122
+
123
+ * ROFF: Don't crash with empty preformatted blocks (sunaku)
124
+
125
+ * ROFF: A whole bunch of weird whitespace related problems in roff output,
126
+ such as the first line of definition lists being indented by two
127
+ characters (rtomayko)
128
+
129
+ * ROFF: All ['".] characters are backslash escaped in roff output. These
130
+ characters are used for various roff macro syntax (rtomayko)
131
+
132
+ Deprecations, Obsoletions:
133
+
134
+ * The ronn(1) command line interface has changed in ways that are not
135
+ backward-compatible with previous versions of ronn. The --build option is
136
+ assumed when one or more .ronn files is given on the command line. Previous
137
+ versions write generated content to standard output with no explicit --build
138
+ options.
139
+
140
+ The default behavior when no files are given remains the same as previous
141
+ versions: ronn source text is read from stdin and roff is written to stdout.
142
+
143
+ See `ronn --help' or the ronn(1) manual for more on command line interface
144
+ changes.
145
+
146
+ (rtomayko, defunkt)
147
+
148
+ * HTML: Ronn no longer uses a specific monospace font-family; the system
149
+ default monospace font is used instead. Use 'ronn --style' to set up a font
150
+ stack (rtomayko)
151
+
152
+ * HTML: The following HTML elements are deprecated and will be removed at some
153
+ point: div#man, div#man ol.man, div#man ol.head, div#man ol.man.
154
+
155
+ The .mp, .man-decor, .man-head, .man-foot, .man-title, and .man-navigation
156
+ classes should be used instead (rtomayko)
157
+
158
+ * The markdown(5) manpage is no longer shipped with the ronn package. It is
159
+ shipped with the latest version of rdiscount, however.
160
+ (rtomayko, sunaku)
161
+
162
+ 0.5 (2010 April 24)
163
+ -------------------
164
+
165
+ * Fixed a bug in roff output where multiple successive newlines were being
166
+ collapsed into a single newline in preformatted output.
167
+
168
+ * Hexadecimal and decimal entity references generated by the Markdown to HTML
169
+ conversion are now properly decoded into normal characters in roff output.
170
+
171
+ * The compatibility shims that allowed the ronn command to be invoked as "ron",
172
+ and the ronn library to be required as "ron", have been removed.
173
+
174
+
175
+ 0.4 (2010 March 08)
176
+ -------------------
177
+
178
+ * Ron has been renamed "Ronn", including the "ronn" command and the "ronn"
179
+ library. Compatibility shims are included in this release but will be removed
180
+ in the next release.
181
+
182
+ * The hpricot library is now used for HTML hackery instead of the nokogiri
183
+ library. The hpricot library is preferred because it doesn't depend on external
184
+ system dependencies.
data/INSTALLING ADDED
@@ -0,0 +1,20 @@
1
+ Ronn is currently distributed mainly as a gem package. Install with rubygems:
2
+
3
+ $ gem install ronn
4
+ $ ronn --help
5
+
6
+ Historical Ronn tarballs available at: <http://github.com/rtomayko/ronn/downloads>
7
+
8
+ $ curl -L http://github.com/rtomayko/ronn/downloads/0.6.6 | tar xvzf -
9
+ $ cd rtomayko-r*
10
+ $ ruby setup.rb
11
+
12
+ The hpricot, mustache, and rdiscount packages are required.
13
+
14
+ $ gem install hpricot mustache rdiscount
15
+
16
+ Hacking? Clone the git repository and put ronn/bin on your PATH:
17
+
18
+ $ git clone git://github.com/apjanke/ronn-ng
19
+ $ PATH=$(pwd)/ronn-ng/bin:$PATH
20
+ $ ronn --help
data/LICENSE.txt ADDED
@@ -0,0 +1,11 @@
1
+ The MIT License
2
+
3
+ Copyright (C) 2009 Ryan Tomayko <tomayko.com/about>
4
+ Copyright (C) 2018 Andrew Janke <apjanke.net>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
+
data/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # Ronn
2
+
3
+ Ronn-NG is a new, currently-maintained fork of the defunct [original Ronn
4
+ project](https://github.com/rtomayko/ronn).
5
+
6
+ Ronn builds manuals. It converts simple, human readable textfiles to roff for
7
+ terminal display, and also to HTML for the web.
8
+
9
+ The source format includes all of Markdown but has a more rigid structure and
10
+ syntax extensions for features commonly found in manpages (definition lists,
11
+ link notation, etc.). The ronn-format(7) manual page defines the format in
12
+ detail.
13
+
14
+ The `*.ronn` files found in the [`man/`][1] directory show off a wide range of
15
+ ronn capabilities:
16
+
17
+ * [ronn(1)](http://rtomayko.github.com/ronn/ronn.1) command -
18
+ [source file](http://github.com/apjanke/ronn-ng/blob/master/man/ronn.1.ronn),
19
+ [roff output](http://github.com/apjanke/ronn-ng/blob/master/man/ronn.1)
20
+
21
+ * [ronn-format(7)](http://rtomayko.github.com/ronn/ronn-format.7) -
22
+ [source file](http://github.com/apjanke/ronn-ng/blob/master/man/ronn-format.7.ronn),
23
+ [roff output](http://github.com/apjanke/ronn-ng/blob/master/man/ronn-format.7)
24
+
25
+ [1]: http://github.com/apjanke/ronn-ng/tree/master/man
26
+
27
+ As an alternative, you might want to check out [pandoc](http://johnmacfarlane.net/pandoc/) which can also convert markdown into roff manual pages.
28
+
29
+ ## Examples
30
+
31
+ Build roff and HTML output files for one or more input files:
32
+
33
+ $ ronn man/ronn.5.ronn
34
+ roff: man/ronn.5
35
+ html: man/ronn.5.html
36
+
37
+ Generate only a standalone HTML version of one or more files:
38
+
39
+ $ ronn --html man/markdown.5.ronn
40
+ html: man/markdown.5.html
41
+
42
+ Build roff versions of all ronn files in a directory:
43
+
44
+ $ ronn --roff man/*.ronn
45
+
46
+ View a ronn file as if it were a manpage without building intermediate files:
47
+
48
+ $ ronn --man man/markdown.5.ronn
49
+
50
+ View roff output with man(1):
51
+
52
+ $ man man/ronn.5
53
+
54
+ The [ronn(1)](http://rtomayko.github.com/ronn/ronn.1) manual page includes
55
+ comprehensive documentation on `ronn` command line options.
56
+
57
+ ## Background
58
+
59
+ Some think Unix manual pages are a poor and outdated form of documentation. I
60
+ disagree:
61
+
62
+ - Manpages follow a well defined structure that's immediately familiar. This
63
+ gives developers a starting point when documenting new tools, libraries, and
64
+ formats.
65
+
66
+ - Manpages get to the point. Because they're written in an inverted style, with
67
+ a SYNOPSIS section followed by additional detail, prose and references to
68
+ other sources of information, manpages provide the best of both cheat sheet
69
+ and reference style documentation.
70
+
71
+ - Historically, manpages use an extremely -- unbelievably -- limited set of
72
+ text formatting capabilities. You get a couple of headings, lists, bold,
73
+ underline and no more. This is a feature.
74
+
75
+ - Although two levels of section hierarchy are technically supported, most
76
+ manpages use only a single level. Unwieldy document hierarchies complicate
77
+ otherwise good documentation. Remember that Feynman covered all of physics
78
+ -- heavenly bodies through QED -- with only two levels of document hierarchy
79
+ (_The Feynman Lectures on Physics_, 1970).
80
+
81
+ - The classical terminal manpage display is typographically well thought out.
82
+ Big bold section headings, justified monospace text, nicely indented
83
+ paragraphs, intelligently aligned definition lists, and an informational
84
+ header and footer.
85
+
86
+ - Manpages have a simple referencing syntax; e.g., sh(1), fork(2), markdown(7).
87
+ HTML versions can use this to generate links between pages.
88
+
89
+ Unfortunately, figuring out how to create a manpage is a fairly tedious process.
90
+ The roff/mandoc/mdoc macro languages are highly extensible, fractured between
91
+ multiple dialects, and include a bunch of device specific stuff irrelevant to
92
+ modern publishing tools.
93
+
94
+
95
+ ## Project Management
96
+
97
+ The project home page is at https://github.com/apjanke/ronn-ng. Bug reports,
98
+ feature requests, and patch submissions are welcome.
99
+
100
+ Ronn-NG was forked from the original Ronn project in 2018 after Ronn
101
+ development had been defunct for a couple years, and Andrew wanted
102
+ some bugs fixed.
103
+
104
+ ## License and Copying
105
+
106
+ MIT License.
107
+
108
+ Ronn is Copyright (C) 2010 [Ryan Tomayko](http://tomayko.com/about).
109
+
110
+ New Ronn-NG material is Copyright (c) 2018 [Andrew Janke](https://apjanke.net)
111
+ and other contributors.
112
+
113
+ See the file LICENSE.txt for information of licensing and distribution.
data/Rakefile ADDED
@@ -0,0 +1,163 @@
1
+ require 'rake/clean'
2
+ require 'date'
3
+
4
+ task :default => :test
5
+
6
+ ROOTDIR = File.expand_path('..', __FILE__).sub(/#{Dir.pwd}(?=\/)/, '.')
7
+ LIBDIR = "#{ROOTDIR}/lib"
8
+ BINDIR = "#{ROOTDIR}/bin"
9
+
10
+ task :environment do
11
+ $LOAD_PATH.unshift ROOTDIR if !$:.include?(ROOTDIR)
12
+ $LOAD_PATH.unshift LIBDIR if !$:.include?(LIBDIR)
13
+ require_library 'hpricot'
14
+ require_library 'rdiscount'
15
+ ENV['RUBYLIB'] = $LOAD_PATH.join(':')
16
+ ENV['PATH'] = "#{BINDIR}:#{ENV['PATH']}"
17
+ end
18
+
19
+ desc 'Run tests'
20
+ task :test => :environment do
21
+ $LOAD_PATH.unshift "#{ROOTDIR}/test"
22
+ Dir['test/test_*.rb'].each { |f| require(f) }
23
+ end
24
+
25
+ desc 'Start the server'
26
+ task :server => :environment do
27
+ if system('type shotgun >/dev/null 2>&1')
28
+ exec "shotgun config.ru"
29
+ else
30
+ require 'ronn/server'
31
+ Ronn::Server.run('man/*.ronn')
32
+ end
33
+ end
34
+
35
+ desc 'Start the server'
36
+ task :server => :environment do
37
+ if system('type shotgun >/dev/null 2>&1')
38
+ exec "shotgun config.ru"
39
+ else
40
+ require 'ronn/server'
41
+ Ronn::Server.run('man/*.ronn')
42
+ end
43
+ end
44
+
45
+ desc 'Build the manual'
46
+ task :man => :environment do
47
+ require 'ronn'
48
+ ENV['RONN_MANUAL'] = "Ronn Manual"
49
+ ENV['RONN_ORGANIZATION'] = "Ronn #{Ronn::revision}"
50
+ sh "ronn -w -s toc -r5 --markdown man/*.ronn"
51
+ end
52
+
53
+ desc 'Publish to github pages'
54
+ task :pages => :man do
55
+ puts '----------------------------------------------'
56
+ puts 'Rebuilding pages ...'
57
+ verbose(false) {
58
+ rm_rf 'pages'
59
+ push_url = `git remote show origin`.grep(/Push.*URL/).first[/git@.*/]
60
+ sh "
61
+ set -e
62
+ git fetch -q origin
63
+ rev=$(git rev-parse origin/gh-pages)
64
+ git clone -q -b gh-pages . pages
65
+ cd pages
66
+ git reset --hard $rev
67
+ rm -f ronn*.html index.html
68
+ cp -rp ../man/ronn*.html ../man/index.txt ../man/index.html ./
69
+ git add -u ronn*.html index.html index.txt
70
+ git commit -m 'rebuild manual'
71
+ git push #{push_url} gh-pages
72
+ ", :verbose => false
73
+ }
74
+ end
75
+
76
+ # PACKAGING ============================================================
77
+
78
+ # Rev Ronn::VERSION
79
+ task :rev do
80
+ rev = ENV['REV'] || `git describe --tags`.chomp
81
+ data = File.read('lib/ronn.rb')
82
+ data.gsub!(/^( *)REV *=.*/, "\\1REV = '#{rev}'")
83
+ File.open('lib/ronn.rb', 'wb') { |fd| fd.write(data) }
84
+ puts "revision: #{rev}"
85
+ puts "version: #{`ruby -Ilib -rronn -e 'puts Ronn::VERSION'`}"
86
+ end
87
+
88
+ require 'rubygems'
89
+ $spec = eval(File.read('ronn-ng.gemspec'))
90
+
91
+ def package(ext='')
92
+ "pkg/ronn-#{$spec.version}" + ext
93
+ end
94
+
95
+ desc 'Build packages'
96
+ task :package => %w[.gem .tar.gz].map { |ext| package(ext) }
97
+
98
+ desc 'Build and install as local gem'
99
+ task :install => package('.gem') do
100
+ sh "gem install #{package('.gem')}"
101
+ end
102
+
103
+ directory 'pkg/'
104
+ CLOBBER.include('pkg')
105
+
106
+ file package('.gem') => %w[pkg/ ronn-ng.gemspec] + $spec.files do |f|
107
+ sh "gem build ronn-ng.gemspec"
108
+ mv File.basename(f.name), f.name
109
+ end
110
+
111
+ file package('.tar.gz') => %w[pkg/] + $spec.files do |f|
112
+ sh <<-SH
113
+ git archive --prefix=ronn-#{source_version}/ --format=tar HEAD |
114
+ gzip > #{f.name}
115
+ SH
116
+ end
117
+
118
+ def source_version
119
+ @source_version ||= `ruby -Ilib -rronn -e 'puts Ronn::VERSION'`.chomp
120
+ end
121
+
122
+ file 'ronn-ng.gemspec' => FileList['{lib,test,bin}/**','Rakefile'] do |f|
123
+ # read spec file and split out manifest section
124
+ spec = File.read(f.name)
125
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
126
+ # replace version and date
127
+ head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
128
+ head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
129
+ # determine file list from git ls-files
130
+ files = `git ls-files`.
131
+ split("\n").
132
+ sort.
133
+ reject{ |file| file =~ /^\./ }.
134
+ reject { |file| file =~ /^doc/ }.
135
+ map{ |file| " #{file}" }.
136
+ join("\n")
137
+ # piece file back together and write...
138
+ manifest = " s.files = %w[\n#{files}\n ]\n"
139
+ spec = [head,manifest,tail].join(" # = MANIFEST =\n")
140
+ File.open(f.name, 'w') { |io| io.write(spec) }
141
+ puts "updated #{f.name}"
142
+ end
143
+
144
+ # Misc ===============================================================
145
+
146
+ def require_library(name)
147
+ require name
148
+ rescue LoadError => boom
149
+ if !defined?(Gem)
150
+ warn "warn: #{boom}. trying again with rubygems."
151
+ require 'rubygems'
152
+ retry
153
+ end
154
+ abort "fatal: the '#{name}' library is required (gem install #{name})"
155
+ end
156
+
157
+ # make .wrong test files right
158
+ task :right do
159
+ Dir['test/*.wrong'].each do |file|
160
+ dest = file.sub(/\.wrong$/, '')
161
+ mv file, dest
162
+ end
163
+ end