mofo 0.2.14 → 0.2.15
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/README +5 -0
- data/Rakefile +1 -1
- data/lib/mofo/hentry.rb +29 -3
- data/test/hatom_test.rb +14 -0
- metadata +2 -2
data/README
CHANGED
@@ -32,6 +32,11 @@
|
|
32
32
|
>> fireball.logo
|
33
33
|
=> "http://static.flickr.com/9/buddyicons/44621776@N00.jpg?1117572751"
|
34
34
|
|
35
|
+
= Grab It
|
36
|
+
|
37
|
+
$ git clone git://github.com/defunkt/mofo.git
|
38
|
+
$ open http://github.com/defunkt/mofo
|
39
|
+
|
35
40
|
= Microwhozit?
|
36
41
|
|
37
42
|
Microformats are tiny little markup definitions built on top of, usually,
|
data/Rakefile
CHANGED
data/lib/mofo/hentry.rb
CHANGED
@@ -11,7 +11,7 @@ class HEntry < Microformat
|
|
11
11
|
many :entry_content => :html, :tags => RelTag
|
12
12
|
|
13
13
|
after_find do
|
14
|
-
@domain = @base_url.sub /http:\/\/([^\/]+).*/, '\1'
|
14
|
+
@domain = @base_url.to_s.sub /http:\/\/([^\/]+).*/, '\1'
|
15
15
|
@updated ||= @published if @published
|
16
16
|
end
|
17
17
|
|
@@ -37,16 +37,42 @@ class HEntry < Microformat
|
|
37
37
|
#{atom_id}
|
38
38
|
#{atom_link}
|
39
39
|
#{to_atom :title, @entry_title}
|
40
|
-
<content type="html">#{ERB::Util.h @entry_content}</content>
|
41
40
|
#{to_atom :updated, @updated.try(:xmlschema)}
|
42
|
-
#{to_atom :published, @updated.try(:xmlschema)}
|
43
41
|
<author>
|
44
42
|
#{to_atom :name, @author.try(:fn)}
|
45
43
|
#{to_atom :email, @author.try(:email)}
|
46
44
|
</author>
|
45
|
+
<content type="html">#{ERB::Util.h @entry_content}</content>
|
47
46
|
</entry>
|
48
47
|
atom_entity
|
49
48
|
end
|
49
|
+
|
50
|
+
def missing_author?
|
51
|
+
@author.nil?
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_in_parent_hcard
|
55
|
+
@properties << 'author'
|
56
|
+
@author = in_parent_hcard
|
57
|
+
end
|
58
|
+
|
59
|
+
# Per spec: if the entry author is missing find the nearest in
|
60
|
+
# parent <address> element(s) with class name author
|
61
|
+
def in_parent_hcard
|
62
|
+
@in_parent_hcard ||= self.class.find_in_parent_hcard
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.build_class(microformat)
|
66
|
+
hentry = super(microformat)
|
67
|
+
hentry.add_in_parent_hcard if hentry.missing_author?
|
68
|
+
hentry
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.find_in_parent_hcard
|
72
|
+
author = HCard.find(:text => (@doc/"//.hentry/..//address.vcard").to_s)
|
73
|
+
raise InvalidMicroformat if @options[:strict] && author.empty?
|
74
|
+
prepare_value(author)
|
75
|
+
end
|
50
76
|
end
|
51
77
|
|
52
78
|
class Array
|
data/test/hatom_test.rb
CHANGED
@@ -15,6 +15,20 @@ context "A parsed hEntry object" do
|
|
15
15
|
$hentry.author.fn.should.equal "Chris"
|
16
16
|
end
|
17
17
|
|
18
|
+
specify "should have an author when there are no entry author but a nearest in parent hcard" do
|
19
|
+
with_parent = HEntry.find(:first => fixture(:redflavor),
|
20
|
+
:base => 'http://journal.redflavor.com')
|
21
|
+
with_parent.author.should.be.an.instance_of HCard
|
22
|
+
with_parent.author.fn.should.equal "Eivind Uggedal"
|
23
|
+
with_parent.author.url.should.equal "http://redflavor.com"
|
24
|
+
end
|
25
|
+
|
26
|
+
specify "should be invalid without any author in strict mode" do
|
27
|
+
proc { HEntry.find(:first => fixture(:hatom_without_author),
|
28
|
+
:base => 'http://bogus.redflavor.com',
|
29
|
+
:strict => true) }.should.raise InvalidMicroformat
|
30
|
+
end
|
31
|
+
|
18
32
|
specify "should have content" do
|
19
33
|
$hentry.entry_content.should.be.an.instance_of String
|
20
34
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mofo
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2008-01-
|
6
|
+
version: 0.2.15
|
7
|
+
date: 2008-01-30 00:00:00 -08:00
|
8
8
|
summary: mofo is a ruby microformat parser
|
9
9
|
require_paths:
|
10
10
|
- lib
|