mofo 0.1.2 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/README +16 -6
- data/lib/microformat.rb +59 -20
- data/lib/microformat/array.rb +5 -0
- data/lib/microformat/simple.rb +16 -18
- data/lib/microformat/string.rb +1 -1
- data/lib/mofo.rb +1 -1
- data/lib/mofo/adr.rb +6 -0
- data/lib/mofo/geo.rb +3 -0
- data/lib/mofo/hcalendar.rb +5 -2
- data/lib/mofo/hcard.rb +7 -12
- data/lib/mofo/hentry.rb +1 -1
- data/lib/mofo/hresume.rb +17 -0
- data/lib/mofo/rel_bookmark.rb +6 -0
- data/lib/mofo/xfn.rb +66 -0
- data/lib/mofo/xoxo.rb +37 -39
- data/test/ext_test.rb +44 -0
- data/test/fixtures/event_addr.html +26 -0
- data/test/fixtures/hresume.html +409 -0
- data/test/fixtures/include_pattern_single_attribute.html +246 -0
- data/test/fixtures/upcoming_single.html +479 -0
- data/test/fixtures/xfn.html +200 -0
- data/test/format_test.rb +1 -1
- data/test/hatom_test.rb +5 -6
- data/test/hcalendar_test.rb +33 -0
- data/test/hcard_test.rb +132 -0
- data/test/hresume_test.rb +23 -0
- data/test/hreview_test.rb +36 -0
- data/test/include_pattern_test.rb +27 -0
- data/test/reltag_test.rb +40 -0
- data/test/test_helper.rb +9 -2
- data/test/xfn_test.rb +76 -0
- data/test/xoxo_test.rb +1 -1
- metadata +31 -4
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'mofo/hcard'
|
3
|
+
|
4
|
+
context "Multiple attributes within a container" do
|
5
|
+
setup do
|
6
|
+
$hcards ||= HCard.find(:all => fixture(:hresume))
|
7
|
+
$included ||= $hcards.first
|
8
|
+
$including ||= $hcards[1]
|
9
|
+
end
|
10
|
+
|
11
|
+
specify "should be referenceable by a microformat using the include pattern" do
|
12
|
+
%w(fn n).each do |att|
|
13
|
+
$including.send(att).should.equal $included.send(att)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "A single attribute" do
|
19
|
+
setup do
|
20
|
+
$horsed ||= HCard.find(:first => fixture(:include_pattern_single_attribute))
|
21
|
+
end
|
22
|
+
|
23
|
+
specify "should be referenceable by a microformat using the include pattern" do
|
24
|
+
$horsed.logo.should.not.be.nil
|
25
|
+
$horsed.logo.should.equal Hpricot(open fixture(:include_pattern_single_attribute)).at("#logo").attributes['src']
|
26
|
+
end
|
27
|
+
end
|
data/test/reltag_test.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'mofo/rel_tag'
|
3
|
+
|
4
|
+
context "An array of reltag arrays created from the corkd review webpage" do
|
5
|
+
setup do
|
6
|
+
$tags ||= RelTag.find(:all => fixture(:corkd))
|
7
|
+
end
|
8
|
+
|
9
|
+
specify "should consist of 23 tags" do
|
10
|
+
$tags.size.should.equal 23
|
11
|
+
end
|
12
|
+
|
13
|
+
specify "should include the berry and slippery tags" do
|
14
|
+
$tags.flatten.should.include 'berry'
|
15
|
+
$tags.flatten.should.include 'slippery'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "A web page with three rel tags" do
|
20
|
+
setup do
|
21
|
+
$page ||= <<-EOF
|
22
|
+
<html>
|
23
|
+
<body>
|
24
|
+
<ul>
|
25
|
+
<li><a href="/tags/miracle" rel="tag">miracle</a></li>
|
26
|
+
<li><a href="/tags/wonder" rel="tag">wonder</a></li>
|
27
|
+
<li><a href="/tags/amusement" rel="tag">amusement</a></li>
|
28
|
+
</ul>
|
29
|
+
</body>
|
30
|
+
</html>
|
31
|
+
EOF
|
32
|
+
end
|
33
|
+
|
34
|
+
specify "should produce an array of three RelTag objects" do
|
35
|
+
tags = RelTag.find(:all, :text => $page)
|
36
|
+
tags.should.be.an.instance_of Array
|
37
|
+
tags.size.should.equal 3
|
38
|
+
tags.should.equal ["miracle", "wonder", "amusement"]
|
39
|
+
end
|
40
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
-
$:.unshift 'lib/'
|
2
|
-
require 'vendor/testspec-0.3.0/lib/test/spec'
|
1
|
+
$:.unshift 'lib/', File.dirname(__FILE__) + '/../lib'
|
2
|
+
require File.dirname(__FILE__) + '/../vendor/testspec-0.3.0/lib/test/spec'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
require 'redgreen'
|
7
|
+
rescue LoadError
|
8
|
+
nil
|
9
|
+
end
|
3
10
|
|
4
11
|
def fixture(name)
|
5
12
|
File.dirname(__FILE__) + "/fixtures/#{name}.html"
|
data/test/xfn_test.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'mofo/xfn'
|
3
|
+
|
4
|
+
def xfn_setup
|
5
|
+
$xfn ||= XFN.find(:first => fixture(:xfn))
|
6
|
+
end
|
7
|
+
|
8
|
+
context "A XFN object" do
|
9
|
+
setup do
|
10
|
+
xfn_setup
|
11
|
+
end
|
12
|
+
|
13
|
+
specify "should know what relations it contains" do
|
14
|
+
$xfn.relations.should.be.an.instance_of Array
|
15
|
+
$xfn.relations.should.include 'me'
|
16
|
+
end
|
17
|
+
|
18
|
+
specify "should give information about a relationship" do
|
19
|
+
me = $xfn.me
|
20
|
+
me.should.be.an.instance_of Array
|
21
|
+
me.first.relation.should.equal 'me'
|
22
|
+
me.first.to_s.should.equal '#me'
|
23
|
+
|
24
|
+
muse = $xfn.muse(true)
|
25
|
+
muse.should.be.an.instance_of XFN::Link
|
26
|
+
muse.relation.should.equal 'muse'
|
27
|
+
muse.to_s.should.equal '#muse'
|
28
|
+
end
|
29
|
+
|
30
|
+
specify "should know relationship intersections" do
|
31
|
+
# hot!
|
32
|
+
intersection = $xfn.colleague_and_sweetheart
|
33
|
+
intersection.should.be.an.instance_of XFN::Link
|
34
|
+
intersection.to_s.should.equal '#colleague'
|
35
|
+
|
36
|
+
intersection = $xfn.kin_and_colleague
|
37
|
+
intersection.should.be.an.instance_of Array
|
38
|
+
intersection.first.to_s.should.equal '#kin'
|
39
|
+
end
|
40
|
+
|
41
|
+
specify "should not know non-existent relationship intersections" do
|
42
|
+
intersection = $xfn.colleague_and_sweetheart_and_muse_and_crush
|
43
|
+
intersection.should.be.nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "A XFN::Link object" do
|
48
|
+
setup do
|
49
|
+
xfn_setup
|
50
|
+
$xfn_link ||= $xfn.first
|
51
|
+
end
|
52
|
+
|
53
|
+
specify "should be able to generate an html version of itself" do
|
54
|
+
$xfn_link.to_html.should.match /href.+\>.+\</
|
55
|
+
end
|
56
|
+
|
57
|
+
specify "should know its name" do
|
58
|
+
$xfn_link.name.should.be.an.instance_of String
|
59
|
+
$xfn_link.name.should.not.be.empty
|
60
|
+
end
|
61
|
+
|
62
|
+
specify "should know its relation to the page from which it was obtained" do
|
63
|
+
$xfn_link.relation.should.be.an.instance_of String
|
64
|
+
$xfn_link.relation.should.not.be.empty
|
65
|
+
end
|
66
|
+
|
67
|
+
specify "should know where it points" do
|
68
|
+
$xfn_link.link.should.be.an.instance_of String
|
69
|
+
$xfn_link.link.should.not.be.empty
|
70
|
+
end
|
71
|
+
|
72
|
+
specify "should display itself as its link" do
|
73
|
+
$xfn_link.inspect.should.equal $xfn_link.link.inspect
|
74
|
+
$xfn_link.to_s.should.equal $xfn_link.link.to_s
|
75
|
+
end
|
76
|
+
end
|
data/test/xoxo_test.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mofo
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: "0.2"
|
7
|
+
date: 2007-03-22 00:00:00 -07:00
|
8
8
|
summary: mofo is a ruby microformat parser
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -36,29 +36,48 @@ files:
|
|
36
36
|
- lib/microformat.rb
|
37
37
|
- lib/mofo
|
38
38
|
- lib/mofo.rb
|
39
|
+
- lib/microformat/array.rb
|
39
40
|
- lib/microformat/simple.rb
|
40
41
|
- lib/microformat/string.rb
|
42
|
+
- lib/mofo/adr.rb
|
43
|
+
- lib/mofo/geo.rb
|
41
44
|
- lib/mofo/hcalendar.rb
|
42
45
|
- lib/mofo/hcard.rb
|
43
46
|
- lib/mofo/hentry.rb
|
44
47
|
- lib/mofo/hfeed.rb
|
48
|
+
- lib/mofo/hresume.rb
|
45
49
|
- lib/mofo/hreview.rb
|
50
|
+
- lib/mofo/rel_bookmark.rb
|
46
51
|
- lib/mofo/rel_tag.rb
|
52
|
+
- lib/mofo/xfn.rb
|
47
53
|
- lib/mofo/xoxo.rb
|
54
|
+
- test/ext_test.rb
|
48
55
|
- test/fixtures
|
49
56
|
- test/format_test.rb
|
50
57
|
- test/hatom_test.rb
|
58
|
+
- test/hcalendar_test.rb
|
59
|
+
- test/hcard_test.rb
|
60
|
+
- test/hresume_test.rb
|
61
|
+
- test/hreview_test.rb
|
62
|
+
- test/include_pattern_test.rb
|
63
|
+
- test/reltag_test.rb
|
51
64
|
- test/test_helper.rb
|
65
|
+
- test/xfn_test.rb
|
52
66
|
- test/xoxo_test.rb
|
53
67
|
- test/fixtures/bob.html
|
54
68
|
- test/fixtures/chowhound.html
|
55
69
|
- test/fixtures/corkd.html
|
70
|
+
- test/fixtures/event_addr.html
|
56
71
|
- test/fixtures/events.html
|
57
72
|
- test/fixtures/fake.html
|
58
73
|
- test/fixtures/fauxtank.html
|
59
74
|
- test/fixtures/hatom.html
|
75
|
+
- test/fixtures/hresume.html
|
76
|
+
- test/fixtures/include_pattern_single_attribute.html
|
60
77
|
- test/fixtures/simple.html
|
61
78
|
- test/fixtures/upcoming.html
|
79
|
+
- test/fixtures/upcoming_single.html
|
80
|
+
- test/fixtures/xfn.html
|
62
81
|
- vendor/testspec-0.3.0
|
63
82
|
- vendor/testspec-0.3.0/bin
|
64
83
|
- vendor/testspec-0.3.0/ChangeLog
|
@@ -137,5 +156,13 @@ extensions: []
|
|
137
156
|
|
138
157
|
requirements: []
|
139
158
|
|
140
|
-
dependencies:
|
141
|
-
|
159
|
+
dependencies:
|
160
|
+
- !ruby/object:Gem::Dependency
|
161
|
+
name: hpricot
|
162
|
+
version_requirement:
|
163
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 0.4.59
|
168
|
+
version:
|