Skip to content

Commit

Permalink
Rss2 uses has_one too
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed May 10, 2009
1 parent 9a548da commit cf409ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 1 addition & 3 deletions lib/feed_me/feed_parser.rb
Expand Up @@ -69,8 +69,6 @@ class Rss2FeedParser < FeedParser

has_many :entries, :path => 'item', :use => :Rss2ItemParser

def author
Rss2PersonParser.new(xml, "managingEditor")
end
has_one :author, :path => 'managingEditor', :use => :Rss2PersonParser
end
end
4 changes: 1 addition & 3 deletions lib/feed_me/item_parser.rb
Expand Up @@ -30,8 +30,6 @@ class Rss2ItemParser < ItemParser
property :content, :path => :description
property :author, :path => :special

def author
Rss2PersonParser.new(xml, "author")
end
has_one :author, :use => :Rss2PersonParser
end
end
8 changes: 4 additions & 4 deletions lib/feed_me/person_parser.rb
Expand Up @@ -21,10 +21,10 @@ class AtomPersonParser < PersonParser
class Rss2PersonParser
attr_reader :name, :email, :uri

def initialize(xml, selector)
item = xml.at("/#{selector}")
if(item)
@email, @name = item.inner_html.split(/\s+/, 2)
def initialize(xml, feed)
@feed = feed
if(xml)
@email, @name = xml.inner_html.split(/\s+/, 2)
@name = name.match( /\((.*?)\)/ ).to_a[1] if @name # strip parentheses
end
end
Expand Down

0 comments on commit cf409ad

Please sign in to comment.