feedbagtoo 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/feedbagtoo.gemspec +2 -2
  3. data/lib/feedbag.rb +15 -5
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.3
1
+ 0.7.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{feedbagtoo}
8
- s.version = "0.7.3"
8
+ s.version = "0.7.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Axiombox", "David Moreno", "Joel Duffin", "Justin Ball", "Fabien Penso"]
12
- s.date = %q{2012-07-23}
12
+ s.date = %q{2012-07-24}
13
13
  s.default_executable = %q{feedbag}
14
14
  s.description = %q{This gem will return title and url for each feed discovered at a given url}
15
15
  s.email = %q{justin@tatemae.com}
@@ -93,7 +93,7 @@ module Feedbag
93
93
  end
94
94
 
95
95
  begin
96
- Timeout::timeout(15) do
96
+ Timeout::timeout(20) do
97
97
  html = open(url) do |f|
98
98
  content_type = f.content_type.downcase
99
99
  if content_type == "application/octet-stream" # open failed
@@ -140,16 +140,16 @@ module Feedbag
140
140
  (doc/"a").each do |a|
141
141
  next unless a["href"]
142
142
  if self.looks_like_feed?(a["href"]) and (a["href"] =~ /\// or a["href"] =~ /#{url_uri.host}/)
143
- title = a["title"] || a.innerText || a['alt'] || title
144
- self.add_feed(a["href"], url, $base_uri, title, description || title)
143
+ calculated_title = self.title_for_anchor(a, title)
144
+ self.add_feed(a["href"], url, $base_uri, calculated_title, description || calculated_title)
145
145
  end
146
146
  end
147
147
 
148
148
  (doc/"a").each do |a|
149
149
  next unless a["href"]
150
150
  if self.looks_like_feed?(a["href"])
151
- title = a["title"] || a.innerText || a['alt'] || title
152
- self.add_feed(a["href"], url, $base_uri, title, description || title)
151
+ calculated_title = self.title_for_anchor(a, title)
152
+ self.add_feed(a["href"], url, $base_uri, calculated_title, description || calculated_title)
153
153
  end
154
154
  end
155
155
 
@@ -173,6 +173,7 @@ module Feedbag
173
173
  end
174
174
 
175
175
  def self.looks_like_feed?(url)
176
+ return false unless url[0...4] == 'http'
176
177
  if url =~ /((\.|\/)(rdf|xml|rdf|rss)$|feed=(rss|atom)|(atom|feed)\/?$)/i
177
178
  true
178
179
  else
@@ -180,6 +181,15 @@ module Feedbag
180
181
  end
181
182
  end
182
183
 
184
+ def self.title_for_anchor(a, title)
185
+ t = a["title"] || a.innerText || a['alt']
186
+ if(t && t.length > 0)
187
+ t
188
+ else
189
+ title
190
+ end
191
+ end
192
+
183
193
  def self.add_feed(feed_url, orig_url, base_uri = nil, title = "", description = "")
184
194
  # puts "#{feed_url} - #{orig_url}"
185
195
  url = feed_url.sub(/^feed:/, '').strip
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedbagtoo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 3
10
- version: 0.7.3
9
+ - 4
10
+ version: 0.7.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Axiombox
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2012-07-23 00:00:00 -06:00
22
+ date: 2012-07-24 00:00:00 -06:00
23
23
  default_executable: feedbag
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency