rfeedreader 0.9.10 → 0.9.11

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.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.9.11 2007-09-08
2
+
3
+ * Add timeout on http request
4
+
1
5
  == 0.9.10 2007-09-05
2
6
 
3
7
  * Solve picasa problem
@@ -2,7 +2,7 @@ module Rfeedreader #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- TINY = 10
5
+ TINY = 11
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/rfeedreader.rb CHANGED
@@ -7,6 +7,8 @@ require 'open-uri'
7
7
  require 'rfeedfinder'
8
8
  require 'timeout'
9
9
 
10
+ require 'rfeedreader/version'
11
+
10
12
  module Rfeedreader
11
13
  module_function
12
14
 
@@ -294,24 +296,34 @@ module Rfeedreader
294
296
  def read_header(uri)
295
297
  return read(uri, parse_entries=false)
296
298
  end
297
-
299
+
298
300
  def open_doc(link)
301
+ data = nil
299
302
  begin
300
- data = Hpricot(open(link,
301
- "User-Agent" => "Ruby/#{RUBY_VERSION} - Rfeedreader",
302
- "From" => "rfeedreader@googlegroups.com",
303
- "Referer" => "http://rfeedreader.rubyforge.org/"), :xml => true)
304
- rescue Timeout::Error
305
- return nil
303
+ Timeout::timeout(20) {
304
+ data = Hpricot(open(link,
305
+ "User-Agent" => "Ruby/#{RUBY_VERSION} - Rfeedfinder",
306
+ "From" => "rfeedfinder@googlegroups.com",
307
+ "Referer" => "http://rfeedfinder.rubyforge.org/"), :xml => true)
308
+ }
306
309
  rescue OpenURI::HTTPError
307
- html = Net::HTTP.get(URI.parse(link))
308
- data = Hpricot(html, :xml => true)
310
+ begin
311
+ Timeout::timeout(20) {
312
+ html = Net::HTTP.get(URI.parse(link))
313
+ data = Hpricot(html, :xml => true) if html.to_s !~ /404 Not Found/
314
+ }
315
+ rescue Timeout::Error
316
+ return nil
317
+ rescue => err
318
+ puts "Error while opening #{link} with Hpricot: #{err.class} " << $!
319
+ return nil
320
+ end
321
+ rescue Timeout::Error
322
+ return nil
309
323
  rescue => err
310
324
  puts "Error while opening #{link} with Hpricot: #{err.class} " << $!
311
325
  return nil
312
326
  end
313
327
  return data
314
328
  end
315
- end
316
-
317
- require 'rfeedreader/version'
329
+ end
@@ -42,26 +42,26 @@ class TestRfeedreader < Test::Unit::TestCase
42
42
  end
43
43
 
44
44
  def test_read_from_feevy
45
- # read_first "http://rss.jumpcut.com/rss/user?u_id=17C65AB8A6EF11DBBE093EF340157CF2"
46
- # read_first "http://rss.jumpcut.com/rss/user?u_id=db9ec418fdaf11db8198000423cef5f6"
47
- # read_first "http://organizandolaesperanza.blogspot.com"
48
- # read_first "http://skblackburn.blogspot.com/"
49
- # read_first "http://nadapersonal.blogspot.com"
50
- # read_first "http://diariodeunadislexica.blogspot.com/"
51
- # read_first "http://diputadodelosverdes.blogspot.com/"
52
- # read_first "http://cinclin.blogspot.com/"
53
- # read_first "http://claudiaramos.blogspot.com/"
54
- # read_first "http://lacomunidad.elpais.com/krismontesinos/"
55
- # read_first "http://www.becker-posner-blog.com/index.rdf"
56
- # read_first "http://rss.slashdot.org/Slashdot/slashdot"
57
- # read_first "http://planeta.lamatriz.org/feed/"
58
- # read_first "http://edubloggers.blogspot.com/"
59
- # read_first "http://www.deugarte.com/feed/"
60
- # read_first "http://www.twitter.com/alx/"
61
- # read_first "http://alemama.blogspot.com"
62
- # read_first "http://seedmagazine.com/news/atom-focus.xml"
63
- # read_first "http://bitacora.feevy.com"
64
- # read_first "http://www.enriquemeneses.com/"
45
+ read_first "http://rss.jumpcut.com/rss/user?u_id=17C65AB8A6EF11DBBE093EF340157CF2"
46
+ read_first "http://rss.jumpcut.com/rss/user?u_id=db9ec418fdaf11db8198000423cef5f6"
47
+ read_first "http://organizandolaesperanza.blogspot.com"
48
+ read_first "http://skblackburn.blogspot.com/"
49
+ read_first "http://nadapersonal.blogspot.com"
50
+ read_first "http://diariodeunadislexica.blogspot.com/"
51
+ read_first "http://diputadodelosverdes.blogspot.com/"
52
+ read_first "http://cinclin.blogspot.com/"
53
+ read_first "http://claudiaramos.blogspot.com/"
54
+ read_first "http://lacomunidad.elpais.com/krismontesinos/"
55
+ read_first "http://www.becker-posner-blog.com/index.rdf"
56
+ read_first "http://rss.slashdot.org/Slashdot/slashdot"
57
+ read_first "http://planeta.lamatriz.org/feed/"
58
+ read_first "http://edubloggers.blogspot.com/"
59
+ read_first "http://www.deugarte.com/feed/"
60
+ read_first "http://www.twitter.com/alx/"
61
+ read_first "http://alemama.blogspot.com"
62
+ read_first "http://seedmagazine.com/news/atom-focus.xml"
63
+ read_first "http://bitacora.feevy.com"
64
+ read_first "http://www.enriquemeneses.com/"
65
65
  read_first "http://ianasagasti.blogs.com/"
66
66
  read_first "http://www.ecoperiodico.com/"
67
67
  read_first "http://bloc.balearweb.net/rss.php?summary=1"
@@ -121,8 +121,9 @@ class TestRfeedreader < Test::Unit::TestCase
121
121
  read_first "http://blogs.ya.com/eltikitaka/atom.xml"
122
122
  end
123
123
 
124
- def test_read_nico
125
- read_first "http://www.zanorg.com/nicoshark/rss/fil_rss.xml"
124
+ def test_timeout
125
+ feed = Rfeedreader.read_first "http://www.zanorg.com/nicoshark/rss/fil_rss.xml"
126
+ assert_nil feed
126
127
  end
127
128
 
128
129
  def test_read_picasa
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>rfeedreader</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/rfeedreader"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/rfeedreader" class="numbers">0.9.10</a>
36
+ <a href="http://rubyforge.org/projects/rfeedreader" class="numbers">0.9.11</a>
37
37
  </div>
38
38
  <h2>What</h2>
39
39
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: rfeedreader
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.9.10
7
- date: 2007-09-05 00:00:00 +02:00
6
+ version: 0.9.11
7
+ date: 2007-09-08 00:00:00 +02:00
8
8
  summary: Feed parser to read feed and return first posts of this feed. Special parsing from sources like Flickr, Jumcut, Google video, ...
9
9
  require_paths:
10
10
  - lib