inochi 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/inochi CHANGED
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/ruby -w
2
2
  #
3
- # Progress indicators:
3
+ # Generates a project scaffold using the given information.
4
+ #
5
+ # Existing files are backed up and NOT overwritten. It is your
6
+ # responsibility to merge changes between the existing files and
7
+ # the newly generated files. See the --merge option for details.
8
+ #
9
+ # This tool announces its progress as it runs, using these indicators:
4
10
  #
5
11
  # create: A file is being created because it does not exist.
6
12
  #
@@ -14,7 +20,19 @@
14
20
  #
15
21
  # Usage:
16
22
  #
17
- # inochi [Option...] ModuleName
23
+ # inochi [Options] ProjectName [ProgramName]
24
+ #
25
+ #
26
+ # ProjectName: Name of your project, which will be normalized
27
+ # into the naame of a Ruby module that will serve
28
+ # as a namespace for all code in your project.
29
+ #
30
+ # ProgramName: (Optional) Name of the main project executable,
31
+ # which also serves as the name of the generated
32
+ # project directory and the main project library.
33
+ #
34
+ #
35
+ # Options:
18
36
  #
19
37
 
20
38
  # command line
@@ -63,21 +81,25 @@
63
81
  end
64
82
 
65
83
  # program body
66
- target = ARGV.shift or
67
- raise ArgumentError, "Project was not specified. Run `#{$0} -h` for help."
84
+ project_name, program_name = ARGV
85
+
86
+ unless project_name
87
+ raise ArgumentError, "ProjectName must be given. Run `#{$0} -h` for help."
88
+ end
68
89
 
69
- project = Inochi.calc_project_symbol(target)
70
- program = Inochi.calc_program_name(project)
71
- version = '0.0.0'
72
- release = Time.now.strftime('%F')
90
+ project_symbol = Inochi.calc_project_symbol(project_name)
91
+ program_name ||= Inochi.calc_program_name(project_symbol)
73
92
 
74
- preamble = %{
93
+ project_version = '0.0.0'
94
+ project_release = Time.now.strftime('%F')
95
+
96
+ inochi_preamble = %{
75
97
  require 'rubygems'
76
98
  gem '#{Inochi::PROGRAM}', '#{Inochi::VERSION.requirement}'
77
99
  require '#{Inochi::PROGRAM}'
78
100
  }.strip
79
101
 
80
- create "#{program}/LICENSE", %{
102
+ create "#{program_name}/LICENSE", %{
81
103
  Copyright #{Time.now.year} Your Name <your@email.here>
82
104
 
83
105
  Permission to use, copy, modify, and/or distribute this software for any
@@ -93,10 +115,10 @@
93
115
  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
94
116
  }
95
117
 
96
- create "#{program}/Rakefile", %{
97
- #{preamble}
118
+ create "#{program_name}/Rakefile", %{
119
+ #{inochi_preamble}
98
120
 
99
- Inochi.rake #{project.inspect} do |gem|
121
+ Inochi.rake #{project_symbol.inspect} do |gem|
100
122
  # TODO: additional gem configuration.
101
123
  # NOTE: this is completely optional!
102
124
  #
@@ -105,20 +127,31 @@
105
127
  end
106
128
  }
107
129
 
108
- bin_file = "#{program}/bin/#{program}"
130
+ bin_file = "#{program_name}/bin/#{program_name}"
109
131
  create bin_file, %{
110
132
  #!/usr/bin/ruby -w
111
133
  #
112
134
  # TODO: Explain the command-line usage of this program here.
113
135
  #
136
+ #
114
137
  # Usage:
115
138
  #
116
- # #{program} [Option...] Arg1 Arg2 Arg3...
139
+ # #{program_name} [Options] Param1 Param2 Param3...
140
+ #
141
+ #
142
+ # Param1: Description for the first parameter.
143
+ #
144
+ # Param2: Description for the second parameter.
145
+ #
146
+ # Param3: Description for the third parameter.
147
+ #
148
+ #
149
+ # Options:
117
150
  #
118
151
 
119
- #{preamble}
152
+ #{inochi_preamble}
120
153
 
121
- options = Inochi.main #{project.inspect} do
154
+ options = Inochi.main #{project_symbol.inspect} do
122
155
  # TODO: define command-line options here.
123
156
  # see http://trollop.rubyforge.org/
124
157
  #
@@ -132,14 +165,14 @@
132
165
  }
133
166
  FileUtils.chmod 0755, bin_file
134
167
 
135
- create "#{program}/lib/#{program}.rb", %{
136
- #{preamble}
168
+ create "#{program_name}/lib/#{program_name}.rb", %{
169
+ #{inochi_preamble}
137
170
 
138
- Inochi.init #{project.inspect},
139
- :project => '#{target}',
140
- :version => '#{version}',
141
- :release => '#{release}',
142
- :website => 'http://#{program}.rubyforge.org',
171
+ Inochi.init #{project_symbol.inspect},
172
+ :project => '#{project_name}',
173
+ :version => '#{project_version}',
174
+ :release => '#{project_release}',
175
+ :website => 'http://#{program_name}.rubyforge.org',
143
176
  :tagline => 'TODO: put a single line description of your project here.',
144
177
  :require => {
145
178
  # TODO: list gems required by your project here.
@@ -153,8 +186,23 @@
153
186
  }
154
187
  }
155
188
 
156
- create "#{program}/doc/index.erb", %{
157
- <% Inochi.book #{project.inspect}, self %>
189
+ create "#{program_name}/test/#{program_name}.rb", %{
190
+ describe #{project_symbol} do
191
+ it 'has inochi' do
192
+ assert #{project_symbol}.const_defined? :INOCHI
193
+
194
+ #{project_symbol}::INOCHI.each do |param, value|
195
+ const = param.to_s.upcase
196
+
197
+ assert #{project_symbol}.const_defined? const
198
+ #{project_symbol}.const_get(const).must_equal value
199
+ end
200
+ end
201
+ end
202
+ }
203
+
204
+ create "#{program_name}/doc/index.erb", %{
205
+ <% Inochi.book #{project_symbol.inspect}, self %>
158
206
 
159
207
  <%# include intro.erb #%>
160
208
  <%# include setup.erb #%>
@@ -163,12 +211,12 @@
163
211
  <%# include history.erb #%>
164
212
  }
165
213
 
166
- create "#{program}/doc/intro.erb", %{
214
+ create "#{program_name}/doc/intro.erb", %{
167
215
  <% chapter "Introduction" do %>
168
216
  <% project_summary do %>
169
217
  > TODO: explain the purpose of your project
170
218
 
171
- ****<%= $project %>**** is a __________ that __________.
219
+ **<%= $project %>** is a __________ that __________.
172
220
  <% end %>
173
221
 
174
222
  > TODO: explain why your project is important
@@ -249,15 +297,15 @@
249
297
  <% end %>
250
298
  }
251
299
 
252
- create "#{program}/doc/setup.erb", %{
300
+ create "#{program_name}/doc/setup.erb", %{
253
301
  <% chapter "Setup" do %>
254
302
  <% section "Requirements" do %>
255
303
  Your system needs the following software to run **<%= $project %>**.
256
304
 
257
- | Software | Description | Notes |
258
- | -------- | ----------- | ----- |
259
- | [Ruby](http://ruby-lang.org) | Ruby language interpreter | Version #{RUBY_VERSION} is required. |
260
- | [RubyGems](http://rubygems.org) | Ruby packaging system | Version #{`gem --version`.chomp} is required. |
305
+ | Software | Description | Notes |
306
+ | -------- | ----------- | ----- |
307
+ | [Ruby](http://ruby-lang.org) | Ruby language interpreter | Version #{RUBY_VERSION} is required. |
308
+ | [RubyGems](http://rubygems.org) | Ruby packaging system | Version #{Gem::RubyGemsVersion} is required. |
261
309
  <% end %>
262
310
 
263
311
  <% section "Installation" do %>
@@ -308,13 +356,13 @@
308
356
  <% end %>
309
357
  }
310
358
 
311
- create "#{program}/doc/theory.erb", %{
359
+ create "#{program_name}/doc/theory.erb", %{
312
360
  <% chapter "Theory of operation" do %>
313
361
  > TODO: explain how your project does what it does
314
362
  <% end %>
315
363
  }
316
364
 
317
- create "#{program}/doc/usage.erb", %{
365
+ create "#{program_name}/doc/usage.erb", %{
318
366
  <% chapter "Usage" do %>
319
367
  <% section "Command-line interface" do %>
320
368
  When you run this command:
@@ -323,7 +371,7 @@
323
371
 
324
372
  You will see this output:
325
373
 
326
- <pre><%= verbatim `ruby bin/\#{$program} --help` %></pre>
374
+ <pre><%= verbatim `ruby bin/\#{$program_name} --help` %></pre>
327
375
 
328
376
  > TODO: explain the command-line arguments
329
377
  <% end %>
@@ -343,7 +391,7 @@
343
391
  <% end %>
344
392
  }
345
393
 
346
- create "#{program}/doc/history.erb", %{
394
+ create "#{program_name}/doc/history.erb", %{
347
395
  <% chapter "History" do %>
348
396
  > TODO: put a brief history about your project here
349
397
 
@@ -351,7 +399,7 @@
351
399
  > TODO: put release notes for your project
352
400
  > here -- newest first, oldest last.
353
401
 
354
- <% section "Version #{version} (#{release})" do %>
402
+ <% section "Version #{project_version} (#{project_release})" do %>
355
403
  > TODO: write a short summary of the changes in this release
356
404
 
357
405
  This release changes __________, adds __________, and fixes __________.
@@ -241,48 +241,48 @@ The eRuby template which serves as the documentation for the project.
241
241
  <pre class="lines">
242
242
 
243
243
 
244
- 910
245
- 911
246
- 912
247
- 913
248
- 914
249
- 915
250
- 916
251
- 917
252
- 918
253
- 919
254
- 920
255
- 921
256
- 922
257
- 923
258
- 924
259
- 925
260
- 926
261
- 927
262
- 928
263
- 929
264
- 930
265
- 931
266
- 932
267
- 933
268
- 934
269
- 935
270
- 936
271
- 937
272
- 938
273
- 939
274
- 940
275
- 941
276
- 942
277
- 943
278
- 944
279
- 945
280
- 946
281
- 947
282
- 948</pre>
244
+ 951
245
+ 952
246
+ 953
247
+ 954
248
+ 955
249
+ 956
250
+ 957
251
+ 958
252
+ 959
253
+ 960
254
+ 961
255
+ 962
256
+ 963
257
+ 964
258
+ 965
259
+ 966
260
+ 967
261
+ 968
262
+ 969
263
+ 970
264
+ 971
265
+ 972
266
+ 973
267
+ 974
268
+ 975
269
+ 976
270
+ 977
271
+ 978
272
+ 979
273
+ 980
274
+ 981
275
+ 982
276
+ 983
277
+ 984
278
+ 985
279
+ 986
280
+ 987
281
+ 988
282
+ 989</pre>
283
283
  </td>
284
284
  <td>
285
- <pre class="code"><span class="info file"># File 'lib/inochi/inochi.rb', line 910</span>
285
+ <pre class="code"><span class="info file"># File 'lib/inochi/inochi.rb', line 951</span>
286
286
 
287
287
  <span class='def def kw'>def</span> <span class='book identifier id'>book</span> <span class='project_symbol identifier id'>project_symbol</span><span class='comma token'>,</span> <span class='book_template identifier id'>book_template</span>
288
288
  <span class='project_module identifier id'>project_module</span> <span class='assign token'>=</span> <span class='fetch_project_module identifier id'>fetch_project_module</span><span class='lparen token'>(</span><span class='project_symbol identifier id'>project_symbol</span><span class='rparen token'>)</span>
@@ -361,12 +361,12 @@ project name fully in lowercase.
361
361
  <pre class="lines">
362
362
 
363
363
 
364
- 954
365
- 955
366
- 956</pre>
364
+ 995
365
+ 996
366
+ 997</pre>
367
367
  </td>
368
368
  <td>
369
- <pre class="code"><span class="info file"># File 'lib/inochi/inochi.rb', line 954</span>
369
+ <pre class="code"><span class="info file"># File 'lib/inochi/inochi.rb', line 995</span>
370
370
 
371
371
  <span class='def def kw'>def</span> <span class='calc_program_name identifier id'>calc_program_name</span> <span class='project_symbol identifier id'>project_symbol</span>
372
372
  <span class='camel_to_snake_case identifier id'>camel_to_snake_case</span><span class='lparen token'>(</span><span class='project_symbol identifier id'>project_symbol</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='downcase identifier id'>downcase</span>
@@ -408,13 +408,13 @@ Calculates the name of the project module from the given project name.
408
408
  <pre class="lines">
409
409
 
410
410
 
411
- 961
412
- 962
413
- 963
414
- 964</pre>
411
+ 1002
412
+ 1003
413
+ 1004
414
+ 1005</pre>
415
415
  </td>
416
416
  <td>
417
- <pre class="code"><span class="info file"># File 'lib/inochi/inochi.rb', line 961</span>
417
+ <pre class="code"><span class="info file"># File 'lib/inochi/inochi.rb', line 1002</span>
418
418
 
419
419
  <span class='def def kw'>def</span> <span class='calc_project_symbol identifier id'>calc_project_symbol</span> <span class='project_name identifier id'>project_name</span>
420
420
  <span class='name identifier id'>name</span> <span class='assign token'>=</span> <span class='project_name identifier id'>project_name</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='dot token'>.</span><span class='gsub identifier id'>gsub</span><span class='lparen token'>(</span><span class='regexp val'>/\W+/</span><span class='comma token'>,</span> <span class='string val'>'_'</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='squeeze identifier id'>squeeze</span><span class='lparen token'>(</span><span class='string val'>'_'</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='gsub identifier id'>gsub</span><span class='lparen token'>(</span><span class='regexp val'>/^_|_$/</span><span class='comma token'>,</span> <span class='string val'>''</span><span class='rparen token'>)</span>
@@ -457,22 +457,22 @@ Transforms the given input from CamelCase to snake_case.
457
457
  <pre class="lines">
458
458
 
459
459
 
460
- 969
461
- 970
462
- 971
463
- 972
464
- 973
465
- 974
466
- 975
467
- 976
468
- 977
469
- 978
470
- 979
471
- 980
472
- 981</pre>
460
+ 1010
461
+ 1011
462
+ 1012
463
+ 1013
464
+ 1014
465
+ 1015
466
+ 1016
467
+ 1017
468
+ 1018
469
+ 1019
470
+ 1020
471
+ 1021
472
+ 1022</pre>
473
473
  </td>
474
474
  <td>
475
- <pre class="code"><span class="info file"># File 'lib/inochi/inochi.rb', line 969</span>
475
+ <pre class="code"><span class="info file"># File 'lib/inochi/inochi.rb', line 1010</span>
476
476
 
477
477
  <span class='def def kw'>def</span> <span class='camel_to_snake_case identifier id'>camel_to_snake_case</span> <span class='input identifier id'>input</span>
478
478
  <span class='input identifier id'>input</span> <span class='assign token'>=</span> <span class='input identifier id'>input</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='dot token'>.</span><span class='dup identifier id'>dup</span>
@@ -1050,8 +1050,9 @@ Provides Rake tasks for packaging, publishing, and announcing your project.
1050
1050
  their contact information) is added to the project module.
1051
1051
 
1052
1052
  <p>
1053
- This information is extracted from copyright notices in the project license
1054
- file. NOTE that the first copyright notice must correspond to the primary
1053
+ Unless this information is supplied via the :authors option, it is
1054
+ automatically extracted from copyright notices in the project license file,
1055
+ where the first copyright notice is expected to correspond to the primary
1055
1056
  project maintainer.
1056
1057
  </p>
1057
1058
  <p>
@@ -1102,6 +1103,12 @@ project.
1102
1103
  Additional method parameters, which are all optional:
1103
1104
  </p>
1104
1105
  <dl>
1106
+ <dt>Array</dt><dd>:authors =&gt; A list of project authors and their contact information.
1107
+ This list must have the form &quot;[[name, info]]&quot; where
1108
+ &quot;name&quot; is the name of a project author and &quot;info&quot; is
1109
+ their contact information.
1110
+
1111
+ </dd>
1105
1112
  <dt>String</dt><dd>:license_file =&gt; Path (relative to the main project directory which
1106
1113
  contains the project Rakefile) to the file which contains the project
1107
1114
  license.
@@ -1211,12 +1218,6 @@ the gem specification
1211
1218
  <pre class="lines">
1212
1219
 
1213
1220
 
1214
- 302
1215
- 303
1216
- 304
1217
- 305
1218
- 306
1219
- 307
1220
1221
  308
1221
1222
  309
1222
1223
  310
@@ -1784,10 +1785,51 @@ the gem specification
1784
1785
  872
1785
1786
  873
1786
1787
  874
1787
- 875</pre>
1788
+ 875
1789
+ 876
1790
+ 877
1791
+ 878
1792
+ 879
1793
+ 880
1794
+ 881
1795
+ 882
1796
+ 883
1797
+ 884
1798
+ 885
1799
+ 886
1800
+ 887
1801
+ 888
1802
+ 889
1803
+ 890
1804
+ 891
1805
+ 892
1806
+ 893
1807
+ 894
1808
+ 895
1809
+ 896
1810
+ 897
1811
+ 898
1812
+ 899
1813
+ 900
1814
+ 901
1815
+ 902
1816
+ 903
1817
+ 904
1818
+ 905
1819
+ 906
1820
+ 907
1821
+ 908
1822
+ 909
1823
+ 910
1824
+ 911
1825
+ 912
1826
+ 913
1827
+ 914
1828
+ 915
1829
+ 916</pre>
1788
1830
  </td>
1789
1831
  <td>
1790
- <pre class="code"><span class="info file"># File 'lib/inochi/inochi.rb', line 302</span>
1832
+ <pre class="code"><span class="info file"># File 'lib/inochi/inochi.rb', line 308</span>
1791
1833
 
1792
1834
  <span class='def def kw'>def</span> <span class='rake identifier id'>rake</span> <span class='project_symbol identifier id'>project_symbol</span><span class='comma token'>,</span> <span class='options identifier id'>options</span> <span class='assign token'>=</span> <span class='semicolon token'>;</span><span class='lbrace token'>{</span><span class='rbrace token'>}</span><span class='comma token'>,</span> <span class='bitand op'>&amp;</span><span class='gem_config identifier id'>gem_config</span>
1793
1835
  <span class='program_file identifier id'>program_file</span> <span class='assign token'>=</span> <span class='first_caller_file identifier id'>first_caller_file</span>
@@ -1795,24 +1837,24 @@ the gem specification
1795
1837
 
1796
1838
  <span class='comment val'># load the project module</span>
1797
1839
  <span class='program_name identifier id'>program_name</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='basename identifier id'>basename</span><span class='lparen token'>(</span><span class='program_home identifier id'>program_home</span><span class='rparen token'>)</span>
1840
+ <span class='project_libs identifier id'>project_libs</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='string val'>'lib'</span><span class='comma token'>,</span> <span class='program_name identifier id'>program_name</span><span class='rparen token'>)</span>
1798
1841
 
1799
- <span class='require identifier id'>require</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='string val'>'lib'</span><span class='comma token'>,</span> <span class='program_name identifier id'>program_name</span><span class='rparen token'>)</span>
1842
+ <span class='require identifier id'>require</span> <span class='project_libs identifier id'>project_libs</span>
1800
1843
  <span class='project_module identifier id'>project_module</span> <span class='assign token'>=</span> <span class='fetch_project_module identifier id'>fetch_project_module</span><span class='lparen token'>(</span><span class='project_symbol identifier id'>project_symbol</span><span class='rparen token'>)</span>
1801
1844
 
1802
1845
  <span class='comment val'># supply default options</span>
1803
1846
  <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:rubyforge_project</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='program_name identifier id'>program_name</span>
1804
1847
  <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:rubyforge_section</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='program_name identifier id'>program_name</span>
1805
- <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:raa_project</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='program_name identifier id'>program_name</span>
1806
- <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:license_file</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='string val'>'LICENSE'</span>
1807
- <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:logins_file</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='ENV constant id'>ENV</span><span class='lbrack token'>[</span><span class='string val'>'HOME'</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='string val'>'.config'</span><span class='comma token'>,</span> <span class='string val'>'inochi'</span><span class='comma token'>,</span> <span class='string val'>'logins.yaml'</span><span class='rparen token'>)</span>
1808
- <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:upload_delete</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='false false kw'>false</span>
1809
- <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:upload_options</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
1848
+ <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:raa_project</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='program_name identifier id'>program_name</span>
1849
+ <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:license_file</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='string val'>'LICENSE'</span>
1850
+ <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:logins_file</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='ENV constant id'>ENV</span><span class='lbrack token'>[</span><span class='string val'>'HOME'</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='string val'>'.config'</span><span class='comma token'>,</span> <span class='string val'>'inochi'</span><span class='comma token'>,</span> <span class='string val'>'logins.yaml'</span><span class='rparen token'>)</span>
1851
+ <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:upload_delete</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='false false kw'>false</span>
1852
+ <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:upload_options</span><span class='rbrack token'>]</span> <span class='opasgn op'>||=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
1810
1853
 
1811
1854
  <span class='comment val'># add AUTHORS constant to the project module</span>
1812
- <span class='license identifier id'>license</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='read identifier id'>read</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:license_file</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
1813
-
1814
- <span class='copyright_holders identifier id'>copyright_holders</span> <span class='assign token'>=</span>
1815
- <span class='license identifier id'>license</span><span class='dot token'>.</span><span class='scan identifier id'>scan</span><span class='lparen token'>(</span><span class='regexp val'>/Copyright.*?\d+\s+(.*)/</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='flatten identifier id'>flatten</span><span class='dot token'>.</span>
1855
+ <span class='copyright_holders identifier id'>copyright_holders</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:authors</span><span class='rbrack token'>]</span> <span class='orop op'>||</span>
1856
+ <span class='File constant id'>File</span><span class='dot token'>.</span><span class='read identifier id'>read</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:license_file</span><span class='rbrack token'>]</span><span class='rparen token'>)</span><span class='dot token'>.</span>
1857
+ <span class='scan identifier id'>scan</span><span class='lparen token'>(</span><span class='regexp val'>/Copyright.*?\d+\s+(.*)/</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='flatten identifier id'>flatten</span><span class='dot token'>.</span>
1816
1858
  <span class='map identifier id'>map</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='s identifier id'>s</span><span class='bitor op'>|</span> <span class='lparen token'>(</span><span class='s identifier id'>s</span> <span class='match op'>=~</span> <span class='regexp val'>/\s*&lt;(.*?)&gt;/</span><span class='rparen token'>)</span> <span class='question op'>?</span> <span class='lbrack token'>[</span><span class='$` back_ref id'>$`</span><span class='comma token'>,</span> <span class='$1 nth_ref id'>$1</span><span class='rbrack token'>]</span> <span class='colon op'>:</span> <span class='lbrack token'>[</span><span class='s identifier id'>s</span><span class='comma token'>,</span> <span class='string val'>''</span><span class='rbrack token'>]</span> <span class='rbrace token'>}</span>
1817
1859
 
1818
1860
  <span class='project_module identifier id'>project_module</span><span class='dot token'>.</span><span class='const_set identifier id'>const_set</span> <span class='symbol val'>:AUTHORS</span><span class='comma token'>,</span> <span class='copyright_holders identifier id'>copyright_holders</span>
@@ -1823,6 +1865,38 @@ the gem specification
1823
1865
  <span class='Rake constant id'>Rake</span><span class='colon2 op'>::</span><span class='Task constant id'>Task</span><span class='lbrack token'>[</span><span class='name identifier id'>name</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='instance_variable_set identifier id'>instance_variable_set</span> <span class='symbol val'>:@comment</span><span class='comma token'>,</span> <span class='nil nil kw'>nil</span>
1824
1866
  <span class='end end kw'>end</span>
1825
1867
 
1868
+ <span class='comment val'># testing</span>
1869
+ <span class='desc identifier id'>desc</span> <span class='string val'>'Run all unit tests.'</span>
1870
+ <span class='task identifier id'>task</span> <span class='symbol val'>:test</span> <span class='do do kw'>do</span>
1871
+ <span class='ruby identifier id'>ruby</span> <span class='string val'>'-w'</span><span class='comma token'>,</span> <span class='string val'>'-I.'</span><span class='comma token'>,</span> <span class='string val'>'-Ilib'</span><span class='comma token'>,</span> <span class='string val'>'-r'</span><span class='comma token'>,</span> <span class='program_name identifier id'>program_name</span><span class='comma token'>,</span> <span class='string val'>'-e'</span><span class='comma token'>,</span> <span class='string val'>%q{
1872
+ # set title of test suite
1873
+ $0 = File.basename(Dir.pwd)
1874
+
1875
+ require 'minitest/unit'
1876
+ require 'minitest/spec'
1877
+ require 'minitest/mock'
1878
+ MiniTest::Unit.autorun
1879
+
1880
+ Dir['test/**/*.rb'].sort.each do |test|
1881
+ unit = test.sub('test/', 'lib/')
1882
+
1883
+ if File.exist? unit
1884
+ # strip file extension because require()
1885
+ # does not normalize its input and it
1886
+ # will think that the two paths (with &amp;
1887
+ # without file extension) are different
1888
+ unit_path = unit.sub(/\.rb$/, '').sub('lib/', '')
1889
+ test_path = test.sub(/\.rb$/, '')
1890
+
1891
+ require unit_path
1892
+ require test_path
1893
+ else
1894
+ warn &quot;Skipped test #{test.inspect} because it lacks a corresponding #{unit.inspect} unit.&quot;
1895
+ end
1896
+ end
1897
+ }</span>
1898
+ <span class='end end kw'>end</span>
1899
+
1826
1900
  <span class='comment val'># documentation</span>
1827
1901
  <span class='desc identifier id'>desc</span> <span class='string val'>'Build all documentation.'</span>
1828
1902
  <span class='task identifier id'>task</span> <span class='symbol val'>:doc</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='dstring node'>%w[ doc:api doc:man ]</span>
@@ -1924,9 +1998,9 @@ the gem specification
1924
1998
  <span class='File constant id'>File</span><span class='dot token'>.</span><span class='delete identifier id'>delete</span> <span class='tmp_file identifier id'>tmp_file</span>
1925
1999
  <span class='end end kw'>end</span>
1926
2000
 
1927
- <span class='comment val'># improve readability of list items that span multiple</span>
1928
- <span class='comment val'># lines by adding a blank line between such items</span>
1929
- <span class='text identifier id'>text</span><span class='dot token'>.</span><span class='gsub! fid id'>gsub!</span> <span class='regexp val'>%r{^( *[^\*\s].*)(\r?\n)( *\* \S)}</span><span class='comma token'>,</span> <span class='string val'>'\1\2\2\3'</span>
2001
+ <span class='comment val'># improve readability of list items</span>
2002
+ <span class='comment val'># by adding a blank line between them</span>
2003
+ <span class='text identifier id'>text</span><span class='dot token'>.</span><span class='gsub! fid id'>gsub!</span> <span class='regexp val'>%r{(\r?\n)( +\* \S)}</span><span class='comma token'>,</span> <span class='string val'>'\1\1\2'</span>
1930
2004
 
1931
2005
  <span class='text identifier id'>text</span>
1932
2006
  <span class='end end kw'>end</span>
@@ -1972,6 +2046,9 @@ the gem specification
1972
2046
  <span class='comment val'># remove heading navigation menus</span>
1973
2047
  <span class='ann_html identifier id'>ann_html</span><span class='dot token'>.</span><span class='gsub! fid id'>gsub!</span> <span class='regexp val'>%r{&lt;div class=&quot;nav&quot;[^&gt;]*&gt;(.*?)&lt;/div&gt;}</span><span class='comma token'>,</span> <span class='string val'>''</span>
1974
2048
 
2049
+ <span class='comment val'># remove latex-style heading numbers</span>
2050
+ <span class='ann_html identifier id'>ann_html</span><span class='dot token'>.</span><span class='gsub! fid id'>gsub!</span> <span class='regexp val'>%r&quot;(&lt;(h\d)[^&gt;]*&gt;).+?(?:&amp;nbsp;){2}(.+?)(&lt;/\2&gt;)&quot;</span><span class='m identifier id'>m</span><span class='comma token'>,</span> <span class='string val'>'\1\3\4'</span>
2051
+
1975
2052
  <span class='ann_html identifier id'>ann_html</span> <span class='assign token'>=</span> <span class='resolve_html_links identifier id'>resolve_html_links</span><span class='lbrack token'>[</span><span class='ann_html identifier id'>ann_html</span><span class='rbrack token'>]</span>
1976
2053
  <span class='end end kw'>end</span>
1977
2054
  <span class='end end kw'>end</span>