smart_diff 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/bin/smart_diff +7 -0
- data/doc/Htmlize.html +63 -65
- data/doc/SmartDiff.html +10 -12
- data/doc/Tag.html +11 -13
- data/doc/Utils.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +4 -4
- data/doc/index.html +4 -4
- data/doc/top-level-namespace.html +1 -1
- data/lib/smart_diff.rb +13 -5
- data/lib/smart_diff/htmlize.rb +3 -6
- data/spec/smart_diff_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fbffcc611b3c05d3bdac4daa287a3738634919d
|
4
|
+
data.tar.gz: f02216481f1250072a1b1ae2bfbe02e6721c4457
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c6966ad3a35ac7b804df1fa7e6e22253f2950162aaa908ab860ee19c782daa35fef8ac3b953842a9dcce92704062b65419bb8c8fbefabfd2db0cdbdb495f0cb
|
7
|
+
data.tar.gz: 863c8c4ca0db686a47416bb4eb98524ba770b877f2300fc8f6a9995b4cd77705358dd45988378f5810e23be055d20a507d0f7e9be884de469e0f66dc23b3b30c
|
data/README.md
CHANGED
@@ -10,8 +10,8 @@ said NodeDiff classes are entirely unrelated to psydiff, except that they do
|
|
10
10
|
something quite similar (create a diff of source code based on the AST rather than comparing the text directly).
|
11
11
|
|
12
12
|
This application should especially serve as an example of using the subdiff's
|
13
|
-
produced by NodeDiff to improve the quality of the output. See `bin/smart_diff`
|
14
|
-
or [check out the docs](http://
|
13
|
+
produced by NodeDiff to improve the quality of the output. See [`bin/smart_diff`](https://github.com/edubkendo/smart_diff/blob/master/bin/smart_diff)
|
14
|
+
or [check out the docs](http://edubkendo.github.io/smart_diff/).
|
15
15
|
|
16
16
|
## Install
|
17
17
|
|
data/bin/smart_diff
CHANGED
@@ -3,6 +3,13 @@
|
|
3
3
|
require_relative "../lib/smart_diff"
|
4
4
|
require_relative "../lib/smart_diff/htmlize"
|
5
5
|
|
6
|
+
if ARGV.size < 2
|
7
|
+
puts "Please call SmartDiff with two ruby files."
|
8
|
+
puts "Like: "
|
9
|
+
puts "\t$ smart_diff example/file1.rb example/file2.rb"
|
10
|
+
exit -1
|
11
|
+
end
|
12
|
+
|
6
13
|
file_path1 = ARGV[0]
|
7
14
|
file_path2 = ARGV[1]
|
8
15
|
|
data/doc/Htmlize.html
CHANGED
@@ -547,13 +547,13 @@ tags for each.</p>
|
|
547
547
|
<pre class="lines">
|
548
548
|
|
549
549
|
|
550
|
+
55
|
551
|
+
56
|
550
552
|
57
|
551
|
-
58
|
552
|
-
59
|
553
|
-
60</pre>
|
553
|
+
58</pre>
|
554
554
|
</td>
|
555
555
|
<td>
|
556
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
556
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 55</span>
|
557
557
|
|
558
558
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
|
559
559
|
<span class='ivar'>@uid_count</span> <span class='op'>=</span> <span class='op'>-</span><span class='int'>1</span>
|
@@ -597,12 +597,12 @@ tags for each.</p>
|
|
597
597
|
<pre class="lines">
|
598
598
|
|
599
599
|
|
600
|
-
|
601
|
-
|
602
|
-
|
600
|
+
53
|
601
|
+
54
|
602
|
+
55</pre>
|
603
603
|
</td>
|
604
604
|
<td>
|
605
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
605
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 53</span>
|
606
606
|
|
607
607
|
<span class='kw'>def</span> <span class='id identifier rubyid_uid_count'>uid_count</span>
|
608
608
|
<span class='ivar'>@uid_count</span>
|
@@ -640,12 +640,12 @@ tags for each.</p>
|
|
640
640
|
<pre class="lines">
|
641
641
|
|
642
642
|
|
643
|
-
|
644
|
-
|
645
|
-
|
643
|
+
53
|
644
|
+
54
|
645
|
+
55</pre>
|
646
646
|
</td>
|
647
647
|
<td>
|
648
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
648
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 53</span>
|
649
649
|
|
650
650
|
<span class='kw'>def</span> <span class='id identifier rubyid_uid_hash'>uid_hash</span>
|
651
651
|
<span class='ivar'>@uid_hash</span>
|
@@ -743,6 +743,8 @@ appropriate text.</p>
|
|
743
743
|
<pre class="lines">
|
744
744
|
|
745
745
|
|
746
|
+
182
|
747
|
+
183
|
746
748
|
184
|
747
749
|
185
|
748
750
|
186
|
@@ -757,12 +759,10 @@ appropriate text.</p>
|
|
757
759
|
195
|
758
760
|
196
|
759
761
|
197
|
760
|
-
198
|
761
|
-
199
|
762
|
-
200</pre>
|
762
|
+
198</pre>
|
763
763
|
</td>
|
764
764
|
<td>
|
765
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
765
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 182</span>
|
766
766
|
|
767
767
|
<span class='kw'>def</span> <span class='id identifier rubyid_apply_tags'>apply_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='comma'>,</span> <span class='id identifier rubyid_tags'>tags</span><span class='rparen'>)</span>
|
768
768
|
<span class='id identifier rubyid_tags'>tags</span> <span class='op'>=</span> <span class='id identifier rubyid_tags'>tags</span><span class='period'>.</span><span class='id identifier rubyid_sort_by'>sort_by</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_x'>x</span><span class='op'>|</span> <span class='lbracket'>[</span><span class='id identifier rubyid_x'>x</span><span class='period'>.</span><span class='id identifier rubyid_idx'>idx</span><span class='comma'>,</span> <span class='op'>-</span><span class='id identifier rubyid_x'>x</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
|
@@ -850,18 +850,18 @@ appropriate text.</p>
|
|
850
850
|
<pre class="lines">
|
851
851
|
|
852
852
|
|
853
|
+
250
|
854
|
+
251
|
853
855
|
252
|
854
856
|
253
|
855
857
|
254
|
856
858
|
255
|
857
859
|
256
|
858
860
|
257
|
859
|
-
258
|
860
|
-
259
|
861
|
-
260</pre>
|
861
|
+
258</pre>
|
862
862
|
</td>
|
863
863
|
<td>
|
864
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
864
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 250</span>
|
865
865
|
|
866
866
|
<span class='kw'>def</span> <span class='id identifier rubyid_change_class'>change_class</span><span class='lparen'>(</span><span class='id identifier rubyid_change'>change</span><span class='rparen'>)</span>
|
867
867
|
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_change'>change</span><span class='period'>.</span><span class='id identifier rubyid_old_node'>old_node</span>
|
@@ -958,6 +958,8 @@ tags for each.</p>
|
|
958
958
|
<pre class="lines">
|
959
959
|
|
960
960
|
|
961
|
+
209
|
962
|
+
210
|
961
963
|
211
|
962
964
|
212
|
963
965
|
213
|
@@ -988,12 +990,10 @@ tags for each.</p>
|
|
988
990
|
238
|
989
991
|
239
|
990
992
|
240
|
991
|
-
241
|
992
|
-
242
|
993
|
-
243</pre>
|
993
|
+
241</pre>
|
994
994
|
</td>
|
995
995
|
<td>
|
996
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
996
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 209</span>
|
997
997
|
|
998
998
|
<span class='kw'>def</span> <span class='id identifier rubyid_change_tags'>change_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_changes'>changes</span><span class='comma'>,</span> <span class='id identifier rubyid_side'>side</span><span class='rparen'>)</span>
|
999
999
|
<span class='id identifier rubyid_tags'>tags</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
@@ -1048,13 +1048,13 @@ tags for each.</p>
|
|
1048
1048
|
<pre class="lines">
|
1049
1049
|
|
1050
1050
|
|
1051
|
+
60
|
1052
|
+
61
|
1051
1053
|
62
|
1052
|
-
63
|
1053
|
-
64
|
1054
|
-
65</pre>
|
1054
|
+
63</pre>
|
1055
1055
|
</td>
|
1056
1056
|
<td>
|
1057
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
1057
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 60</span>
|
1058
1058
|
|
1059
1059
|
<span class='kw'>def</span> <span class='id identifier rubyid_clear_uid'>clear_uid</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
1060
1060
|
<span class='ivar'>@uid_count</span> <span class='op'>=</span> <span class='op'>-</span><span class='int'>1</span>
|
@@ -1193,6 +1193,8 @@ tags for each.</p>
|
|
1193
1193
|
<pre class="lines">
|
1194
1194
|
|
1195
1195
|
|
1196
|
+
156
|
1197
|
+
157
|
1196
1198
|
158
|
1197
1199
|
159
|
1198
1200
|
160
|
@@ -1206,12 +1208,10 @@ tags for each.</p>
|
|
1206
1208
|
168
|
1207
1209
|
169
|
1208
1210
|
170
|
1209
|
-
171
|
1210
|
-
172
|
1211
|
-
173</pre>
|
1211
|
+
171</pre>
|
1212
1212
|
</td>
|
1213
1213
|
<td>
|
1214
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
1214
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 156</span>
|
1215
1215
|
|
1216
1216
|
<span class='kw'>def</span> <span class='id identifier rubyid_create_html'>create_html</span><span class='lparen'>(</span><span class='id identifier rubyid_changes'>changes</span><span class='comma'>,</span> <span class='id identifier rubyid_file1'>file1</span><span class='comma'>,</span> <span class='id identifier rubyid_file2'>file2</span><span class='comma'>,</span> <span class='id identifier rubyid_text1'>text1</span><span class='comma'>,</span> <span class='id identifier rubyid_text2'>text2</span><span class='rparen'>)</span>
|
1217
1217
|
<span class='id identifier rubyid_tags1'>tags1</span> <span class='op'>=</span> <span class='id identifier rubyid_change_tags'>change_tags</span><span class='lparen'>(</span><span class='id identifier rubyid_changes'>changes</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>left</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
@@ -1278,13 +1278,13 @@ tags for each.</p>
|
|
1278
1278
|
<pre class="lines">
|
1279
1279
|
|
1280
1280
|
|
1281
|
+
115
|
1282
|
+
116
|
1281
1283
|
117
|
1282
|
-
118
|
1283
|
-
119
|
1284
|
-
120</pre>
|
1284
|
+
118</pre>
|
1285
1285
|
</td>
|
1286
1286
|
<td>
|
1287
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
1287
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 115</span>
|
1288
1288
|
|
1289
1289
|
<span class='kw'>def</span> <span class='id identifier rubyid_html_footer'>html_footer</span>
|
1290
1290
|
<span class='id identifier rubyid_out'>out</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>%Q{</span><span class='tstring_content'></body>\n
|
@@ -1339,6 +1339,8 @@ tags for each.</p>
|
|
1339
1339
|
<pre class="lines">
|
1340
1340
|
|
1341
1341
|
|
1342
|
+
88
|
1343
|
+
89
|
1342
1344
|
90
|
1343
1345
|
91
|
1344
1346
|
92
|
@@ -1357,12 +1359,10 @@ tags for each.</p>
|
|
1357
1359
|
105
|
1358
1360
|
106
|
1359
1361
|
107
|
1360
|
-
108
|
1361
|
-
109
|
1362
|
-
110</pre>
|
1362
|
+
108</pre>
|
1363
1363
|
</td>
|
1364
1364
|
<td>
|
1365
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
1365
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 88</span>
|
1366
1366
|
|
1367
1367
|
<span class='kw'>def</span> <span class='id identifier rubyid_html_header'>html_header</span>
|
1368
1368
|
<span class='id identifier rubyid_install_path'>install_path</span> <span class='op'>=</span> <span class='id identifier rubyid_get_install_path'>get_install_path</span>
|
@@ -1470,6 +1470,9 @@ tags for each.</p>
|
|
1470
1470
|
<pre class="lines">
|
1471
1471
|
|
1472
1472
|
|
1473
|
+
279
|
1474
|
+
280
|
1475
|
+
281
|
1473
1476
|
282
|
1474
1477
|
283
|
1475
1478
|
284
|
@@ -1477,13 +1480,10 @@ tags for each.</p>
|
|
1477
1480
|
286
|
1478
1481
|
287
|
1479
1482
|
288
|
1480
|
-
289
|
1481
|
-
290
|
1482
|
-
291
|
1483
|
-
292</pre>
|
1483
|
+
289</pre>
|
1484
1484
|
</td>
|
1485
1485
|
<td>
|
1486
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
1486
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 279</span>
|
1487
1487
|
|
1488
1488
|
<span class='kw'>def</span> <span class='id identifier rubyid_link_start'>link_start</span><span class='lparen'>(</span><span class='id identifier rubyid_change'>change</span><span class='comma'>,</span> <span class='id identifier rubyid_side'>side</span><span class='rparen'>)</span>
|
1489
1489
|
<span class='id identifier rubyid_cls'>cls</span> <span class='op'>=</span> <span class='id identifier rubyid_change_class'>change_class</span><span class='lparen'>(</span><span class='id identifier rubyid_change'>change</span><span class='rparen'>)</span>
|
@@ -1565,12 +1565,12 @@ tags for each.</p>
|
|
1565
1565
|
<pre class="lines">
|
1566
1566
|
|
1567
1567
|
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1568
|
+
298
|
1569
|
+
299
|
1570
|
+
300</pre>
|
1571
1571
|
</td>
|
1572
1572
|
<td>
|
1573
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
1573
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 298</span>
|
1574
1574
|
|
1575
1575
|
<span class='kw'>def</span> <span class='id identifier rubyid_qs'>qs</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='rparen'>)</span>
|
1576
1576
|
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>'</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_s'>s</span><span class='embexpr_end'>}</span><span class='tstring_content'>'</span><span class='tstring_end'>"</span></span>
|
@@ -1594,8 +1594,6 @@ tags for each.</p>
|
|
1594
1594
|
|
1595
1595
|
<p>Takes a Change and creates a span tag.</p>
|
1596
1596
|
|
1597
|
-
<p>an insertion or deletion.</p>
|
1598
|
-
|
1599
1597
|
|
1600
1598
|
</div>
|
1601
1599
|
</div>
|
@@ -1614,7 +1612,7 @@ tags for each.</p>
|
|
1614
1612
|
|
1615
1613
|
—
|
1616
1614
|
<div class='inline'>
|
1617
|
-
<p>A single change
|
1615
|
+
<p>A single change, either an insertion or deletion.</p>
|
1618
1616
|
</div>
|
1619
1617
|
|
1620
1618
|
</li>
|
@@ -1646,12 +1644,12 @@ tags for each.</p>
|
|
1646
1644
|
<pre class="lines">
|
1647
1645
|
|
1648
1646
|
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1647
|
+
267
|
1648
|
+
268
|
1649
|
+
269</pre>
|
1652
1650
|
</td>
|
1653
1651
|
<td>
|
1654
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
1652
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 267</span>
|
1655
1653
|
|
1656
1654
|
<span class='kw'>def</span> <span class='id identifier rubyid_span_start'>span_start</span><span class='lparen'>(</span><span class='id identifier rubyid_change'>change</span><span class='rparen'>)</span>
|
1657
1655
|
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'><span class=</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_qs'>qs</span><span class='lparen'>(</span><span class='id identifier rubyid_change_class'>change_class</span><span class='lparen'>(</span><span class='id identifier rubyid_change'>change</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>></span><span class='tstring_end'>"</span></span>
|
@@ -1726,17 +1724,17 @@ already has one, fetch it from the hash and return it.</p>
|
|
1726
1724
|
<pre class="lines">
|
1727
1725
|
|
1728
1726
|
|
1727
|
+
74
|
1728
|
+
75
|
1729
1729
|
76
|
1730
1730
|
77
|
1731
1731
|
78
|
1732
1732
|
79
|
1733
1733
|
80
|
1734
|
-
81
|
1735
|
-
82
|
1736
|
-
83</pre>
|
1734
|
+
81</pre>
|
1737
1735
|
</td>
|
1738
1736
|
<td>
|
1739
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
1737
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 74</span>
|
1740
1738
|
|
1741
1739
|
<span class='kw'>def</span> <span class='id identifier rubyid_uid'>uid</span><span class='lparen'>(</span><span class='id identifier rubyid_node'>node</span><span class='rparen'>)</span>
|
1742
1740
|
<span class='kw'>if</span> <span class='ivar'>@uid_hash</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_node'>node</span><span class='rparen'>)</span>
|
@@ -1831,6 +1829,8 @@ already has one, fetch it from the hash and return it.</p>
|
|
1831
1829
|
<pre class="lines">
|
1832
1830
|
|
1833
1831
|
|
1832
|
+
128
|
1833
|
+
129
|
1834
1834
|
130
|
1835
1835
|
131
|
1836
1836
|
132
|
@@ -1844,12 +1844,10 @@ already has one, fetch it from the hash and return it.</p>
|
|
1844
1844
|
140
|
1845
1845
|
141
|
1846
1846
|
142
|
1847
|
-
143
|
1848
|
-
144
|
1849
|
-
145</pre>
|
1847
|
+
143</pre>
|
1850
1848
|
</td>
|
1851
1849
|
<td>
|
1852
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
1850
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 128</span>
|
1853
1851
|
|
1854
1852
|
<span class='kw'>def</span> <span class='id identifier rubyid_write_html'>write_html</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='comma'>,</span> <span class='id identifier rubyid_side'>side</span><span class='rparen'>)</span>
|
1855
1853
|
<span class='id identifier rubyid_out'>out</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span>
|
@@ -1877,7 +1875,7 @@ already has one, fetch it from the hash and return it.</p>
|
|
1877
1875
|
</div>
|
1878
1876
|
|
1879
1877
|
<div id="footer">
|
1880
|
-
Generated on
|
1878
|
+
Generated on Wed Sep 18 04:58:10 2013 by
|
1881
1879
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1882
1880
|
0.8.6.1 (ruby-2.0.0).
|
1883
1881
|
</div>
|
data/doc/SmartDiff.html
CHANGED
@@ -257,7 +257,7 @@
|
|
257
257
|
<li class="public ">
|
258
258
|
<span class="summary_signature">
|
259
259
|
|
260
|
-
<a href="#diff-instance_method" title="#diff (instance method)">- (java.util.ArrayList) <strong>diff</strong> </a>
|
260
|
+
<a href="#diff-instance_method" title="#diff (instance method)">- (java.util.ArrayList<DeepDiff>) <strong>diff</strong> </a>
|
261
261
|
|
262
262
|
|
263
263
|
|
@@ -671,7 +671,7 @@ on AST generated by JRubyParser.</p>
|
|
671
671
|
<div class="method_details first">
|
672
672
|
<h3 class="signature first" id="diff-instance_method">
|
673
673
|
|
674
|
-
- (<tt>java.util.ArrayList
|
674
|
+
- (<tt>java.util.ArrayList<DeepDiff></tt>) <strong>diff</strong>
|
675
675
|
|
676
676
|
|
677
677
|
|
@@ -682,8 +682,6 @@ on AST generated by JRubyParser.</p>
|
|
682
682
|
|
683
683
|
<p>Create a diff of the two AST objects.</p>
|
684
684
|
|
685
|
-
<p>org.jrubyparser.DeepDiff objects.</p>
|
686
|
-
|
687
685
|
|
688
686
|
</div>
|
689
687
|
</div>
|
@@ -695,13 +693,13 @@ on AST generated by JRubyParser.</p>
|
|
695
693
|
<li>
|
696
694
|
|
697
695
|
|
698
|
-
<span class='type'>(<tt>java.util.ArrayList
|
696
|
+
<span class='type'>(<tt>java.util.ArrayList<DeepDiff></tt>)</span>
|
699
697
|
|
700
698
|
|
701
699
|
|
702
700
|
—
|
703
701
|
<div class='inline'>
|
704
|
-
<p>
|
702
|
+
<p>The differences.</p>
|
705
703
|
</div>
|
706
704
|
|
707
705
|
</li>
|
@@ -714,6 +712,7 @@ on AST generated by JRubyParser.</p>
|
|
714
712
|
<pre class="lines">
|
715
713
|
|
716
714
|
|
715
|
+
58
|
717
716
|
59
|
718
717
|
60
|
719
718
|
61
|
@@ -722,11 +721,10 @@ on AST generated by JRubyParser.</p>
|
|
722
721
|
64
|
723
722
|
65
|
724
723
|
66
|
725
|
-
67
|
726
|
-
68</pre>
|
724
|
+
67</pre>
|
727
725
|
</td>
|
728
726
|
<td>
|
729
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff.rb', line
|
727
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff.rb', line 58</span>
|
730
728
|
|
731
729
|
<span class='kw'>def</span> <span class='id identifier rubyid_diff'>diff</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
732
730
|
<span class='ivar'>@code_one</span> <span class='op'>=</span> <span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='ivar'>@file_one</span><span class='rparen'>)</span>
|
@@ -755,7 +753,7 @@ on AST generated by JRubyParser.</p>
|
|
755
753
|
</h3><div class="docstring">
|
756
754
|
<div class="discussion">
|
757
755
|
|
758
|
-
<p>Parse the source into an abstract syntax tree
|
756
|
+
<p>Parse the source into an abstract syntax tree.</p>
|
759
757
|
|
760
758
|
|
761
759
|
</div>
|
@@ -810,7 +808,7 @@ on AST generated by JRubyParser.</p>
|
|
810
808
|
|
811
809
|
—
|
812
810
|
<div class='inline'>
|
813
|
-
<p>A Node object representing the code as
|
811
|
+
<p>A Node object representing the code as AST.</p>
|
814
812
|
</div>
|
815
813
|
|
816
814
|
</li>
|
@@ -932,7 +930,7 @@ on AST generated by JRubyParser.</p>
|
|
932
930
|
</div>
|
933
931
|
|
934
932
|
<div id="footer">
|
935
|
-
Generated on
|
933
|
+
Generated on Wed Sep 18 04:58:09 2013 by
|
936
934
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
937
935
|
0.8.6.1 (ruby-2.0.0).
|
938
936
|
</div>
|
data/doc/Tag.html
CHANGED
@@ -286,8 +286,6 @@ be linked to their matches.</p>
|
|
286
286
|
|
287
287
|
<p>Construct a new tag.</p>
|
288
288
|
|
289
|
-
<p>The end offset of the node if it is a closing tag. for a closing tag.</p>
|
290
|
-
|
291
289
|
|
292
290
|
</div>
|
293
291
|
</div>
|
@@ -322,7 +320,7 @@ be linked to their matches.</p>
|
|
322
320
|
|
323
321
|
—
|
324
322
|
<div class='inline'>
|
325
|
-
<p>
|
323
|
+
<p>for open tag: start offset. closing tag: end offset</p>
|
326
324
|
</div>
|
327
325
|
|
328
326
|
</li>
|
@@ -340,7 +338,7 @@ be linked to their matches.</p>
|
|
340
338
|
|
341
339
|
—
|
342
340
|
<div class='inline'>
|
343
|
-
<p>
|
341
|
+
<p>for open tag: -1. for closing tag: start offset.</p>
|
344
342
|
</div>
|
345
343
|
|
346
344
|
</li>
|
@@ -354,14 +352,14 @@ be linked to their matches.</p>
|
|
354
352
|
<pre class="lines">
|
355
353
|
|
356
354
|
|
355
|
+
27
|
356
|
+
28
|
357
357
|
29
|
358
358
|
30
|
359
|
-
31
|
360
|
-
32
|
361
|
-
33</pre>
|
359
|
+
31</pre>
|
362
360
|
</td>
|
363
361
|
<td>
|
364
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
362
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 27</span>
|
365
363
|
|
366
364
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_tag'>tag</span><span class='comma'>,</span> <span class='id identifier rubyid_idx'>idx</span><span class='comma'>,</span> <span class='id identifier rubyid_start'>start</span><span class='op'>=</span><span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span>
|
367
365
|
<span class='ivar'>@tag</span> <span class='op'>=</span> <span class='id identifier rubyid_tag'>tag</span>
|
@@ -558,12 +556,12 @@ be linked to their matches.</p>
|
|
558
556
|
<pre class="lines">
|
559
557
|
|
560
558
|
|
561
|
-
|
562
|
-
|
563
|
-
|
559
|
+
38
|
560
|
+
39
|
561
|
+
40</pre>
|
564
562
|
</td>
|
565
563
|
<td>
|
566
|
-
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line
|
564
|
+
<pre class="code"><span class="info file"># File 'lib/smart_diff/htmlize.rb', line 38</span>
|
567
565
|
|
568
566
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
|
569
567
|
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>tag: </span><span class='embexpr_beg'>#{</span><span class='ivar'>@tag</span><span class='embexpr_end'>}</span><span class='tstring_content'>, idx: </span><span class='embexpr_beg'>#{</span><span class='ivar'>@idx</span><span class='embexpr_end'>}</span><span class='tstring_content'> start: </span><span class='embexpr_beg'>#{</span><span class='ivar'>@start</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
@@ -578,7 +576,7 @@ be linked to their matches.</p>
|
|
578
576
|
</div>
|
579
577
|
|
580
578
|
<div id="footer">
|
581
|
-
Generated on
|
579
|
+
Generated on Wed Sep 18 04:58:09 2013 by
|
582
580
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
583
581
|
0.8.6.1 (ruby-2.0.0).
|
584
582
|
</div>
|
data/doc/Utils.html
CHANGED
@@ -568,7 +568,7 @@ the HTML.</p>
|
|
568
568
|
</div>
|
569
569
|
|
570
570
|
<div id="footer">
|
571
|
-
Generated on
|
571
|
+
Generated on Wed Sep 18 04:58:08 2013 by
|
572
572
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
573
573
|
0.8.6.1 (ruby-2.0.0).
|
574
574
|
</div>
|
data/doc/_index.html
CHANGED
@@ -140,7 +140,7 @@
|
|
140
140
|
</div>
|
141
141
|
|
142
142
|
<div id="footer">
|
143
|
-
Generated on
|
143
|
+
Generated on Wed Sep 18 04:58:07 2013 by
|
144
144
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
145
145
|
0.8.6.1 (ruby-2.0.0).
|
146
146
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -84,9 +84,9 @@ rather than comparing the text directly).</p>
|
|
84
84
|
|
85
85
|
<p>This application should especially serve as an example of using the
|
86
86
|
subdiff's produced by NodeDiff to improve the quality of the output.
|
87
|
-
See <
|
88
|
-
href="
|
89
|
-
docs</a>.</p>
|
87
|
+
See <a
|
88
|
+
href="https://github.com/edubkendo/smart_diff/blob/master/bin/smart_diff">bin/smart_diff</a>
|
89
|
+
or <a href="http://edubkendo.github.io/smart_diff/">check out the docs</a>.</p>
|
90
90
|
|
91
91
|
<h2 id="label-Install">Install</h2>
|
92
92
|
|
@@ -123,7 +123,7 @@ href="http://www.gnu.org/licenses">www.gnu.org/licenses</a>/.</p>
|
|
123
123
|
</div></div>
|
124
124
|
|
125
125
|
<div id="footer">
|
126
|
-
Generated on
|
126
|
+
Generated on Wed Sep 18 04:58:08 2013 by
|
127
127
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
128
128
|
0.8.6.1 (ruby-2.0.0).
|
129
129
|
</div>
|
data/doc/index.html
CHANGED
@@ -84,9 +84,9 @@ rather than comparing the text directly).</p>
|
|
84
84
|
|
85
85
|
<p>This application should especially serve as an example of using the
|
86
86
|
subdiff's produced by NodeDiff to improve the quality of the output.
|
87
|
-
See <
|
88
|
-
href="
|
89
|
-
docs</a>.</p>
|
87
|
+
See <a
|
88
|
+
href="https://github.com/edubkendo/smart_diff/blob/master/bin/smart_diff">bin/smart_diff</a>
|
89
|
+
or <a href="http://edubkendo.github.io/smart_diff/">check out the docs</a>.</p>
|
90
90
|
|
91
91
|
<h2 id="label-Install">Install</h2>
|
92
92
|
|
@@ -123,7 +123,7 @@ href="http://www.gnu.org/licenses">www.gnu.org/licenses</a>/.</p>
|
|
123
123
|
</div></div>
|
124
124
|
|
125
125
|
<div id="footer">
|
126
|
-
Generated on
|
126
|
+
Generated on Wed Sep 18 04:58:07 2013 by
|
127
127
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
128
128
|
0.8.6.1 (ruby-2.0.0).
|
129
129
|
</div>
|
@@ -105,7 +105,7 @@
|
|
105
105
|
</div>
|
106
106
|
|
107
107
|
<div id="footer">
|
108
|
-
Generated on
|
108
|
+
Generated on Wed Sep 18 04:58:08 2013 by
|
109
109
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
110
110
|
0.8.6.1 (ruby-2.0.0).
|
111
111
|
</div>
|
data/lib/smart_diff.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "jruby-parser"
|
2
2
|
require "pathname"
|
3
3
|
require "jruby-parser.jar"
|
4
|
+
import org.jrubyparser.lexer.SyntaxException
|
4
5
|
|
5
6
|
import org.jrubyparser.util.diff.NodeDiff
|
6
7
|
|
@@ -41,21 +42,28 @@ class SmartDiff
|
|
41
42
|
|
42
43
|
#
|
43
44
|
# Parse the source into an abstract syntax tree.
|
45
|
+
#
|
44
46
|
# @param code_to_parse [String] Ruby source code.
|
45
47
|
# @param file_name [String] The path to the file containing code_to_parse
|
46
48
|
#
|
47
|
-
# @return [org.jrubyparser.Node] A Node object representing the code as
|
48
|
-
# AST.
|
49
|
+
# @return [org.jrubyparser.Node] A Node object representing the code as AST.
|
49
50
|
def parse(code_to_parse, file_name)
|
50
|
-
|
51
|
+
begin
|
52
|
+
JRubyParser.parse(code_to_parse, { :filename => file_name })
|
53
|
+
rescue SyntaxException => e
|
54
|
+
message = e.message
|
55
|
+
message << "\nThis file, #{file_name} ,is not valid ruby."
|
56
|
+
message << "\nCheck syntax and try again."
|
57
|
+
se = SyntaxException.new(e.pid, e.position, message)
|
58
|
+
raise se
|
59
|
+
end
|
51
60
|
end
|
52
61
|
|
53
62
|
|
54
63
|
#
|
55
64
|
# Create a diff of the two AST objects.
|
56
65
|
#
|
57
|
-
# @return [java.util.ArrayList]
|
58
|
-
# org.jrubyparser.DeepDiff objects.
|
66
|
+
# @return [java.util.ArrayList<DeepDiff>] The differences.
|
59
67
|
def diff()
|
60
68
|
@code_one = read(@file_one)
|
61
69
|
@code_two = read(@file_two)
|
data/lib/smart_diff/htmlize.rb
CHANGED
@@ -20,10 +20,8 @@ class Tag
|
|
20
20
|
# Construct a new tag.
|
21
21
|
#
|
22
22
|
# @param tag [String] An HTML tag.
|
23
|
-
# @param idx [Fixnum]
|
24
|
-
#
|
25
|
-
# @param start [Fixnum] Left -1 for an open tag, the node's start offset
|
26
|
-
# for a closing tag.
|
23
|
+
# @param idx [Fixnum] for open tag: start offset. closing tag: end offset
|
24
|
+
# @param start [Fixnum] for open tag: -1. for closing tag: start offset.
|
27
25
|
#
|
28
26
|
# @return [Tag] The Tag which was constructed.
|
29
27
|
def initialize(tag, idx, start=-1)
|
@@ -263,8 +261,7 @@ class Htmlize
|
|
263
261
|
#
|
264
262
|
# Takes a Change and creates a span tag.
|
265
263
|
#
|
266
|
-
# @param change [Change] A single change
|
267
|
-
# an insertion or deletion.
|
264
|
+
# @param change [Change] A single change, either an insertion or deletion.
|
268
265
|
#
|
269
266
|
# @return [String] A span tag based on the Change passed in.
|
270
267
|
def span_start(change)
|
data/spec/smart_diff_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "smart_diff"
|
2
|
+
import org.jrubyparser.lexer.SyntaxException
|
2
3
|
|
3
4
|
describe "SmartDiff" do
|
4
5
|
before(:each) do
|
@@ -23,6 +24,11 @@ describe "SmartDiff" do
|
|
23
24
|
@rd.parse(code_for_parse, @rd.file_one).instance_of?(org.jrubyparser.ast.RootNode).should be(true)
|
24
25
|
end
|
25
26
|
|
27
|
+
it "should raise an exception if the code is invalid ruby" do
|
28
|
+
code_for_parse = "Def BadRubyCodeIsBAda end puts cLas$"
|
29
|
+
expect { @rd.parse(code_for_parse, @rd.file_one) }.to raise_error(SyntaxException)
|
30
|
+
end
|
31
|
+
|
26
32
|
it "should create a diff of the two ASTs" do
|
27
33
|
@rd.node_diff.size.should >= 1
|
28
34
|
end
|