simple-rss 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -32,10 +32,11 @@ The parser does not care about the correctness of the XML as it does not use an
32
32
  SimpleRSS.feed_tags << :some_new_tag
33
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
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
-
35
+ SimpleRSS.item_tags << :"media:content#url" # this will grab the url attribute of the media:content tag
36
36
 
37
37
  == Authors
38
38
  * Lucas Carlson (mailto:lucas@rufy.com)
39
+ * Herval Freire (mailto:hervalfreire@gmail.com)
39
40
 
40
41
  Inspired by Blagg (http://www.raelity.org/lang/perl/blagg) from Rael Dornfest.
41
42
 
@@ -2,7 +2,7 @@ require 'cgi'
2
2
  require 'time'
3
3
 
4
4
  class SimpleRSS
5
- VERSION = "1.2.2"
5
+ VERSION = "1.2.3"
6
6
 
7
7
  attr_reader :items, :source
8
8
  alias :entries :items
@@ -30,7 +30,11 @@ class SimpleRSS
30
30
  :category, :guid,
31
31
  :'trackback:ping', :'trackback:about',
32
32
  :'dc:creator', :'dc:title', :'dc:subject', :'dc:rights', :'dc:publisher',
33
- :'feedburner:origLink'
33
+ :'feedburner:origLink',
34
+ :'media:content#url', :'media:content#type', :'media:content#height', :'media:content#width',
35
+ :'media:title', :'media:thumbnail#url', :'media:thumbnail#height', :'media:thumbnail#width',
36
+ :'media:credit', :'media:credit#role',
37
+ :'media:category', :'media:category#scheme'
34
38
  ]
35
39
 
36
40
  def initialize(source, options={})
@@ -106,6 +110,16 @@ class SimpleRSS
106
110
  nil
107
111
  end
108
112
  item[clean_tag("#{tag}+#{rel}")] = clean_content(tag, $3, $4) if $3 || $4
113
+ elsif tag.to_s.include?("#")
114
+ tag_data = tag.to_s.split("#")
115
+ tag = tag_data[0]
116
+ attrib = tag_data[1]
117
+ if match[3] =~ %r{<(rss:|atom:)?#{tag}(.*?)#{attrib}=['"](.*?)['"](.*?)>(.*?)</(rss:|atom:)?#{tag}>}mi
118
+ nil
119
+ elsif match[3] =~ %r{<(rss:|atom:)?#{tag}(.*?)#{attrib}=['"](.*?)['"](.*?)/\s*>}mi
120
+ nil
121
+ end
122
+ item[clean_tag("#{tag}_#{attrib}")] = clean_content(tag, attrib, $3) if $3
109
123
  else
110
124
  if match[3] =~ %r{<(rss:|atom:)?#{tag}(.*?)>(.*?)</(rss:|atom:)?#{tag}>}mi
111
125
  nil
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "simple-rss"
3
- s.version = "1.2.2"
4
- s.date = "2009-02-25"
3
+ s.version = "1.2.3"
4
+ s.date = "2010-07-06"
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"
@@ -3,6 +3,7 @@ class BaseTest < Test::Unit::TestCase
3
3
  def setup
4
4
  @rss09 = SimpleRSS.parse open(File.dirname(__FILE__) + '/../data/rss09.rdf')
5
5
  @rss20 = SimpleRSS.parse open(File.dirname(__FILE__) + '/../data/rss20.xml')
6
+ @media_rss = SimpleRSS.parse open(File.dirname(__FILE__) + '/../data/media_rss.xml')
6
7
  @atom = SimpleRSS.parse open(File.dirname(__FILE__) + '/../data/atom.xml')
7
8
  end
8
9
 
@@ -28,6 +29,26 @@ class BaseTest < Test::Unit::TestCase
28
29
  assert_equal Time.parse("Fri Sep 09 02:52:31 PDT 2005"), @rss09.channel.dc_date
29
30
  end
30
31
 
32
+ def test_media_rss
33
+ assert_equal 20, @media_rss.items.size
34
+ assert_equal "Uploads from herval", @media_rss.title
35
+ assert_equal "http://www.flickr.com/photos/herval/", @media_rss.channel.link
36
+ assert_equal "http://www.flickr.com/photos/herval/4671960608/", @media_rss.items.first.link
37
+ assert_equal "http://www.flickr.com/photos/herval/4671960608/", @media_rss.items.first[:link]
38
+ assert_equal "http://farm5.static.flickr.com/4040/4671960608_10cb945d5c_o.jpg", @media_rss.items.first.media_content_url
39
+ assert_equal "image/jpeg", @media_rss.items.first.media_content_type
40
+ assert_equal "3168", @media_rss.items.first.media_content_height
41
+ assert_equal "4752", @media_rss.items.first.media_content_width
42
+ assert_equal "Woof?", @media_rss.items.first.media_title
43
+ assert_equal "http://farm5.static.flickr.com/4040/4671960608_954d2297bc_s.jpg", @media_rss.items.first.media_thumbnail_url
44
+ assert_equal "75", @media_rss.items.first.media_thumbnail_height
45
+ assert_equal "75", @media_rss.items.first.media_thumbnail_width
46
+ assert_equal "herval", @media_rss.items.first.media_credit
47
+ assert_equal "photographer", @media_rss.items.first.media_credit_role
48
+ assert_equal "pets frodo", @media_rss.items.first.media_category
49
+ assert_equal "urn:flickr:tags", @media_rss.items.first.media_category_scheme
50
+ end
51
+
31
52
  def test_rss20
32
53
  assert_equal 10, @rss20.items.size
33
54
  assert_equal "Technoblog", @rss20.title
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-rss
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
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: 2009-02-25 00:00:00 -08:00
12
+ date: 2010-07-06 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15