cardmagic-simple-rss 1.1 → 1.2

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.
Files changed (4) hide show
  1. data/README +3 -0
  2. data/lib/simple-rss.rb +22 -8
  3. data/simple-rss.gemspec +2 -2
  4. metadata +2 -2
data/README CHANGED
@@ -30,6 +30,9 @@ But since the parser can read Atom feeds as easily as RSS feeds, there are optio
30
30
  The parser does not care about the correctness of the XML as it does not use an XML library to read the information. Thus it is flexible and allows for easy extending via:
31
31
 
32
32
  SimpleRSS.feed_tags << :some_new_tag
33
+ SimpleRSS.item_tags << :"item+myrel" # this will extend SimpleRSS to be able to parse RSS items or ATOM entries that have a rel specified, common in many blogger feeds
34
+ SimpleRSS.item_tags << :"feedburner:origLink" # this will extend SimpleRSS to be able to parse RSS items or ATOM entries that have a specific pre-tag specified, common in many feedburner feeds
35
+
33
36
 
34
37
  == Authors
35
38
  * Lucas Carlson (mailto:lucas@rufy.com)
data/lib/simple-rss.rb CHANGED
@@ -2,7 +2,7 @@ require 'cgi'
2
2
  require 'time'
3
3
 
4
4
  class SimpleRSS
5
- VERSION = "1.1"
5
+ VERSION = "1.2"
6
6
 
7
7
  attr_reader :items, :source
8
8
  alias :entries :items
@@ -23,13 +23,14 @@ class SimpleRSS
23
23
 
24
24
  @@item_tags = [
25
25
  :id,
26
- :title, :link,
26
+ :title, :link, :'link+alternate', :'link+self', :'link+edit', :'link+replies',
27
27
  :author, :contributor,
28
28
  :description, :summary, :content, :'content:encoded', :comments,
29
29
  :pubDate, :published, :updated, :expirationDate, :modified, :'dc:date',
30
30
  :category, :guid,
31
31
  :'trackback:ping', :'trackback:about',
32
- :'dc:creator', :'dc:title', :'dc:subject', :'dc:rights', :'dc:publisher'
32
+ :'dc:creator', :'dc:title', :'dc:subject', :'dc:rights', :'dc:publisher',
33
+ :'feedburner:origLink'
33
34
  ]
34
35
 
35
36
  def initialize(source)
@@ -93,12 +94,25 @@ class SimpleRSS
93
94
  @source.scan( %r{<(rss:|atom:)?(item|entry)([\s][^>]*)?>(.*?)</(rss:|atom:)?(item|entry)>}mi ) do |match|
94
95
  item = Hash.new
95
96
  @@item_tags.each do |tag|
96
- if match[3] =~ %r{<(rss:|atom:)?#{tag}(.*?)>(.*?)</(rss:|atom:)?#{tag}>}mi
97
- nil
98
- elsif match[3] =~ %r{<(rss:|atom:)?#{tag}(.*?)/\s*>}mi
99
- nil
97
+ if tag.to_s.include?("+")
98
+ tag_data = tag.to_s.split("+")
99
+ tag = tag_data[0]
100
+ rel = tag_data[1]
101
+
102
+ if match[3] =~ %r{<(rss:|atom:)?#{tag}(.*?)rel=['"]#{rel}['"](.*?)>(.*?)</(rss:|atom:)?#{tag}>}mi
103
+ nil
104
+ elsif match[3] =~ %r{<(rss:|atom:)?#{tag}(.*?)rel=['"]#{rel}['"](.*?)/\s*>}mi
105
+ nil
106
+ end
107
+ item[clean_tag("#{tag}+#{rel}")] = clean_content(tag, $3, $4) if $3 || $4
108
+ else
109
+ if match[3] =~ %r{<(rss:|atom:)?#{tag}(.*?)>(.*?)</(rss:|atom:)?#{tag}>}mi
110
+ nil
111
+ elsif match[3] =~ %r{<(rss:|atom:)?#{tag}(.*?)/\s*>}mi
112
+ nil
113
+ end
114
+ item[clean_tag(tag)] = clean_content(tag, $2, $3) if $2 || $3
100
115
  end
101
- item[clean_tag(tag)] = clean_content(tag, $2, $3) if $2 || $3
102
116
  end
103
117
  def item.method_missing(name, *args) self[name] end
104
118
  @items << item
data/simple-rss.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "simple-rss"
3
- s.version = "1.1"
4
- s.date = "2008-07-15"
3
+ s.version = "1.2"
4
+ s.date = "2009-02-25"
5
5
  s.summary = "A simple, flexible, extensible, and liberal RSS and Atom reader for Ruby. It is designed to be backwards compatible with the standard RSS parser, but will never do RSS generation."
6
6
  s.email = "lucas@rufy.com"
7
7
  s.homepage = "http://github.com/cardmagic/simple-rss"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cardmagic-simple-rss
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.1"
4
+ version: "1.2"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-15 00:00:00 -07:00
12
+ date: 2009-02-25 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15