mofo 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ gem 'echoe', '=1.3'
3
4
 
4
- version = '0.2.9'
5
+ version = '0.2.10'
5
6
 
6
7
  ENV['RUBY_FLAGS'] = ""
7
8
 
data/lib/mofo/xfn.rb CHANGED
@@ -2,6 +2,27 @@ $:.unshift 'lib'
2
2
  require 'microformat'
3
3
 
4
4
  class XFN < Microformat
5
+ @@valid_relations = %w(
6
+ contact
7
+ acquaintance
8
+ friend
9
+ met
10
+ co-worker
11
+ colleague
12
+ co-resident
13
+ neighbor
14
+ child
15
+ parent
16
+ sibling
17
+ spouse
18
+ kin
19
+ muse
20
+ crush
21
+ date
22
+ sweetheart
23
+ me
24
+ )
25
+
5
26
  class Link < OpenStruct
6
27
  def initialize(*args)
7
28
  super
@@ -35,9 +56,15 @@ class XFN < Microformat
35
56
 
36
57
  def initialize(doc)
37
58
  @links = doc.search("a[@rel]").map do |rl|
38
- relation = rl[:rel].include?(' ') ? rl[:rel].split(' ') : rl[:rel]
59
+ relation = rl[:rel].split(' ')
60
+
61
+ # prune invalid relations
62
+ relation.each { |r| relation.delete(r) unless @@valid_relations.include? r }
63
+ relation = relation.first if relation.size == 1
64
+ next if relation.empty?
65
+
39
66
  Link.new(:name => rl.innerHTML, :link => rl[:href], :relation => relation)
40
- end
67
+ end.compact
41
68
  end
42
69
 
43
70
  def relations
@@ -160,6 +160,13 @@
160
160
  <dt>Geographical - multiple values</dt>
161
161
  <dd><a href="#co-resident" rel="co-resident neighbor">co-resident + neighbor</a></dd>
162
162
  </dl>
163
+
164
+ <dl class="invalid">
165
+ <dt>Reserved rels</dt>
166
+ <dd><a href="#nofollow" rel="nofollow">nofollow</a></dd>
167
+ <dd><a href="#nofollow" rel="friend nofollow">friend + nofollow</a></dd>
168
+ <dd><a href="#bookmark" rel="bookmark">bookmark</a></dd>
169
+ </dl>
163
170
 
164
171
  <dl class="invalid">
165
172
  <dt>Family - multiple values</dt>
data/test/xfn_test.rb CHANGED
@@ -42,6 +42,12 @@ context "A XFN object" do
42
42
  intersection = $xfn.colleague_and_sweetheart_and_muse_and_crush
43
43
  intersection.should.be.nil
44
44
  end
45
+
46
+ specify "should not pick up reserved relationships" do
47
+ $xfn.nofollow.should.be.nil
48
+ $xfn.friend_and_nofollow.should.be.nil
49
+ $xfn.bookmark.should.be.nil
50
+ end
45
51
  end
46
52
 
47
53
  context "A XFN::Link object" do
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.2.9
7
- date: 2007-08-03 00:00:00 -07:00
6
+ version: 0.2.10
7
+ date: 2007-08-17 00:00:00 -07:00
8
8
  summary: mofo is a ruby microformat parser
9
9
  require_paths:
10
10
  - lib