feed_parser 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -19,9 +19,9 @@ end
19
19
  desc "Default: Run specs"
20
20
  task :default => :spec
21
21
 
22
- namespace :rubies do
22
+ namespace :spec do
23
23
  desc "Run tests with three major Ruby versions"
24
- task :specs do
25
- run("rvm 1.8.7-p302@feed_parser,1.9.2-p0@feed_parser,1.9.3-p125@feed_parser do bundle exec rake spec")
24
+ task :rubies do
25
+ system("rvm 1.8.7-p302@feed_parser,1.9.2-p0@feed_parser,1.9.3-p194@feed_parser do bundle exec rake spec")
26
26
  end
27
27
  end
data/lib/feed_parser.rb CHANGED
@@ -3,7 +3,7 @@ require 'nokogiri'
3
3
 
4
4
  class FeedParser
5
5
 
6
- VERSION = "0.3.1"
6
+ VERSION = "0.3.2"
7
7
 
8
8
  USER_AGENT = "Ruby / FeedParser gem"
9
9
 
@@ -49,18 +49,21 @@ class FeedParser
49
49
 
50
50
  # Some feeds
51
51
  def open_or_follow_redirect(feed_url)
52
- parsed_url = parse_url(feed_url)
52
+ parsed_url = URI.parse(feed_url)
53
53
 
54
54
  connection_options = {"User-Agent" => FeedParser::USER_AGENT}
55
55
  connection_options.merge!(@http_options)
56
- connection_options[:http_basic_authentication] = parsed_url[:basic_auth] if parsed_url[:basic_auth]
56
+ if parsed_url.userinfo
57
+ connection_options[:http_basic_authentication] = [parsed_url.user, parsed_url.password].compact
58
+ parsed_url.userinfo = parsed_url.user = parsed_url.password = nil
59
+ end
57
60
 
58
61
  connection_options[:redirect] = true if RUBY_VERSION >= '1.9'
59
62
 
60
- if parsed_url[:protocol]
61
- open(parsed_url[:url], connection_options)
63
+ if parsed_url.scheme
64
+ open(parsed_url.to_s, connection_options)
62
65
  else
63
- open(parsed_url[:url])
66
+ open(parsed_url.to_s)
64
67
  end
65
68
  rescue RuntimeError => ex
66
69
  redirect_url = ex.to_s.split(" ").last
@@ -70,14 +73,5 @@ class FeedParser
70
73
  raise ex
71
74
  end
72
75
  end
73
-
74
- def parse_url(feed_url)
75
- protocol, auth, *the_rest = URI.split(feed_url)
76
- # insert a question mark in the beginning of query part of the uri
77
- the_rest[-2].insert(0, '?') if the_rest[-2].is_a?(String)
78
- url = (protocol && [protocol, the_rest.join].join('://') || the_rest.join)
79
- basic_auth = auth.split(':') if auth
80
- {:protocol => protocol, :url => url, :basic_auth => basic_auth}
81
- end
82
76
  end
83
77
  end
@@ -57,7 +57,7 @@ class FeedParser
57
57
  def initialize(item)
58
58
  @type = :rss
59
59
  super
60
- @link = item.xpath(Dsl[@type][:item_link]).text
60
+ @link = item.xpath(Dsl[@type][:item_link]).text.strip
61
61
  @categories = item.xpath(Dsl[@type][:item_categories]).map{|cat| cat.text}
62
62
  end
63
63
  end
@@ -66,7 +66,7 @@ class FeedParser
66
66
  def initialize(item)
67
67
  @type = :atom
68
68
  super
69
- @link = item.xpath(Dsl[@type][:item_link]).attribute("href").text
69
+ @link = item.xpath(Dsl[@type][:item_link]).attribute("href").text.strip
70
70
  @categories = item.xpath(Dsl[@type][:item_categories]).map{|cat| cat.attribute("term").text}
71
71
  end
72
72
  end
@@ -143,6 +143,21 @@ describe FeedParser do
143
143
  }
144
144
  ]
145
145
  },
146
+ 'scrumalliance.rss.xml' => {
147
+ :title => "ScrumAlliance",
148
+ :url => "http://scrumalliance.org/",
149
+ :items => [
150
+ {
151
+ :guid => "http://scrumalliance.org/articles/424-testing-in-scrum-with-a-waterfall-interaction",
152
+ :link => "http://scrumalliance.org/articles/424-testing-in-scrum-with-a-waterfall-interaction", # trims the link
153
+ :title => "Testing in Scrum with a Waterfall Interaction",
154
+ :categories => [],
155
+ :author => "",
156
+ :description => "Sometimes, when testing user stories in Scrum, there's a final Waterfall interaction to deal with. The scenario I present here is based on this situation: a Scrum process with an interaction of sequential phases at the end of the process to (re)test the whole developed functionality. These sequential phases are mandatory for our organization, which follows a Waterfall process for the releases of the product. So, for the moment at least, we have to deal with this and my experience is that we aren't alone.",
157
+ :content => ""
158
+ }
159
+ ]
160
+ },
146
161
  'TechCrunch.xml' => {
147
162
  :title => "TechCrunch",
148
163
  :url => "http://techcrunch.com",
@@ -13,7 +13,6 @@
13
13
  <sy:updateFrequency>1</sy:updateFrequency>
14
14
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Nodeta" type="application/rss+xml" /><item>
15
15
  <title>Announcing Flowdock - Real-time collaboration for teams</title>
16
- <link>http://blog.nodeta.fi/2009/07/05/announcing-flowdock-real-time-collaboration-for-teams/</link>
17
16
  <comments>http://blog.nodeta.fi/2009/07/05/announcing-flowdock-real-time-collaboration-for-teams/#comments</comments>
18
17
  <pubDate>Sun, 05 Jul 2009 09:25:32 +0000</pubDate>
19
18
  <dc:creator>Karri Saarinen</dc:creator>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
3
+ <channel>
4
+ <atom:link href="http://www.scrumalliance.org/rss" rel="self" type="application/rss+xml" />
5
+ <title>ScrumAlliance</title>
6
+ <link>http://scrumalliance.org/</link>
7
+ <pubDate>Wed, 23 May 2012 11:07:32 GMT</pubDate>
8
+ <description> Scrum Alliance </description>
9
+
10
+ <item>
11
+ <title>Testing in Scrum with a Waterfall Interaction</title>
12
+ <link> http://scrumalliance.org/articles/424-testing-in-scrum-with-a-waterfall-interaction</link>
13
+ <description>Sometimes, when testing user stories in Scrum, there's a final Waterfall interaction to deal with. The scenario I present here is based on this situation: a Scrum process with an interaction of sequential phases at the end of the process to (re)test the whole developed functionality. These sequential phases are mandatory for our organization, which follows a Waterfall process for the releases of the product. So, for the moment at least, we have to deal with this and my experience is that we aren't alone.</description>
14
+ <pubDate>Wed, 23 May 2012 11:07:03 GMT</pubDate>
15
+ <guid>http://scrumalliance.org/articles/424-testing-in-scrum-with-a-waterfall-interaction</guid>
16
+ </item>
17
+ </channel>
18
+ </rss>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feed_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-07 00:00:00.000000000 Z
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &2152816100 !ruby/object:Gem::Requirement
16
+ requirement: &2153328640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152816100
24
+ version_requirements: *2153328640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec-rails
27
- requirement: &2152815240 !ruby/object:Gem::Requirement
27
+ requirement: &2153383440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '2.6'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2152815240
35
+ version_requirements: *2153383440
36
36
  description: Rss and Atom feed parser with sanitizer support built on top of Nokogiri.
37
37
  email:
38
38
  - arttu.tervo@gmail.com
@@ -60,6 +60,7 @@ files:
60
60
  - spec/fixtures/gcal.atom.xml
61
61
  - spec/fixtures/nodeta.rss.xml
62
62
  - spec/fixtures/sanitize.me.rss.xml
63
+ - spec/fixtures/scrumalliance.rss.xml
63
64
  - spec/fixtures/smashingmagazine.atom.xml
64
65
  homepage: http://github.com/arttu/feed_parser
65
66
  licenses: []
@@ -93,4 +94,5 @@ test_files:
93
94
  - spec/fixtures/gcal.atom.xml
94
95
  - spec/fixtures/nodeta.rss.xml
95
96
  - spec/fixtures/sanitize.me.rss.xml
97
+ - spec/fixtures/scrumalliance.rss.xml
96
98
  - spec/fixtures/smashingmagazine.atom.xml