rrsimple-rss 1.3.9 → 1.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rrsimple-rss.rb +17 -3
- data/rrsimple-rss.gemspec +1 -1
- data/test/base/base_test.rb +20 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b202a9c81df93abba588c6c9157ba77038ae71e0
|
4
|
+
data.tar.gz: e98e2d08b4729243d06ddceafdf19dc0c4fe41d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79fa2c492e08186e26aa56ab6576e943be4a2b23ace18bb804dc9843d8e1deeefac34e870b6f390908cecade038e4c22d5dedbfbe000c3fb7a605973c69eddee
|
7
|
+
data.tar.gz: bb9fc6666f882d8e440bfdd0c33918f078340a1146866e8edd5a067de29d32a53fdadcb17a8a487be8a341b12c2c8dc96bd78688ff0a0a97395d03c70c9f4f58
|
data/lib/rrsimple-rss.rb
CHANGED
@@ -3,7 +3,7 @@ require 'cgi'
|
|
3
3
|
require 'time'
|
4
4
|
|
5
5
|
class RRSimpleRSS
|
6
|
-
VERSION = "1.3.
|
6
|
+
VERSION = "1.3.10"
|
7
7
|
|
8
8
|
attr_reader :items, :source
|
9
9
|
alias :entries :items
|
@@ -131,9 +131,19 @@ class RRSimpleRSS
|
|
131
131
|
end
|
132
132
|
|
133
133
|
if tag == :category
|
134
|
-
|
134
|
+
if self.channel.link.include?("bbc.com")
|
135
|
+
item[tag] = match[3].scan(%r{<(rss:|atom:)?#{tag} label=(.*?)>}mi).map {|x| categorybbc(x[1]) }
|
136
|
+
else
|
137
|
+
item[tag] = match[3].scan(%r{<(rss:|atom:)?#{tag}(.*?)>(.*?)</(rss:|atom:)?#{tag}>}mi).map {|x| category(x[2])}
|
138
|
+
end
|
135
139
|
elsif tag == :keywords
|
136
|
-
|
140
|
+
if self.channel.link.include?("bbc.com")
|
141
|
+
keys = match[3].scan(%r{<(rss:|atom:)?dc:subject rdf:type="keywords"(.*?)>(.*?)<\/(rss:|atom:)?dc:subject>}mi)
|
142
|
+
item[tag] = keys.empty? ? [] : keys[0][2].split("; ")
|
143
|
+
item[:category].map { |x| item[tag] << x }
|
144
|
+
else
|
145
|
+
item[tag] = match[3].scan(%r{<(rss:|atom:)?dc:subject rdf:type="keywords"(.*?)>(.*?)<\/(rss:|atom:)?dc:subject>}mi).map {|x| x[2].gsub(";", ",") }
|
146
|
+
end
|
137
147
|
elsif tag == :linkbbc
|
138
148
|
match[3] =~ %r{<(rss:|atom:)?link(.*?)/\s*>}mi
|
139
149
|
$2 =~ %r{href=(.*?)rel}
|
@@ -152,6 +162,10 @@ class RRSimpleRSS
|
|
152
162
|
|
153
163
|
end
|
154
164
|
|
165
|
+
def categorybbc(str)
|
166
|
+
str.split(" ").first
|
167
|
+
end
|
168
|
+
|
155
169
|
def category(str)
|
156
170
|
str.include?("CDATA") ? str[9..str.length-4] : str
|
157
171
|
end
|
data/rrsimple-rss.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "rrsimple-rss"
|
3
|
-
s.version = "1.3.
|
3
|
+
s.version = "1.3.10"
|
4
4
|
s.date = Time.now.strftime("%Y-%m-%d")
|
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 = "rodrigo@rrmartins.com"
|
data/test/base/base_test.rb
CHANGED
@@ -9,6 +9,7 @@ class BaseTest < Test::Unit::TestCase
|
|
9
9
|
@rss_prnews = RRSimpleRSS.parse open(File.dirname(__FILE__) + '/../data/prnews.xml')
|
10
10
|
@rss_bbc = RRSimpleRSS.parse open(File.dirname(__FILE__) + '/../data/bbc.xml')
|
11
11
|
@rss_bbc2 = RRSimpleRSS.parse open(File.dirname(__FILE__) + '/../data/bbc2.xml')
|
12
|
+
@rss_bbc3 = RRSimpleRSS.parse open(File.dirname(__FILE__) + '/../data/bbc3.xml')
|
12
13
|
@rss_baboo = RRSimpleRSS.parse open(File.dirname(__FILE__) + '/../data/baboo.xml')
|
13
14
|
@rss09 = RRSimpleRSS.parse open(File.dirname(__FILE__) + '/../data/rss09.rdf')
|
14
15
|
@rss20 = RRSimpleRSS.parse open(File.dirname(__FILE__) + '/../data/rss20.xml')
|
@@ -17,8 +18,9 @@ class BaseTest < Test::Unit::TestCase
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def test_channel
|
21
|
+
assert_equal @rss_bbc, @rss_bbc.channel
|
20
22
|
assert_equal @rss_bbc2, @rss_bbc2.channel
|
21
|
-
assert_equal @
|
23
|
+
assert_equal @rss_bbc3, @rss_bbc3.channel
|
22
24
|
assert_equal @rss09, @rss09.channel
|
23
25
|
assert_equal @rss20, @rss20.channel
|
24
26
|
assert_equal @atom, @atom.feed
|
@@ -30,6 +32,7 @@ class BaseTest < Test::Unit::TestCase
|
|
30
32
|
assert_kind_of Array, @rss_baboo.items
|
31
33
|
assert_kind_of Array, @rss_bbc.items
|
32
34
|
assert_kind_of Array, @rss_bbc2.items
|
35
|
+
assert_kind_of Array, @rss_bbc3.items
|
33
36
|
assert_kind_of Array, @rss09.items
|
34
37
|
assert_kind_of Array, @rss20.items
|
35
38
|
assert_kind_of Array, @atom.entries
|
@@ -85,11 +88,26 @@ class BaseTest < Test::Unit::TestCase
|
|
85
88
|
assert_equal Time.parse("2015-11-09 16:40:33 -0200"), @rss_bbc2.items.first.updated
|
86
89
|
assert_equal Time.parse("2015-11-09 13:29:35 -0200"), @rss_bbc2.channel.updated
|
87
90
|
assert_not_nil @rss_bbc2.items.first.content
|
88
|
-
|
91
|
+
assert_not_nil @rss_bbc2.items.first.category.first
|
89
92
|
assert_kind_of Array, @rss_bbc2.items.first.keywords
|
90
93
|
assert_equal "internacional", @rss_bbc2.items.first.keywords[0].split(", ").first
|
91
94
|
end
|
92
95
|
|
96
|
+
def test_rss_bbc3
|
97
|
+
assert_equal 88, @rss_bbc3.items.size
|
98
|
+
assert_equal "BBCBrasil.com | NotÃcias", @rss_bbc3.title.force_encoding("UTF-8")
|
99
|
+
assert_equal "http://www.bbc.com/portuguese/full_all.xml", @rss_bbc3.channel.link
|
100
|
+
assert_equal "http://www.bbc.com/portuguese/noticias/2015/11/151130_dilma_cervero_cop_lab_rm", @rss_bbc3.items.first.linkbbc
|
101
|
+
assert_equal "http://www.bbc.com/portuguese/noticias/2015/11/151130_dilma_cervero_cop_lab_rm", @rss_bbc3.items.first[:linkbbc]
|
102
|
+
assert_equal Time.parse("2015-11-30 18:41:31 -0200"), @rss_bbc3.items.first.updated
|
103
|
+
assert_equal Time.parse("2015-11-30 18:41:31 -0200"), @rss_bbc3.channel.updated
|
104
|
+
assert_not_nil @rss_bbc3.items.first.content
|
105
|
+
assert_not_nil @rss_bbc3.items.first.category.first
|
106
|
+
assert_kind_of Array, @rss_bbc3.items.first.category
|
107
|
+
assert_kind_of Array, @rss_bbc3.items.first.keywords
|
108
|
+
assert_equal "brasil", @rss_bbc3.items.first.keywords[0].split(", ").first
|
109
|
+
end
|
110
|
+
|
93
111
|
def test_rss09
|
94
112
|
assert_equal 10, @rss09.items.size
|
95
113
|
assert_equal "Slashdot", @rss09.title
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rrsimple-rss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Carlson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-11-
|
12
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple, flexible, extensible, and liberal RSS and Atom reader for Ruby.
|
15
15
|
It is designed to be backwards compatible with the standard RSS parser, but will
|