codnar 0.1.64 → 0.1.66

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,5 +1,10 @@
1
+ 2011-08-25 Oren Ben-Kiki <github-oren@ben-kiki.org>
2
+
3
+ * Use OLAG's additional utilities.
4
+
1
5
  2011-04-22 Oren Ben-Kiki <github-oren@ben-kiki.org>
2
6
 
7
+ * Fix homepage specification.
3
8
  * Olag 0.1.7 and issue fixes.
4
9
 
5
10
  2011-04-19 Oren Ben-Kiki <github-oren@ben-kiki.org>
data/codnar.html CHANGED
@@ -686,7 +686,7 @@ number of Git commits by running <tt>rake version</tt>.
686
686
  </tr>
687
687
  </table>
688
688
  <pre class='ruby code syntax'>
689
- <span class="Type">VERSION</span> = <span class="Special">&quot;</span><span class="Constant">0.1.64</span><span class="Special">&quot;</span>
689
+ <span class="Type">VERSION</span> = <span class="Special">&quot;</span><span class="Constant">0.1.66</span><span class="Special">&quot;</span>
690
690
 
691
691
  end
692
692
  </pre>
@@ -763,7 +763,7 @@ Test scanning classified lines.
763
763
  <span class="PreProc">include</span> <span class="Type">Test</span>::<span class="Type">WithFakeFS</span>
764
764
 
765
765
  <span class="PreProc">def</span> <span class="Identifier">test_scan_lines</span>
766
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">comments</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Type">INPUT</span>) }
766
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">comments</span><span class="Special">&quot;</span>, <span class="Type">INPUT</span>)
767
767
  scanner = <span class="Type">Codnar</span>::<span class="Type">Scanner</span>.new(<span class="Identifier">@errors</span>, <span class="Type">SYNTAX</span>)
768
768
  scanner.lines(<span class="Special">&quot;</span><span class="Constant">comments</span><span class="Special">&quot;</span>).should == <span class="Type">LINES</span>
769
769
  <span class="Identifier">@errors</span>.should == <span class="Type">ERRORS</span>
@@ -1001,7 +1001,7 @@ follows:
1001
1001
  <span class="Identifier">@path</span> = path
1002
1002
  <span class="Identifier">@lines</span> = []
1003
1003
  <span class="Identifier">@state</span> = <span class="Identifier">@syntax</span>.start_state
1004
- <span class="Identifier">@errors</span>.in_path(path) { scan_path }
1004
+ <span class="Identifier">@errors</span>.in_file_lines(path) { |<span class="Identifier">line</span>| scan_line(line.chomp) }
1005
1005
  <span class="Statement">return</span> <span class="Identifier">@lines</span>
1006
1006
  <span class="PreProc">end</span>
1007
1007
 
@@ -1318,52 +1318,6 @@ state transitions to each line:
1318
1318
  <div class="chunk html">
1319
1319
  <pre class='ruby code syntax'>
1320
1320
 
1321
- </pre>
1322
- <table class='layout'>
1323
- <tr>
1324
- <td class='indentation'>
1325
- <pre></pre>
1326
- </td>
1327
- <td class='html'>
1328
- <div class='rdoc comment markup'>
1329
- <p>
1330
- Scan a disk file.
1331
- </p>
1332
- </div>
1333
- </td>
1334
- </tr>
1335
- </table>
1336
- <pre class='ruby code syntax'>
1337
- <span class="PreProc">def</span> <span class="Identifier">scan_path</span>
1338
- <span class="Type">File</span>.open(<span class="Identifier">@path</span>, <span class="Special">&quot;</span><span class="Constant">r</span><span class="Special">&quot;</span>) <span class="Statement">do</span> |<span class="Identifier">file</span>|
1339
- scan_file(file)
1340
- <span class="Statement">end</span>
1341
- <span class="PreProc">end</span>
1342
-
1343
- </pre>
1344
- <table class='layout'>
1345
- <tr>
1346
- <td class='indentation'>
1347
- <pre></pre>
1348
- </td>
1349
- <td class='html'>
1350
- <div class='rdoc comment markup'>
1351
- <p>
1352
- Scan an opened file.
1353
- </p>
1354
- </div>
1355
- </td>
1356
- </tr>
1357
- </table>
1358
- <pre class='ruby code syntax'>
1359
- <span class="PreProc">def</span> <span class="Identifier">scan_file</span>(file)
1360
- <span class="Identifier">@line_number</span> = <span class="Constant">0</span>
1361
- file.read.each_line <span class="Statement">do</span> |<span class="Identifier">line</span>|
1362
- <span class="Identifier">@errors</span>.at_line(<span class="Identifier">@line_number</span> += <span class="Constant">1</span>)
1363
- scan_line(line.chomp)
1364
- <span class="Statement">end</span>
1365
- <span class="PreProc">end</span>
1366
-
1367
1321
  </pre>
1368
1322
  <table class='layout'>
1369
1323
  <tr>
@@ -1435,7 +1389,7 @@ Handle a file line, only if it matches the pattern.
1435
1389
  <span class="Identifier">@lines</span> &lt;&lt; <span class="Type">Scanner</span>.extracted_groups(match, pattern.groups).update({
1436
1390
  <span class="Special">&quot;</span><span class="Constant">line</span><span class="Special">&quot;</span> =&gt; line,
1437
1391
  <span class="Special">&quot;</span><span class="Constant">kind</span><span class="Special">&quot;</span> =&gt; transition.kind,
1438
- <span class="Special">&quot;</span><span class="Constant">number</span><span class="Special">&quot;</span> =&gt; <span class="Identifier">@line_number</span>
1392
+ <span class="Special">&quot;</span><span class="Constant">number</span><span class="Special">&quot;</span> =&gt; <span class="Identifier">@errors</span>.line_number
1439
1393
  })
1440
1394
  <span class="Identifier">@state</span> = transition.next_state
1441
1395
  <span class="Statement">return</span> <span class="Constant">true</span>
@@ -1490,7 +1444,7 @@ Handle a file line that couldn’t be classified.
1490
1444
  <span class="Special">&quot;</span><span class="Constant">payload</span><span class="Special">&quot;</span> =&gt; line.unindent,
1491
1445
  <span class="Special">&quot;</span><span class="Constant">kind</span><span class="Special">&quot;</span> =&gt; <span class="Special">&quot;</span><span class="Constant">error</span><span class="Special">&quot;</span>,
1492
1446
  <span class="Special">&quot;</span><span class="Constant">state</span><span class="Special">&quot;</span> =&gt; state_name,
1493
- <span class="Special">&quot;</span><span class="Constant">number</span><span class="Special">&quot;</span> =&gt; <span class="Identifier">@line_number</span>
1447
+ <span class="Special">&quot;</span><span class="Constant">number</span><span class="Special">&quot;</span> =&gt; <span class="Identifier">@errors</span>.line_number
1494
1448
  }
1495
1449
  <span class="Identifier">@errors</span> &lt;&lt; <span class="Special">&quot;</span><span class="Constant">State: </span><span class="Special">#{</span>state_name<span class="Special">}</span><span class="Constant"> failed to classify line: </span><span class="Special">#{</span><span class="Identifier">@lines</span>.last.payload<span class="Special">}</span><span class="Special">&quot;</span>
1496
1450
  <span class="PreProc">end</span>
@@ -4368,7 +4322,7 @@ Test “splitting” documentation files.
4368
4322
  <span class="PreProc">include</span> <span class="Type">Test</span>::<span class="Type">WithFakeFS</span>
4369
4323
 
4370
4324
  <span class="PreProc">def</span> <span class="Identifier">test_split_raw</span>
4371
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">raw.html</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Special">&quot;</span><span class="Constant">&lt;foo&gt;</span><span class="Special">\n</span><span class="Constant">bar</span><span class="Special">\n</span><span class="Constant">&lt;/foo&gt;</span><span class="Special">\n</span><span class="Special">&quot;</span>) }
4325
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">raw.html</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">&lt;foo&gt;</span><span class="Special">\n</span><span class="Constant">bar</span><span class="Special">\n</span><span class="Constant">&lt;/foo&gt;</span><span class="Special">\n</span><span class="Special">&quot;</span>)
4372
4326
  splitter = <span class="Type">Codnar</span>::<span class="Type">Splitter</span>.new(<span class="Identifier">@errors</span>, configuration(<span class="Special">&quot;</span><span class="Constant">html</span><span class="Special">&quot;</span>))
4373
4327
  chunks = splitter.chunks(<span class="Special">&quot;</span><span class="Constant">raw.html</span><span class="Special">&quot;</span>)
4374
4328
  <span class="Identifier">@errors</span>.should == []
@@ -4382,7 +4336,7 @@ Test “splitting” documentation files.
4382
4336
  <span class="PreProc">end</span>
4383
4337
 
4384
4338
  <span class="PreProc">def</span> <span class="Identifier">test_split_markdown</span>
4385
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">markdown.md</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Special">&quot;</span><span class="Constant">*foo*</span><span class="Special">\n</span><span class="Constant">bar</span><span class="Special">\n</span><span class="Special">&quot;</span>) }
4339
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">markdown.md</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">*foo*</span><span class="Special">\n</span><span class="Constant">bar</span><span class="Special">\n</span><span class="Special">&quot;</span>)
4386
4340
  splitter = <span class="Type">Codnar</span>::<span class="Type">Splitter</span>.new(<span class="Identifier">@errors</span>, configuration(<span class="Special">&quot;</span><span class="Constant">markdown</span><span class="Special">&quot;</span>))
4387
4341
  chunks = splitter.chunks(<span class="Special">&quot;</span><span class="Constant">markdown.md</span><span class="Special">&quot;</span>)
4388
4342
  <span class="Identifier">@errors</span>.should == []
@@ -4396,7 +4350,7 @@ Test “splitting” documentation files.
4396
4350
  <span class="PreProc">end</span>
4397
4351
 
4398
4352
  <span class="PreProc">def</span> <span class="Identifier">test_split_rdoc</span>
4399
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">rdoc.rdoc</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Special">&quot;</span><span class="Constant">*foo*</span><span class="Special">\n</span><span class="Constant">bar</span><span class="Special">\n</span><span class="Special">&quot;</span>) }
4353
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">rdoc.rdoc</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">*foo*</span><span class="Special">\n</span><span class="Constant">bar</span><span class="Special">\n</span><span class="Special">&quot;</span>)
4400
4354
  splitter = <span class="Type">Codnar</span>::<span class="Type">Splitter</span>.new(<span class="Identifier">@errors</span>, configuration(<span class="Special">&quot;</span><span class="Constant">rdoc</span><span class="Special">&quot;</span>))
4401
4355
  chunks = splitter.chunks(<span class="Special">&quot;</span><span class="Constant">rdoc.rdoc</span><span class="Special">&quot;</span>)
4402
4356
  <span class="Identifier">@errors</span>.should == []
@@ -4410,7 +4364,7 @@ Test “splitting” documentation files.
4410
4364
  <span class="PreProc">end</span>
4411
4365
 
4412
4366
  <span class="PreProc">def</span> <span class="Identifier">test_split_unknown_kind</span>
4413
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">unknown.kind</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Special">&quot;</span><span class="Constant">foo</span><span class="Special">\n</span><span class="Constant">bar</span><span class="Special">\n</span><span class="Special">&quot;</span>) }
4367
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">unknown.kind</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">foo</span><span class="Special">\n</span><span class="Constant">bar</span><span class="Special">\n</span><span class="Special">&quot;</span>)
4414
4368
  splitter = <span class="Type">Codnar</span>::<span class="Type">Splitter</span>.new(<span class="Identifier">@errors</span>, configuration(<span class="Special">&quot;</span><span class="Constant">unknown-kind</span><span class="Special">&quot;</span>))
4415
4369
  chunks = splitter.chunks(<span class="Special">&quot;</span><span class="Constant">unknown.kind</span><span class="Special">&quot;</span>)
4416
4370
  <span class="Identifier">@errors</span>.should == [ <span class="Special">&quot;</span><span class="Special">#{</span><span class="Identifier">$0</span><span class="Special">}</span><span class="Constant">: No formatter specified for lines of kind: unknown-kind</span><span class="Special">&quot;</span> ]
@@ -7123,10 +7077,9 @@ Test reading chunks from files.
7123
7077
  <span class="PreProc">end</span>
7124
7078
 
7125
7079
  <span class="PreProc">def</span> <span class="Identifier">test_read_invalid_chunks</span>
7126
- file_path = <span class="Constant">nil</span>
7127
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">foo.chunks</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file_path = <span class="Type">File</span>.expand_path(file.path) }
7080
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">foo.chunks</span><span class="Special">&quot;</span>)
7128
7081
  reader = <span class="Type">Codnar</span>::<span class="Type">Reader</span>.new(<span class="Identifier">@errors</span>, <span class="Type">Dir</span>.glob(<span class="Special">&quot;</span><span class="Constant">./**/*.chunks</span><span class="Special">&quot;</span>))
7129
- <span class="Identifier">@errors</span>.should == [ <span class="Special">&quot;</span><span class="Special">#{</span><span class="Identifier">$0</span><span class="Special">}</span><span class="Constant">: Invalid chunks data in file: </span><span class="Special">#{</span>file_path<span class="Special">}</span><span class="Special">&quot;</span> ]
7082
+ <span class="Identifier">@errors</span>.should == [ <span class="Special">&quot;</span><span class="Special">#{</span><span class="Identifier">$0</span><span class="Special">}</span><span class="Constant">: Invalid chunks data in file: </span><span class="Special">#{</span><span class="Type">File</span>.expand_path(<span class="Special">&quot;</span><span class="Constant">foo.chunks</span><span class="Special">&quot;</span>)<span class="Special">}</span><span class="Special">&quot;</span> ]
7130
7083
  <span class="PreProc">end</span>
7131
7084
 
7132
7085
  <span class="PreProc">def</span> <span class="Identifier">test_read_unused_chunks</span>
@@ -7627,7 +7580,7 @@ Test the built-in weave configurations.
7627
7580
  <span class="Constant"> &lt;embed src=&quot;path&quot; type=&quot;x-codnar/file&quot;/&gt;</span>
7628
7581
  <span class="Constant"> </span><span class="Special">EOF</span>
7629
7582
  })
7630
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">path</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.puts(<span class="Special">&quot;</span><span class="Constant">&lt;h2&gt;File&lt;/h2&gt;</span><span class="Special">&quot;</span>) }
7583
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">path</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">&lt;h2&gt;File&lt;/h2&gt;</span><span class="Special">\n</span><span class="Special">&quot;</span>)
7631
7584
  html = <span class="Type">Codnar</span>::<span class="Type">Weaver</span>.new(<span class="Identifier">@errors</span>, [ <span class="Special">&quot;</span><span class="Constant">chunks</span><span class="Special">&quot;</span> ], <span class="Type">Codnar</span>::<span class="Type">Configuration</span>::<span class="Type">WEAVE_INCLUDE</span>).weave(<span class="Special">&quot;</span><span class="Constant">include</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">top</span><span class="Special">&quot;</span>)
7632
7585
  <span class="Identifier">@errors</span>.should == []
7633
7586
  html.should == &lt;&lt;-<span class="Special">EOF</span>.unindent
@@ -8526,7 +8479,7 @@ Test running a Codnar Application.
8526
8479
  }
8527
8480
 
8528
8481
  <span class="PreProc">def</span> <span class="Identifier">test_merge_configurations</span>
8529
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">user_configuration.yaml</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.print(<span class="Type">USER_CONFIGURATION</span>.to_yaml) }
8482
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">user_configuration.yaml</span><span class="Special">&quot;</span>, <span class="Type">USER_CONFIGURATION</span>.to_yaml)
8530
8483
  <span class="Type">Codnar</span>::<span class="Type">Application</span>.with_argv(<span class="Special">%w(</span><span class="Constant">-o stdout -c split_pre_documentation -c user_configuration.yaml -p</span><span class="Special">)</span>) { <span class="Type">Codnar</span>::<span class="Type">Application</span>.new(<span class="Constant">true</span>).run }.should == <span class="Constant">0</span>
8531
8484
  <span class="Type">YAML</span>.load_file(<span class="Special">&quot;</span><span class="Constant">stdout</span><span class="Special">&quot;</span>).should == <span class="Type">Codnar</span>::<span class="Type">Configuration</span>::<span class="Type">SPLIT_PRE_DOCUMENTATION</span>.deep_merge(<span class="Type">USER_CONFIGURATION</span>)
8532
8485
  <span class="PreProc">end</span>
@@ -8540,7 +8493,7 @@ Test running a Codnar Application.
8540
8493
  <span class="PreProc">def</span> <span class="Identifier">test_require_module</span>
8541
8494
  <span class="Type">FakeFS</span>.deactivate! <span class="Comment"># The additional_module is read by Ruby and is not affected by FakeFS.</span>
8542
8495
  directory = create_tempdir
8543
- <span class="Type">File</span>.open(directory + <span class="Special">&quot;</span><span class="Constant">/additional_module.rb</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.puts(<span class="Special">&quot;</span><span class="Constant">puts 'HERE'</span><span class="Special">&quot;</span>) }
8496
+ write_fake_file(directory + <span class="Special">&quot;</span><span class="Constant">/additional_module.rb</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">puts 'HERE'</span><span class="Special">\n</span><span class="Special">&quot;</span>)
8544
8497
  <span class="Type">Application</span>.with_argv([<span class="Special">&quot;</span><span class="Constant">-o</span><span class="Special">&quot;</span>, stdout = directory + <span class="Special">&quot;</span><span class="Constant">/stdout</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">-I</span><span class="Special">&quot;</span>, directory, <span class="Special">&quot;</span><span class="Constant">-r</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">additional_module</span><span class="Special">&quot;</span> ]) { <span class="Type">Codnar</span>::<span class="Type">Application</span>.new(<span class="Constant">true</span>).run }.should == <span class="Constant">0</span>
8545
8498
  <span class="Type">File</span>.read(stdout).should == <span class="Special">&quot;</span><span class="Constant">HERE</span><span class="Special">\n</span><span class="Special">&quot;</span>
8546
8499
  <span class="PreProc">end</span>
@@ -8875,7 +8828,7 @@ Test running the Split Codnar Application.
8875
8828
  <span class="PreProc">end</span>
8876
8829
 
8877
8830
  <span class="PreProc">def</span> <span class="Identifier">test_run_split</span>
8878
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">input</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.puts(<span class="Special">&quot;</span><span class="Constant">&lt;foo&gt;</span><span class="Special">&quot;</span>) }
8831
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">input</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">&lt;foo&gt;</span><span class="Special">\n</span><span class="Special">&quot;</span>)
8879
8832
  <span class="Type">Codnar</span>::<span class="Type">Application</span>.with_argv(<span class="Special">%w(</span><span class="Constant">-o stdout input</span><span class="Special">)</span>) { <span class="Type">Codnar</span>::<span class="Type">Split</span>.new(<span class="Constant">true</span>).run }.should == <span class="Constant">0</span>
8880
8833
  <span class="Type">YAML</span>.load_file(<span class="Special">&quot;</span><span class="Constant">stdout</span><span class="Special">&quot;</span>).should == [ {
8881
8834
  <span class="Special">&quot;</span><span class="Constant">name</span><span class="Special">&quot;</span> =&gt; <span class="Special">&quot;</span><span class="Constant">input</span><span class="Special">&quot;</span>,
@@ -8886,16 +8839,6 @@ Test running the Split Codnar Application.
8886
8839
  } ]
8887
8840
  <span class="PreProc">end</span>
8888
8841
 
8889
- <span class="PreProc">def</span> <span class="Identifier">test_run_split_no_file</span>
8890
- <span class="Type">Codnar</span>::<span class="Type">Application</span>.with_argv(<span class="Special">%w(</span><span class="Constant">-e stderr</span><span class="Special">)</span>) { <span class="Type">Codnar</span>::<span class="Type">Split</span>.new(<span class="Constant">true</span>).run }.should == <span class="Constant">1</span>
8891
- <span class="Type">File</span>.read(<span class="Special">&quot;</span><span class="Constant">stderr</span><span class="Special">&quot;</span>).should == <span class="Special">&quot;</span><span class="Special">#{</span><span class="Identifier">$0</span><span class="Special">}</span><span class="Constant">: No input file to split</span><span class="Special">\n</span><span class="Special">&quot;</span>
8892
- <span class="PreProc">end</span>
8893
-
8894
- <span class="PreProc">def</span> <span class="Identifier">test_run_split_many_file</span>
8895
- <span class="Type">Codnar</span>::<span class="Type">Application</span>.with_argv(<span class="Special">%w(</span><span class="Constant">-e stderr one two</span><span class="Special">)</span>) { <span class="Type">Codnar</span>::<span class="Type">Split</span>.new(<span class="Constant">true</span>).run }.should == <span class="Constant">1</span>
8896
- <span class="Type">File</span>.read(<span class="Special">&quot;</span><span class="Constant">stderr</span><span class="Special">&quot;</span>).should == <span class="Special">&quot;</span><span class="Special">#{</span><span class="Identifier">$0</span><span class="Special">}</span><span class="Constant">: Too many input files to split</span><span class="Special">\n</span><span class="Special">&quot;</span>
8897
- <span class="PreProc">end</span>
8898
-
8899
8842
  <span class="PreProc">end</span>
8900
8843
  </pre>
8901
8844
  </div>
@@ -8994,12 +8937,7 @@ Parse remaining command-line file arguments.
8994
8937
  </table>
8995
8938
  <pre class='ruby code syntax'>
8996
8939
  <span class="PreProc">def</span> <span class="Identifier">parse_arguments</span>
8997
- <span class="Statement">case</span> <span class="Identifier">ARGV</span>.size
8998
- <span class="Statement">when</span> <span class="Constant">1</span> <span class="Statement">then</span> <span class="Statement">return</span>
8999
- <span class="Statement">when</span> <span class="Constant">0</span> <span class="Statement">then</span> <span class="Identifier">$stderr</span>.puts(<span class="Special">&quot;</span><span class="Special">#{</span><span class="Identifier">$0</span><span class="Special">}</span><span class="Constant">: No input file to split</span><span class="Special">&quot;</span>)
9000
- <span class="Statement">else</span> <span class="Identifier">$stderr</span>.puts(<span class="Special">&quot;</span><span class="Special">#{</span><span class="Identifier">$0</span><span class="Special">}</span><span class="Constant">: Too many input files to split</span><span class="Special">&quot;</span>)
9001
- <span class="Statement">end</span>
9002
- <span class="Statement">exit</span>(<span class="Constant">1</span>)
8940
+ expect_exactly(<span class="Constant">1</span>, <span class="Special">&quot;</span><span class="Constant">files to split</span><span class="Special">&quot;</span>)
9003
8941
  <span class="PreProc">end</span>
9004
8942
 
9005
8943
  </pre>
@@ -9158,30 +9096,25 @@ Test running the Weave Codnar Application.
9158
9096
  } ]
9159
9097
 
9160
9098
  <span class="PreProc">def</span> <span class="Identifier">test_run_weave</span>
9161
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Type">ROOT_CHUNKS</span>.to_yaml) }
9162
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">included</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Type">INCLUDED_CHUNKS</span>.to_yaml) }
9099
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>, <span class="Type">ROOT_CHUNKS</span>.to_yaml)
9100
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">included</span><span class="Special">&quot;</span>, <span class="Type">INCLUDED_CHUNKS</span>.to_yaml)
9163
9101
  <span class="Type">Codnar</span>::<span class="Type">Application</span>.with_argv(<span class="Special">%w(</span><span class="Constant">-o stdout root included</span><span class="Special">)</span>) { <span class="Type">Codnar</span>::<span class="Type">Weave</span>.new(<span class="Constant">true</span>).run }.should == <span class="Constant">0</span>
9164
9102
  <span class="Type">File</span>.read(<span class="Special">&quot;</span><span class="Constant">stdout</span><span class="Special">&quot;</span>).should == <span class="Special">&quot;</span><span class="Constant">Root</span><span class="Special">\n</span><span class="Constant">Included</span><span class="Special">\n</span><span class="Special">&quot;</span>
9165
9103
  <span class="PreProc">end</span>
9166
9104
 
9167
9105
  <span class="PreProc">def</span> <span class="Identifier">test_run_weave_missing_chunk</span>
9168
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Type">ROOT_CHUNKS</span>.to_yaml) }
9106
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>, <span class="Type">ROOT_CHUNKS</span>.to_yaml)
9169
9107
  <span class="Type">Codnar</span>::<span class="Type">Application</span>.with_argv(<span class="Special">%w(</span><span class="Constant">-e stderr -o stdout root</span><span class="Special">)</span>) { <span class="Type">Codnar</span>::<span class="Type">Weave</span>.new(<span class="Constant">true</span>).run }.should == <span class="Constant">1</span>
9170
9108
  <span class="Type">File</span>.read(<span class="Special">&quot;</span><span class="Constant">stderr</span><span class="Special">&quot;</span>).should == <span class="Special">&quot;</span><span class="Special">#{</span><span class="Identifier">$0</span><span class="Special">}</span><span class="Constant">: Missing chunk: included in file: root</span><span class="Special">\n</span><span class="Special">&quot;</span>
9171
9109
  <span class="PreProc">end</span>
9172
9110
 
9173
9111
  <span class="PreProc">def</span> <span class="Identifier">test_run_weave_unused_chunk</span>
9174
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Type">ROOT_CHUNKS</span>.to_yaml) }
9175
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">included</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Type">INCLUDED_CHUNKS</span>.to_yaml) }
9112
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>, <span class="Type">ROOT_CHUNKS</span>.to_yaml)
9113
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">included</span><span class="Special">&quot;</span>, <span class="Type">INCLUDED_CHUNKS</span>.to_yaml)
9176
9114
  <span class="Type">Codnar</span>::<span class="Type">Application</span>.with_argv(<span class="Special">%w(</span><span class="Constant">-e stderr -o stdout included root</span><span class="Special">)</span>) { <span class="Type">Codnar</span>::<span class="Type">Weave</span>.new(<span class="Constant">true</span>).run }.should == <span class="Constant">1</span>
9177
9115
  <span class="Type">File</span>.read(<span class="Special">&quot;</span><span class="Constant">stderr</span><span class="Special">&quot;</span>).should == <span class="Special">&quot;</span><span class="Special">#{</span><span class="Identifier">$0</span><span class="Special">}</span><span class="Constant">: Unused chunk: root in file: root at line: 1</span><span class="Special">\n</span><span class="Special">&quot;</span>
9178
9116
  <span class="PreProc">end</span>
9179
9117
 
9180
- <span class="PreProc">def</span> <span class="Identifier">test_run_weave_no_chunks</span>
9181
- <span class="Type">Codnar</span>::<span class="Type">Application</span>.with_argv(<span class="Special">%w(</span><span class="Constant">-e stderr</span><span class="Special">)</span>) { <span class="Type">Codnar</span>::<span class="Type">Weave</span>.new(<span class="Constant">true</span>).run }.should == <span class="Constant">1</span>
9182
- <span class="Type">File</span>.read(<span class="Special">&quot;</span><span class="Constant">stderr</span><span class="Special">&quot;</span>).should == <span class="Special">&quot;</span><span class="Special">#{</span><span class="Identifier">$0</span><span class="Special">}</span><span class="Constant">: No chunk files to weave</span><span class="Special">\n</span><span class="Special">&quot;</span>
9183
- <span class="PreProc">end</span>
9184
-
9185
9118
  <span class="Type">FILE_CHUNKS</span> = [ {
9186
9119
  <span class="Special">&quot;</span><span class="Constant">name</span><span class="Special">&quot;</span> =&gt; <span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>,
9187
9120
  <span class="Special">&quot;</span><span class="Constant">locations</span><span class="Special">&quot;</span> =&gt; [ { <span class="Special">&quot;</span><span class="Constant">file</span><span class="Special">&quot;</span> =&gt; <span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">line</span><span class="Special">&quot;</span> =&gt; <span class="Constant">1</span> } ],
@@ -9189,7 +9122,7 @@ Test running the Weave Codnar Application.
9189
9122
  } ]
9190
9123
 
9191
9124
  <span class="PreProc">def</span> <span class="Identifier">test_run_weave_missing_file</span>
9192
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Type">FILE_CHUNKS</span>.to_yaml) }
9125
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>, <span class="Type">FILE_CHUNKS</span>.to_yaml)
9193
9126
  <span class="Type">Codnar</span>::<span class="Type">Application</span>.with_argv(<span class="Special">%w(</span><span class="Constant">-e stderr -o stdout root</span><span class="Special">)</span>) { <span class="Type">Codnar</span>::<span class="Type">Weave</span>.new(<span class="Constant">true</span>).run }.should == <span class="Constant">1</span>
9194
9127
  double_message = <span class="Special">&quot;</span><span class="Constant">No such file or directory - </span><span class="Special">&quot;</span> * <span class="Constant">2</span> <span class="Comment"># Something weird in Ruby Exception.to_s</span>
9195
9128
  <span class="Type">File</span>.read(<span class="Special">&quot;</span><span class="Constant">stdout</span><span class="Special">&quot;</span>).should == <span class="Special">&quot;</span><span class="Constant">Root</span><span class="Special">\n</span><span class="Constant">FILE: included.file EXCEPTION: </span><span class="Special">#{</span>double_message<span class="Special">}</span><span class="Special">\n</span><span class="Special">&quot;</span>
@@ -9198,8 +9131,8 @@ Test running the Weave Codnar Application.
9198
9131
  <span class="PreProc">end</span>
9199
9132
 
9200
9133
  <span class="PreProc">def</span> <span class="Identifier">test_run_weave_existing_file</span>
9201
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Type">FILE_CHUNKS</span>.to_yaml) }
9202
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">included.file</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.write(<span class="Special">&quot;</span><span class="Constant">included file</span><span class="Special">\n</span><span class="Special">&quot;</span>) }
9134
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">root</span><span class="Special">&quot;</span>, <span class="Type">FILE_CHUNKS</span>.to_yaml)
9135
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">included.file</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">included file</span><span class="Special">\n</span><span class="Special">&quot;</span>)
9203
9136
  <span class="Type">Codnar</span>::<span class="Type">Application</span>.with_argv(<span class="Special">%w(</span><span class="Constant">-e stderr -o stdout root</span><span class="Special">)</span>) { <span class="Type">Codnar</span>::<span class="Type">Weave</span>.new(<span class="Constant">true</span>).run }.should == <span class="Constant">0</span>
9204
9137
  <span class="Type">File</span>.read(<span class="Special">&quot;</span><span class="Constant">stdout</span><span class="Special">&quot;</span>).should == <span class="Special">&quot;</span><span class="Constant">Root</span><span class="Special">\n</span><span class="Constant">included file</span><span class="Special">\n</span><span class="Special">&quot;</span>
9205
9138
  <span class="PreProc">end</span>
@@ -9303,9 +9236,7 @@ Parse remaining command-line file arguments.
9303
9236
  </table>
9304
9237
  <pre class='ruby code syntax'>
9305
9238
  <span class="PreProc">def</span> <span class="Identifier">parse_arguments</span>
9306
- <span class="Statement">return</span> <span class="Statement">if</span> <span class="Identifier">ARGV</span>.size &gt; <span class="Constant">0</span>
9307
- <span class="Identifier">$stderr</span>.puts(<span class="Special">&quot;</span><span class="Special">#{</span><span class="Identifier">$0</span><span class="Special">}</span><span class="Constant">: No chunk files to weave</span><span class="Special">&quot;</span>)
9308
- <span class="Statement">exit</span>(<span class="Constant">1</span>)
9239
+ expect_at_least(<span class="Constant">1</span>, <span class="Special">&quot;</span><span class="Constant">chunk files to weave</span><span class="Special">&quot;</span>)
9309
9240
  <span class="PreProc">end</span>
9310
9241
 
9311
9242
  </pre>
@@ -9457,7 +9388,7 @@ Test rake tasks.
9457
9388
  <span class="Statement">protected</span>
9458
9389
 
9459
9390
  <span class="PreProc">def</span> <span class="Identifier">run_rake</span>
9460
- <span class="Type">File</span>.open(<span class="Special">&quot;</span><span class="Constant">foo</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">w</span><span class="Special">&quot;</span>) { |<span class="Identifier">file</span>| file.puts(<span class="Special">&quot;</span><span class="Constant">foo</span><span class="Special">&quot;</span>) }
9391
+ write_fake_file(<span class="Special">&quot;</span><span class="Constant">foo</span><span class="Special">&quot;</span>, <span class="Special">&quot;</span><span class="Constant">foo</span><span class="Special">\n</span><span class="Special">&quot;</span>)
9461
9392
  <span class="Type">Codnar</span>::<span class="Type">Rake</span>::<span class="Type">SplitTask</span>.new([ <span class="Special">&quot;</span><span class="Constant">foo</span><span class="Special">&quot;</span> ], [])
9462
9393
  <span class="Type">Codnar</span>::<span class="Type">Rake</span>::<span class="Type">WeaveTask</span>.new(<span class="Special">&quot;</span><span class="Constant">foo</span><span class="Special">&quot;</span>, [])
9463
9394
  <span class="Identifier">@rake</span>[<span class="Special">&quot;</span><span class="Constant">codnar</span><span class="Special">&quot;</span>].invoke
@@ -77,7 +77,7 @@ module Codnar
77
77
  @path = path
78
78
  @lines = []
79
79
  @state = @syntax.start_state
80
- @errors.in_path(path) { scan_path }
80
+ @errors.in_file_lines(path) { |line| scan_line(line.chomp) }
81
81
  return @lines
82
82
  end
83
83
 
@@ -144,22 +144,6 @@ module Codnar
144
144
 
145
145
  # {{{ Scanner file processing
146
146
 
147
- # Scan a disk file.
148
- def scan_path
149
- File.open(@path, "r") do |file|
150
- scan_file(file)
151
- end
152
- end
153
-
154
- # Scan an opened file.
155
- def scan_file(file)
156
- @line_number = 0
157
- file.read.each_line do |line|
158
- @errors.at_line(@line_number += 1)
159
- scan_line(line.chomp)
160
- end
161
- end
162
-
163
147
  # Scan the next file line.
164
148
  def scan_line(line)
165
149
  @state.transitions.each do |transition|
@@ -179,7 +163,7 @@ module Codnar
179
163
  @lines << Scanner.extracted_groups(match, pattern.groups).update({
180
164
  "line" => line,
181
165
  "kind" => transition.kind,
182
- "number" => @line_number
166
+ "number" => @errors.line_number
183
167
  })
184
168
  @state = transition.next_state
185
169
  return true
@@ -204,7 +188,7 @@ module Codnar
204
188
  "payload" => line.unindent,
205
189
  "kind" => "error",
206
190
  "state" => state_name,
207
- "number" => @line_number
191
+ "number" => @errors.line_number
208
192
  }
209
193
  @errors << "State: #{state_name} failed to classify line: #{@lines.last.payload}"
210
194
  end
data/lib/codnar/split.rb CHANGED
@@ -19,12 +19,7 @@ module Codnar
19
19
 
20
20
  # Parse remaining command-line file arguments.
21
21
  def parse_arguments
22
- case ARGV.size
23
- when 1 then return
24
- when 0 then $stderr.puts("#{$0}: No input file to split")
25
- else $stderr.puts("#{$0}: Too many input files to split")
26
- end
27
- exit(1)
22
+ expect_exactly(1, "files to split")
28
23
  end
29
24
 
30
25
  # Return the banner line of the help message.
@@ -3,6 +3,6 @@ module Codnar
3
3
 
4
4
  # This version number. The third number is automatically updated to track the
5
5
  # number of Git commits by running <tt>rake version</tt>.
6
- VERSION = "0.1.64"
6
+ VERSION = "0.1.66"
7
7
 
8
8
  end
data/lib/codnar/weave.rb CHANGED
@@ -20,9 +20,7 @@ module Codnar
20
20
 
21
21
  # Parse remaining command-line file arguments.
22
22
  def parse_arguments
23
- return if ARGV.size > 0
24
- $stderr.puts("#{$0}: No chunk files to weave")
25
- exit(1)
23
+ expect_at_least(1, "chunk files to weave")
26
24
  end
27
25
 
28
26
  # Return the banner line of the help message.
data/test/rake_tasks.rb CHANGED
@@ -16,7 +16,7 @@ class TestRakeTasks < Test::Unit::TestCase
16
16
  protected
17
17
 
18
18
  def run_rake
19
- File.open("foo", "w") { |file| file.puts("foo") }
19
+ write_fake_file("foo", "foo\n")
20
20
  Codnar::Rake::SplitTask.new([ "foo" ], [])
21
21
  Codnar::Rake::WeaveTask.new("foo", [])
22
22
  @rake["codnar"].invoke
data/test/read_chunks.rb CHANGED
@@ -19,10 +19,9 @@ class TestReadChunks < Test::Unit::TestCase
19
19
  end
20
20
 
21
21
  def test_read_invalid_chunks
22
- file_path = nil
23
- File.open("foo.chunks", "w") { |file| file_path = File.expand_path(file.path) }
22
+ write_fake_file("foo.chunks")
24
23
  reader = Codnar::Reader.new(@errors, Dir.glob("./**/*.chunks"))
25
- @errors.should == [ "#{$0}: Invalid chunks data in file: #{file_path}" ]
24
+ @errors.should == [ "#{$0}: Invalid chunks data in file: #{File.expand_path("foo.chunks")}" ]
26
25
  end
27
26
 
28
27
  def test_read_unused_chunks
@@ -27,7 +27,7 @@ module Codnar
27
27
  }
28
28
 
29
29
  def test_merge_configurations
30
- File.open("user_configuration.yaml", "w") { |file| file.print(USER_CONFIGURATION.to_yaml) }
30
+ write_fake_file("user_configuration.yaml", USER_CONFIGURATION.to_yaml)
31
31
  Codnar::Application.with_argv(%w(-o stdout -c split_pre_documentation -c user_configuration.yaml -p)) { Codnar::Application.new(true).run }.should == 0
32
32
  YAML.load_file("stdout").should == Codnar::Configuration::SPLIT_PRE_DOCUMENTATION.deep_merge(USER_CONFIGURATION)
33
33
  end
@@ -41,7 +41,7 @@ module Codnar
41
41
  def test_require_module
42
42
  FakeFS.deactivate! # The additional_module is read by Ruby and is not affected by FakeFS.
43
43
  directory = create_tempdir
44
- File.open(directory + "/additional_module.rb", "w") { |file| file.puts("puts 'HERE'") }
44
+ write_fake_file(directory + "/additional_module.rb", "puts 'HERE'\n")
45
45
  Application.with_argv(["-o", stdout = directory + "/stdout", "-I", directory, "-r", "additional_module" ]) { Codnar::Application.new(true).run }.should == 0
46
46
  File.read(stdout).should == "HERE\n"
47
47
  end
data/test/run_split.rb CHANGED
@@ -14,7 +14,7 @@ class TestRunSplit < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  def test_run_split
17
- File.open("input", "w") { |file| file.puts("<foo>") }
17
+ write_fake_file("input", "<foo>\n")
18
18
  Codnar::Application.with_argv(%w(-o stdout input)) { Codnar::Split.new(true).run }.should == 0
19
19
  YAML.load_file("stdout").should == [ {
20
20
  "name" => "input",
@@ -25,14 +25,4 @@ class TestRunSplit < Test::Unit::TestCase
25
25
  } ]
26
26
  end
27
27
 
28
- def test_run_split_no_file
29
- Codnar::Application.with_argv(%w(-e stderr)) { Codnar::Split.new(true).run }.should == 1
30
- File.read("stderr").should == "#{$0}: No input file to split\n"
31
- end
32
-
33
- def test_run_split_many_file
34
- Codnar::Application.with_argv(%w(-e stderr one two)) { Codnar::Split.new(true).run }.should == 1
35
- File.read("stderr").should == "#{$0}: Too many input files to split\n"
36
- end
37
-
38
28
  end
data/test/run_weave.rb CHANGED
@@ -26,30 +26,25 @@ class TestRunWeave < Test::Unit::TestCase
26
26
  } ]
27
27
 
28
28
  def test_run_weave
29
- File.open("root", "w") { |file| file.write(ROOT_CHUNKS.to_yaml) }
30
- File.open("included", "w") { |file| file.write(INCLUDED_CHUNKS.to_yaml) }
29
+ write_fake_file("root", ROOT_CHUNKS.to_yaml)
30
+ write_fake_file("included", INCLUDED_CHUNKS.to_yaml)
31
31
  Codnar::Application.with_argv(%w(-o stdout root included)) { Codnar::Weave.new(true).run }.should == 0
32
32
  File.read("stdout").should == "Root\nIncluded\n"
33
33
  end
34
34
 
35
35
  def test_run_weave_missing_chunk
36
- File.open("root", "w") { |file| file.write(ROOT_CHUNKS.to_yaml) }
36
+ write_fake_file("root", ROOT_CHUNKS.to_yaml)
37
37
  Codnar::Application.with_argv(%w(-e stderr -o stdout root)) { Codnar::Weave.new(true).run }.should == 1
38
38
  File.read("stderr").should == "#{$0}: Missing chunk: included in file: root\n"
39
39
  end
40
40
 
41
41
  def test_run_weave_unused_chunk
42
- File.open("root", "w") { |file| file.write(ROOT_CHUNKS.to_yaml) }
43
- File.open("included", "w") { |file| file.write(INCLUDED_CHUNKS.to_yaml) }
42
+ write_fake_file("root", ROOT_CHUNKS.to_yaml)
43
+ write_fake_file("included", INCLUDED_CHUNKS.to_yaml)
44
44
  Codnar::Application.with_argv(%w(-e stderr -o stdout included root)) { Codnar::Weave.new(true).run }.should == 1
45
45
  File.read("stderr").should == "#{$0}: Unused chunk: root in file: root at line: 1\n"
46
46
  end
47
47
 
48
- def test_run_weave_no_chunks
49
- Codnar::Application.with_argv(%w(-e stderr)) { Codnar::Weave.new(true).run }.should == 1
50
- File.read("stderr").should == "#{$0}: No chunk files to weave\n"
51
- end
52
-
53
48
  FILE_CHUNKS = [ {
54
49
  "name" => "root",
55
50
  "locations" => [ { "file" => "root", "line" => 1 } ],
@@ -57,7 +52,7 @@ class TestRunWeave < Test::Unit::TestCase
57
52
  } ]
58
53
 
59
54
  def test_run_weave_missing_file
60
- File.open("root", "w") { |file| file.write(FILE_CHUNKS.to_yaml) }
55
+ write_fake_file("root", FILE_CHUNKS.to_yaml)
61
56
  Codnar::Application.with_argv(%w(-e stderr -o stdout root)) { Codnar::Weave.new(true).run }.should == 1
62
57
  double_message = "No such file or directory - " * 2 # Something weird in Ruby Exception.to_s
63
58
  File.read("stdout").should == "Root\nFILE: included.file EXCEPTION: #{double_message}\n"
@@ -66,8 +61,8 @@ class TestRunWeave < Test::Unit::TestCase
66
61
  end
67
62
 
68
63
  def test_run_weave_existing_file
69
- File.open("root", "w") { |file| file.write(FILE_CHUNKS.to_yaml) }
70
- File.open("included.file", "w") { |file| file.write("included file\n") }
64
+ write_fake_file("root", FILE_CHUNKS.to_yaml)
65
+ write_fake_file("included.file", "included file\n")
71
66
  Codnar::Application.with_argv(%w(-e stderr -o stdout root)) { Codnar::Weave.new(true).run }.should == 0
72
67
  File.read("stdout").should == "Root\nincluded file\n"
73
68
  end
data/test/scan_lines.rb CHANGED
@@ -9,7 +9,7 @@ class TestScanLines < Test::Unit::TestCase
9
9
  include Test::WithFakeFS
10
10
 
11
11
  def test_scan_lines
12
- File.open("comments", "w") { |file| file.write(INPUT) }
12
+ write_fake_file("comments", INPUT)
13
13
  scanner = Codnar::Scanner.new(@errors, SYNTAX)
14
14
  scanner.lines("comments").should == LINES
15
15
  @errors.should == ERRORS
@@ -9,7 +9,7 @@ class TestSplitDocumentation < Test::Unit::TestCase
9
9
  include Test::WithFakeFS
10
10
 
11
11
  def test_split_raw
12
- File.open("raw.html", "w") { |file| file.write("<foo>\nbar\n</foo>\n") }
12
+ write_fake_file("raw.html", "<foo>\nbar\n</foo>\n")
13
13
  splitter = Codnar::Splitter.new(@errors, configuration("html"))
14
14
  chunks = splitter.chunks("raw.html")
15
15
  @errors.should == []
@@ -23,7 +23,7 @@ class TestSplitDocumentation < Test::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_split_markdown
26
- File.open("markdown.md", "w") { |file| file.write("*foo*\nbar\n") }
26
+ write_fake_file("markdown.md", "*foo*\nbar\n")
27
27
  splitter = Codnar::Splitter.new(@errors, configuration("markdown"))
28
28
  chunks = splitter.chunks("markdown.md")
29
29
  @errors.should == []
@@ -37,7 +37,7 @@ class TestSplitDocumentation < Test::Unit::TestCase
37
37
  end
38
38
 
39
39
  def test_split_rdoc
40
- File.open("rdoc.rdoc", "w") { |file| file.write("*foo*\nbar\n") }
40
+ write_fake_file("rdoc.rdoc", "*foo*\nbar\n")
41
41
  splitter = Codnar::Splitter.new(@errors, configuration("rdoc"))
42
42
  chunks = splitter.chunks("rdoc.rdoc")
43
43
  @errors.should == []
@@ -51,7 +51,7 @@ class TestSplitDocumentation < Test::Unit::TestCase
51
51
  end
52
52
 
53
53
  def test_split_unknown_kind
54
- File.open("unknown.kind", "w") { |file| file.write("foo\nbar\n") }
54
+ write_fake_file("unknown.kind", "foo\nbar\n")
55
55
  splitter = Codnar::Splitter.new(@errors, configuration("unknown-kind"))
56
56
  chunks = splitter.chunks("unknown.kind")
57
57
  @errors.should == [ "#{$0}: No formatter specified for lines of kind: unknown-kind" ]
@@ -16,7 +16,7 @@ class TestWeaveConfigurations < Test::Unit::TestCase
16
16
  <embed src="path" type="x-codnar/file"/>
17
17
  EOF
18
18
  })
19
- File.open("path", "w") { |file| file.puts("<h2>File</h2>") }
19
+ write_fake_file("path", "<h2>File</h2>\n")
20
20
  html = Codnar::Weaver.new(@errors, [ "chunks" ], Codnar::Configuration::WEAVE_INCLUDE).weave("include", "top")
21
21
  @errors.should == []
22
22
  html.should == <<-EOF.unindent
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codnar
3
3
  version: !ruby/object:Gem::Version
4
- hash: 155
4
+ hash: 159
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 64
10
- version: 0.1.64
9
+ - 66
10
+ version: 0.1.66
11
11
  platform: ruby
12
12
  authors:
13
13
  - Oren Ben-Kiki
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-22 00:00:00 Z
18
+ date: 2011-08-25 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: andand
@@ -296,7 +296,7 @@ licenses: []
296
296
  post_install_message:
297
297
  rdoc_options:
298
298
  - --title
299
- - Code Narrator 0.1.64
299
+ - Code Narrator 0.1.66
300
300
  - --main
301
301
  - README.rdoc
302
302
  - --line-numbers