mofo 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ = 0.2.6
2
+ - Added rel-license [Mark Murphy]
3
+ - Performance optimization [Mark Murphy]
4
+ - Fix bug in hEntry rel-tag [Mark Murphy]
5
+
1
6
  = 0.2.5
2
7
  - Added ability to find ALL microformats on a page using Microformat.find.
3
8
  Only searches using loaded microformat classes, so make sure to just require 'mofo'
data/README CHANGED
@@ -191,6 +191,8 @@ them in a session.
191
191
  >> Christian Carter
192
192
  >> Grant Rodgers
193
193
  >> Denis Defreyne
194
+ >> Andrew Turner
195
+ >> Mark Murphy
194
196
 
195
197
  = Author
196
198
 
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
 
4
- version = '0.2.5'
4
+ version = '0.2.6'
5
5
  svn_repo = 'svn+ssh://chris@errtheblog.com/svn/projects/mofo'
6
6
 
7
7
  begin
@@ -174,21 +174,26 @@ class Microformat
174
174
  def build_hash(doc, attributes = @attributes)
175
175
  hash = {}
176
176
 
177
+ # rel="bookmark" pattern
178
+ if bookmark = extract_bookmark(doc)
179
+ hash[:bookmark] = bookmark
180
+ end
181
+
182
+ # rel="license" pattern
183
+ if license = extract_license(doc)
184
+ hash[:license] = license
185
+ end
186
+
187
+ # rel="tag" pattern
188
+ if tags = extract_tags(doc)
189
+ hash[:tags] = tags
190
+ end
191
+
177
192
  [:one, :many].each do |name|
178
193
  attributes[name].each do |attribute|
179
194
  is_hash = attribute.is_a? Hash
180
195
  key = is_hash ? attribute.keys.first : attribute
181
196
 
182
- # rel="bookmark" pattern
183
- if bookmark = extract_bookmark(doc)
184
- hash[:bookmark] = bookmark
185
- end
186
-
187
- # rel="tag" pattern
188
- if tags = extract_tags(doc)
189
- hash[:tags] = tags
190
- end
191
-
192
197
  found = doc/".#{key.no_bang.to_s.gsub('_','-')}"
193
198
  raise InvalidMicroformat if found.empty? && key.to_s =~ /!/
194
199
  next if found.empty?
@@ -236,10 +241,15 @@ class Microformat
236
241
  end
237
242
 
238
243
  def extract_bookmark(doc)
239
- bookmark = doc.at("[@rel=bookmark]") rescue nil
244
+ bookmark = (doc.at("[@rel=bookmark]") || doc.at("[@rel='self bookmark']")) rescue nil
240
245
  bookmark.attributes['href'] if bookmark.respond_to? :attributes
241
246
  end
242
247
 
248
+ def extract_license(doc)
249
+ license = doc.at("[@rel=license]") rescue nil
250
+ license.attributes['href'] if license.respond_to? :attributes
251
+ end
252
+
243
253
  def extract_tags(doc)
244
254
  return unless (tags = doc.search("[@rel=tag]")).size.nonzero?
245
255
  tags.inject([]) { |array, tag| array + [tag.innerText] }
@@ -5,9 +5,9 @@ require 'mofo/rel_tag'
5
5
 
6
6
  class HEntry < Microformat
7
7
  one :entry_title!, :entry_summary, :updated, :published,
8
- :author => HCard, :tags => RelTag
8
+ :author => HCard
9
9
 
10
- many :entry_content
10
+ many :entry_content, :tags => RelTag
11
11
 
12
12
  after_find do
13
13
  @updated = @published unless @updated if @published
metadata CHANGED
@@ -3,7 +3,7 @@ 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.5
6
+ version: 0.2.6
7
7
  date: 2007-05-07 00:00:00 -07:00
8
8
  summary: mofo is a ruby microformat parser
9
9
  require_paths: