hmachine 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.gitignore +2 -2
  2. data/Gemfile +6 -4
  3. data/Gemfile.lock +51 -0
  4. data/README.md +123 -9
  5. data/Rakefile +12 -3
  6. data/bin/hmachine +99 -0
  7. data/hmachine.gemspec +132 -0
  8. data/lib/hmachine.rb +121 -12
  9. data/lib/hmachine/microformat.rb +39 -20
  10. data/lib/hmachine/microformat/adr.rb +22 -0
  11. data/lib/hmachine/microformat/geo.rb +48 -0
  12. data/lib/hmachine/microformat/hcard.rb +169 -11
  13. data/lib/hmachine/microformat/rellicense.rb +20 -0
  14. data/lib/hmachine/microformat/reltag.rb +38 -0
  15. data/lib/hmachine/microformat/votelinks.rb +42 -0
  16. data/lib/hmachine/microformat/xfn.rb +54 -0
  17. data/lib/hmachine/microformat/xmdp.rb +14 -0
  18. data/lib/hmachine/microformat/xoxo.rb +69 -0
  19. data/lib/hmachine/pattern.rb +26 -0
  20. data/lib/hmachine/pattern/abbr.rb +21 -0
  21. data/lib/hmachine/pattern/datetime.rb +75 -0
  22. data/lib/hmachine/pattern/typevalue.rb +32 -0
  23. data/lib/hmachine/pattern/url.rb +32 -0
  24. data/lib/hmachine/pattern/valueclass.rb +51 -0
  25. data/lib/hmachine/posh.rb +3 -0
  26. data/lib/hmachine/posh/anchor.rb +40 -0
  27. data/lib/hmachine/posh/base.rb +204 -0
  28. data/lib/hmachine/posh/definition_list.rb +41 -0
  29. data/test/fixtures/huffduffer.html +466 -0
  30. data/test/fixtures/likeorhate.html +48 -0
  31. data/test/fixtures/rel_license.html +4 -0
  32. data/test/fixtures/test-fixture/hcard/hcard1.html +147 -0
  33. data/test/fixtures/test-fixture/hcard/hcard11.html +123 -0
  34. data/test/fixtures/test-fixture/hcard/hcard12.html +178 -0
  35. data/test/fixtures/test-fixture/hcard/hcard17.html +165 -0
  36. data/test/fixtures/test-fixture/hcard/hcard2.html +264 -0
  37. data/test/fixtures/test-fixture/hcard/hcard3.html +144 -0
  38. data/test/fixtures/test-fixture/hcard/hcard4.html +117 -0
  39. data/test/fixtures/test-fixture/hcard/hcard5.html +119 -0
  40. data/test/fixtures/test-fixture/hcard/hcard6.html +188 -0
  41. data/test/fixtures/test-fixture/hcard/hcard7.html +188 -0
  42. data/test/fixtures/test-fixture/hcard/hcard8.html +130 -0
  43. data/test/fixtures/test-fixture/hcard/hcard9.html +111 -0
  44. data/test/fixtures/test-fixture/hcard/hcard99.html +215 -0
  45. data/test/fixtures/test-fixture/value-class-date-time/value-dt-test-YYYY-MM-DD--HH-MM.html +9 -0
  46. data/test/fixtures/test-fixture/value-class-date-time/value-dt-test-abbr-YYYY-MM-DD--HH-MM.html +4 -0
  47. data/test/fixtures/xfn.html +198 -0
  48. data/test/fixtures/xmdp.html +32 -0
  49. data/test/fixtures/xoxo.html +51 -0
  50. data/test/hmachine_test.rb +122 -6
  51. data/test/microformat/adr_test.rb +47 -0
  52. data/test/microformat/geo_test.rb +66 -0
  53. data/test/microformat/hcard_test.rb +487 -20
  54. data/test/microformat/rellicense_test.rb +36 -0
  55. data/test/microformat/reltag_test.rb +61 -0
  56. data/test/microformat/votelinks_test.rb +44 -0
  57. data/test/microformat/xfn_test.rb +28 -0
  58. data/test/microformat/xmdp_test.rb +16 -0
  59. data/test/microformat/xoxo_test.rb +51 -0
  60. data/test/microformat_test.rb +12 -34
  61. data/test/pattern/date_time_test.rb +55 -0
  62. data/test/pattern/value_class_test.rb +33 -0
  63. data/test/pattern_test.rb +132 -0
  64. data/test/posh/anchor_test.rb +41 -0
  65. data/test/posh/base_test.rb +150 -0
  66. data/test/posh/definition_list_test.rb +38 -0
  67. data/test/test_helper.rb +24 -6
  68. metadata +93 -15
  69. data/lib/hmachine/microformat/base.rb +0 -17
@@ -0,0 +1,130 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
+ <title>hCard 8 - extracting URLs test</title>
7
+
8
+ <!-- This will be replace with one CSS file and one JavaScipt file -->
9
+ <link rel="stylesheet" href="../css/uftestsuite.css" type="text/css" />
10
+ <link rel="stylesheet" href="../../../testrunner/css/testrunner.css" type="text/css" />
11
+
12
+ <script type="text/javascript" src="../../testrunner/javascript/prototype-1.6.0.2.js"></script>
13
+ <script type="text/javascript" src="../../testrunner/javascript/beautify.js"></script>
14
+ <script type="text/javascript" src="../../testrunner/javascript/sumo/microformat.js"></script>
15
+ <script type="application/javascript;version=1.7" src="http://svn.mozilla.org/labs/operator/chrome/operator/content/Microformats/Microformats.js"></script>
16
+ <script type="text/javascript" src="../../testrunner/javascript/testrunner.js"></script>
17
+
18
+
19
+ </head>
20
+ <body>
21
+
22
+ <div class="test-fixture">
23
+
24
+ <p>
25
+ <a href="../"><img border="0" id="testsuite-image" alt="Microformats test suite" src="../images/testsuite.gif" /></a><br />
26
+ </p>
27
+
28
+ <h1 class="summary">hCard 8 - extracting URLs test</h1>
29
+ <p class="description">This page test that parsers can extract URLs from differnt structures.</p>
30
+ <p>From: <a href="default.htm"><span class="format">hCard</span> test suite 1.0</a></p>
31
+ <p class="author vcard">
32
+ Author: <a class="url fn" href="http://www.glennjones.net/">Glenn Jones</a>
33
+ </p>
34
+ <!--
35
+ <p>Output examples:
36
+ <ul>
37
+ <li class="output"><a class="url" href="hcard1.js"><span class="type">JSON</span></a></li>
38
+ <li class="output"><a class="url" href="hcard1.xml"><span class="type">XML</span></a></li>
39
+ </ul>
40
+ </p>
41
+ -->
42
+
43
+ <p>Tests:</p>
44
+ <table id="assetTable" cellpadding="0" cellspacing="0">
45
+ <thead>
46
+ <tr>
47
+ <th>Test</th>
48
+ <th>Result</th>
49
+ <th>Comment</th>
50
+ </tr>
51
+ </thead>
52
+ <tbody>
53
+
54
+ <tr class="assert">
55
+ <td class="test">vcard[0].url[0]</td>
56
+ <td class="result">IsEqualTo("http://example.com/johndoe/")</td>
57
+ <td class="comment">Should collect the URL from the a element</td>
58
+ </tr>
59
+
60
+ <tr class="assert">
61
+ <td class="test">vcard[1].url[0]</td>
62
+ <td class="result">IsEqualTo("http://example.com/johndoe/")</td>
63
+ <td class="comment">Should collect the URL from the area element</td>
64
+ </tr>
65
+
66
+ <tr class="assert">
67
+ <td class="test">vcard[2].photo[0]</td>
68
+ <td class="result">IsEqualTo("http://ufxtract.com/testsuite/images/photo.gif")</td>
69
+ <td class="comment">Should collect the URL of the image element</td>
70
+ </tr>
71
+
72
+
73
+ </tbody>
74
+ </table>
75
+
76
+
77
+ <p>History:</p>
78
+ <ul>
79
+ <li class="history vevent">
80
+ <span class="summary">Created</span>: <abbr class="dtstart" title="2008-05-10">10 May 2008</abbr>
81
+ <span class="description">by Glenn Jones</span>
82
+ </li>
83
+ </ul>
84
+
85
+
86
+
87
+ </div>
88
+
89
+ <div id="uf">
90
+ <!-- This may not be the best semantic use of HTML element -->
91
+
92
+ <!-- 0 -->
93
+ <p class="vcard">
94
+ <span class="fn">John Doe</span> -
95
+ <a href="http://example.com/johndoe/" class="url">Blog</a>:
96
+ </p>
97
+
98
+ <!-- 1 -->
99
+ <p class="vcard">
100
+ <span class="fn">John Doe</span> -
101
+ <img src="http://ufxtract.com/testsuite/images/photo.gif" class="photo" usemap="#people"/>
102
+ <map id="#people" name="#people">
103
+ <area class="url" shape ="rect" coords ="0,0,20,20" href="http://example.com/johndoe/" alt="John Doe" />
104
+ </map>
105
+ </p>
106
+
107
+ <!-- 2 -->
108
+ <p class="vcard">
109
+ <span class="fn">John Doe</span>
110
+ <img src="http://ufxtract.com/testsuite/images/photo.gif" class="photo" />
111
+ </p>
112
+
113
+ <!-- 4 Could not htink of a practical example
114
+ <p class="vcard">
115
+ <span class="fn">John Doe</span> -
116
+ <object data="http://example.com/johndoe/" class="photo" />
117
+ </p>
118
+ -->
119
+
120
+
121
+ </div>
122
+
123
+ <p>
124
+ <a rel="license" href="../license.txt">Some rights reserved</a>
125
+ </p>
126
+
127
+
128
+ </body>
129
+
130
+ </html>
@@ -0,0 +1,111 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
+ <title>hCard 9 - extracting Geo test</title>
7
+
8
+ <!-- This will be replace with one CSS file and one JavaScipt file -->
9
+ <link rel="stylesheet" href="../css/uftestsuite.css" type="text/css" />
10
+ <link rel="stylesheet" href="../../../testrunner/css/testrunner.css" type="text/css" />
11
+
12
+ <script type="text/javascript" src="../../testrunner/javascript/prototype-1.6.0.2.js"></script>
13
+ <script type="text/javascript" src="../../testrunner/javascript/beautify.js"></script>
14
+ <script type="text/javascript" src="../../testrunner/javascript/sumo/microformat.js"></script>
15
+ <script type="application/javascript;version=1.7" src="http://svn.mozilla.org/labs/operator/chrome/operator/content/Microformats/Microformats.js"></script>
16
+ <script type="text/javascript" src="../../testrunner/javascript/testrunner.js"></script>
17
+
18
+ </head>
19
+ <body>
20
+
21
+ <div class="test-fixture">
22
+
23
+ <p>
24
+ <a href="../"><img border="0" id="testsuite-image" alt="Microformats test suite" src="../images/testsuite.gif" /></a><br />
25
+ </p>
26
+
27
+ <h1 class="summary">hCard 9 - extracting geo singular and paired values test</h1>
28
+ <p class="description">This page was design to comprehensively test the geo format. Most of these tests are based on <span class="vcard"><a href="http://www.kaply.com/weblog/"class="fn url">Mike Kaply</a></span> work for the
29
+ Firefox. The IsEqualToGeo method <a href="../documentation/geo.htm">canonicalise and compares</a> geo's.</p>
30
+ <p>From: <a href="default.htm"><span class="format">hCard</span> test suite 1.0</a></p>
31
+ <p class="author vcard">
32
+ Author: <a class="url fn" href="http://www.glennjones.net/">Glenn Jones</a>
33
+ </p>
34
+ <!--
35
+ <p>Output examples:
36
+ <ul>
37
+ <li class="output"><a class="url" href="hcard1.js"><span class="type">JSON</span></a></li>
38
+ <li class="output"><a class="url" href="hcard1.xml"><span class="type">XML</span></a></li>
39
+ </ul>
40
+ </p>
41
+ -->
42
+
43
+ <p>Tests:</p>
44
+ <table id="assetTable" cellpadding="0" cellspacing="0">
45
+ <thead>
46
+ <tr>
47
+ <th>Test</th>
48
+ <th>Result</th>
49
+ <th>Comment</th>
50
+ </tr>
51
+ </thead>
52
+ <tbody>
53
+
54
+ <tr class="assert">
55
+ <td class="test">vcard[0].geo.latitude</td>
56
+ <td class="result">IsEqualToGeo("37.77")</td>
57
+ <td class="comment">Should find latitude value from single element</td>
58
+ </tr>
59
+
60
+ <tr class="assert">
61
+ <td class="test">vcard[1].geo.latitude</td>
62
+ <td class="result">IsEqualToGeo("37.77")</td>
63
+ <td class="comment">Should extract latitude value from paired value</td>
64
+ </tr>
65
+
66
+
67
+ </tbody>
68
+ </table>
69
+
70
+
71
+ <p>History:</p>
72
+ <ul>
73
+ <li class="history vevent">
74
+ <span class="summary">Created</span>: <abbr class="dtstart" title="2008-05-10">10 May 2008</abbr>
75
+ <span class="description">by Glenn Jones</span>
76
+ </li>
77
+ </ul>
78
+
79
+
80
+
81
+ </div>
82
+
83
+ <div id="uf">
84
+ <!-- This may not be the best semantic use of HTML element -->
85
+
86
+ <!-- 0 -->
87
+ <div class="vcard">
88
+ <span class="fn">John Doe</span> -
89
+ <span class="geo">
90
+ <abbr class="latitude" title="37.77">Northern</abbr>
91
+ <abbr class="longitude" title="-122.41">California</abbr>
92
+ </span>
93
+ </div>
94
+
95
+ <!-- 1 -->
96
+ <div class="vcard">
97
+ <span class="fn">John Doe</span> -
98
+ <abbr class="geo" title="37.77;-122.41">Northern California</abbr>
99
+ </div>
100
+
101
+ </div>
102
+
103
+
104
+ <p>
105
+ <a rel="license" href="../license.txt">Some rights reserved</a>
106
+ </p>
107
+
108
+
109
+ </body>
110
+
111
+ </html>
@@ -0,0 +1,215 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
+ <title>hCard 99 - implied n optimization test</title>
7
+
8
+ <!-- This will be replace with one CSS file and one JavaScipt file -->
9
+ <link rel="stylesheet" href="../css/uftestsuite.css" type="text/css" />
10
+ <link rel="stylesheet" href="../../testrunner/css/testrunner.css" type="text/css" />
11
+
12
+ <script type="text/javascript" src="../../testrunner/javascript/prototype-1.6.0.2.js"></script>
13
+ <script type="text/javascript" src="../../testrunner/javascript/beautify.js"></script>
14
+ <script type="text/javascript" src="../../testrunner/javascript/sumo/microformat.js"></script>
15
+ <script type="application/javascript;version=1.7" src="http://svn.mozilla.org/labs/operator/chrome/operator/content/Microformats/Microformats.js"></script>
16
+ <script type="text/javascript" src="../../testrunner/javascript/testrunner.js"></script>
17
+
18
+ </head>
19
+ <body>
20
+
21
+ <div class="test-fixture">
22
+
23
+ <p>
24
+ <a href="../"><img border="0" id="testsuite-image" alt="Microformats test suite" src="../images/testsuite.gif" /></a><br />
25
+ </p>
26
+
27
+ <h1 class="summary">hCard 99 - implied n optimization test</h1>
28
+ <p class="description">This page was design to test the implied "n" optimization which is explained
29
+ on the wiki <a href="http://microformats.org/wiki/hcard#Implied_.22n.22_Optimization">http://microformats.org/wiki/hcard#Implied_.22n.22_Optimization</a>.
30
+ Examples copied from the orginal test suite.
31
+ </p>
32
+ <p>From: <a href="default.htm"><span class="format">hCard</span> test suite 1.0</a></p>
33
+ <p class="author vcard">
34
+ Author: <a class="url fn" href="http://www.glennjones.net/">Glenn Jones</a>
35
+ </p>
36
+ <!--
37
+ <p>Output examples:
38
+ <ul>
39
+ <li class="output"><a class="url" href="hcard1.js"><span class="type">JSON</span></a></li>
40
+ <li class="output"><a class="url" href="hcard1.xml"><span class="type">XML</span></a></li>
41
+ </ul>
42
+ </p>
43
+ -->
44
+
45
+ <p>Tests:</p>
46
+ <table id="assetTable" cellpadding="0" cellspacing="0">
47
+ <thead>
48
+ <tr>
49
+ <th>Test</th>
50
+ <th>Result</th>
51
+ <th>Comment</th>
52
+ </tr>
53
+ </thead>
54
+ <tbody>
55
+ <tr class="assert">
56
+ <td class="test">vcard[0].n.given-name[0]</td>
57
+ <td class="result">IsEqualTo("Ryan")</td>
58
+ <td class="comment">The given-name value is implied from the fn value</td>
59
+ </tr>
60
+ <tr class="assert">
61
+ <td class="test">vcard[0].n.family-name[0]</td>
62
+ <td class="result">IsEqualTo("King")</td>
63
+ <td class="comment">The family-name value is implied from the fn value</td>
64
+ </tr>
65
+ <tr class="assert">
66
+ <td class="test">vcard[1].n.given-name[0]</td>
67
+ <td class="result">IsEqualTo("Ryan")</td>
68
+ <td class="comment">The given-name value is implied from the fn value</td>
69
+ </tr>
70
+ <tr class="assert">
71
+ <td class="test">vcard[1].n.family-name[0]</td>
72
+ <td class="result">IsEqualTo("King")</td>
73
+ <td class="comment">The family-name value is implied from the fn value</td>
74
+ </tr>
75
+ <tr class="assert">
76
+ <td class="test">vcard[2].n.given-name[0]</td>
77
+ <td class="result">IsEqualTo("Ryan")</td>
78
+ <td class="comment">The given-name value is implied from the fn value</td>
79
+ </tr>
80
+ <tr class="assert">
81
+ <td class="test">vcard[2].n.family-name[0]</td>
82
+ <td class="result">IsEqualTo("King")</td>
83
+ <td class="comment">The family-name value is implied from the fn value</td>
84
+ </tr>
85
+ <tr class="assert">
86
+ <td class="test">vcard[3].n.given-name[0]</td>
87
+ <td class="result">IsEqualTo("Brian")</td>
88
+ <td class="comment">The given-name value is implied from the fn value</td>
89
+ </tr>
90
+ <tr class="assert">
91
+ <td class="test">vcard[3].n.family-name[0]</td>
92
+ <td class="result">IsEqualTo("Suda")</td>
93
+ <td class="comment">The family-name value is implied from the fn value</td>
94
+ </tr>
95
+ <tr class="assert">
96
+ <td class="test">vcard[4].n.given-name[0]</td>
97
+ <td class="result">IsEqualTo("Ryan")</td>
98
+ <td class="comment">The given-name value is implied from the fn value</td>
99
+ </tr>
100
+ <tr class="assert">
101
+ <td class="test">vcard[4].n.family-name[0]</td>
102
+ <td class="result">IsEqualTo("King")</td>
103
+ <td class="comment">The family-name value is implied from the fn value</td>
104
+ </tr>
105
+ <tr class="assert">
106
+ <td class="test">vcard[5].n.given-name[0]</td>
107
+ <td class="result">IsEqualTo("R")</td>
108
+ <td class="comment">The given-name value is implied from the fn value</td>
109
+ </tr>
110
+ <tr class="assert">
111
+ <td class="test">vcard[5].n.family-name[0]</td>
112
+ <td class="result">IsEqualTo("King")</td>
113
+ <td class="comment">The family-name value is implied from the fn value</td>
114
+ </tr>
115
+ <tr class="assert">
116
+ <td class="test">vcard[6].n.given-name[0]</td>
117
+ <td class="result">IsEqualTo("R")</td>
118
+ <td class="comment">The given-name value is implied from the fn value</td>
119
+ </tr>
120
+ <tr class="assert">
121
+ <td class="test">vcard[6].n.family-name[0]</td>
122
+ <td class="result">IsEqualTo("King")</td>
123
+ <td class="comment">The family-name value is implied from the fn value</td>
124
+ </tr>
125
+
126
+ <tr class="assert">
127
+ <td class="test">vcard[7].n.given-name</td>
128
+ <td class="result">HasProperty(false)</td>
129
+ <td class="comment">The given-name property should be missing</td>
130
+ </tr>
131
+ <tr class="assert">
132
+ <td class="test">vcard[7].n.family-name</td>
133
+ <td class="result">HasProperty(false)</td>
134
+ <td class="comment">The family-name property should be missing</td>
135
+ </tr>
136
+
137
+ <tr class="assert">
138
+ <td class="test">vcard[8].n.given-name</td>
139
+ <td class="result">HasProperty(false)</td>
140
+ <td class="comment">The given-name property should be missing</td>
141
+ </tr>
142
+ <tr class="assert">
143
+ <td class="test">vcard[8].n.family-name</td>
144
+ <td class="result">HasProperty(false)</td>
145
+ <td class="comment">The family-name property should be missing</td>
146
+ </tr>
147
+
148
+
149
+
150
+ </tbody>
151
+ </table>
152
+
153
+
154
+ <p>History:</p>
155
+ <ul>
156
+ <li class="history vevent">
157
+ <span class="summary">Created</span>: <abbr class="dtstart" title="2008-04-08">8 April 2008</abbr>
158
+ <span class="description">by Glenn Jones</span>
159
+ </li>
160
+ </ul>
161
+
162
+
163
+
164
+ </div>
165
+
166
+ <div id="uf">
167
+ <!-- This may not be the best semantic use of HTML element -->
168
+
169
+ <p class="vcard">
170
+ <span class="fn">Ryan King</span>
171
+ </p>
172
+
173
+ <p class="vcard">
174
+ <abbr class="fn" title="Ryan King">me</abbr>
175
+ </p>
176
+
177
+ <p class="vcard">
178
+ <img src="/me.jpg" title="Brian Suda" alt="Ryan King" class="fn" />
179
+ </p>
180
+
181
+ <p class="vcard">
182
+ <a class="fn" href="http://suda.co.uk/">Brian Suda</a>
183
+ </p>
184
+
185
+ <p class="vcard">
186
+ <span class="fn">King, Ryan</span>
187
+ </p>
188
+
189
+ <p class="vcard">
190
+ <span class="fn">King, R</span>
191
+ </p>
192
+
193
+ <p class="vcard">
194
+ <span class="fn">King R</span>
195
+ </p>
196
+
197
+ <p class="vcard">
198
+ <span class="fn">Jesse James Garrett</span>
199
+ </p>
200
+
201
+ <p class="vcard">
202
+ <span class="fn">Thomas Vander Wal</span>
203
+ </p>
204
+
205
+
206
+ </div>
207
+
208
+ <p>
209
+ <a rel="license" href="../license.txt">Some rights reserved</a>
210
+ </p>
211
+
212
+
213
+ </body>
214
+
215
+ </html>