feedbag 0.5.100 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/feedbag +28 -0
- data/lib/feedbag.rb +29 -31
- metadata +22 -12
data/bin/feedbag
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "feedbag"
|
5
|
+
|
6
|
+
def usage
|
7
|
+
%Q{
|
8
|
+
#{$0} <url 1> [<url 2> <url 3> ... <url n>]
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
if ARGV.empty?
|
13
|
+
puts usage
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
|
17
|
+
ARGV.each do |url|
|
18
|
+
puts "== #{url}:"
|
19
|
+
feeds = Feedbag.find url
|
20
|
+
if feeds.empty?
|
21
|
+
puts " no feeds found!"
|
22
|
+
else
|
23
|
+
feeds.each do |f|
|
24
|
+
puts " - #{f}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
data/lib/feedbag.rb
CHANGED
@@ -39,6 +39,8 @@ module Feedbag
|
|
39
39
|
# use LWR::Simple.normalize some time
|
40
40
|
url_uri = URI.parse(url)
|
41
41
|
url = "#{url_uri.scheme or 'http'}://#{url_uri.host}#{url_uri.path}"
|
42
|
+
url << "?#{url_uri.query}" if url_uri.query
|
43
|
+
|
42
44
|
# hack:
|
43
45
|
url.sub!(/^feed:\/\//, 'http://')
|
44
46
|
|
@@ -65,22 +67,20 @@ module Feedbag
|
|
65
67
|
#url = "#{url_uri.scheme or 'http'}://#{url_uri.host}#{url_uri.path}"
|
66
68
|
|
67
69
|
# check if feed_valid is avail
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|
70
|
+
begin
|
71
|
+
require "feed_validator"
|
72
|
+
v = W3C::FeedValidator.new
|
73
|
+
v.validate_url(url)
|
74
|
+
return self.add_feed(url, nil) if v.valid?
|
75
|
+
rescue LoadError
|
76
|
+
# scoo
|
77
|
+
rescue REXML::ParseException
|
78
|
+
# usually indicates timeout
|
79
|
+
# TODO: actually find out timeout. use Terminator?
|
80
|
+
# $stderr.puts "Feed looked like feed but might not have passed validation or timed out"
|
81
|
+
rescue => ex
|
82
|
+
$stderr.puts "#{ex.class} error ocurred with: `#{url}': #{ex.message}"
|
83
|
+
end
|
84
84
|
|
85
85
|
begin
|
86
86
|
html = open(url) do |f|
|
@@ -108,21 +108,19 @@ module Feedbag
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
end
|
125
|
-
end
|
111
|
+
(doc/"a").each do |a|
|
112
|
+
next unless a["href"]
|
113
|
+
if self.looks_like_feed?(a["href"]) and (a["href"] =~ /\// or a["href"] =~ /#{url_uri.host}/)
|
114
|
+
self.add_feed(a["href"], url, $base_uri)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
(doc/"a").each do |a|
|
119
|
+
next unless a["href"]
|
120
|
+
if self.looks_like_feed?(a["href"])
|
121
|
+
self.add_feed(a["href"], url, $base_uri)
|
122
|
+
end
|
123
|
+
end
|
126
124
|
|
127
125
|
end
|
128
126
|
rescue Timeout::Error => err
|
metadata
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feedbag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 6
|
8
|
+
version: "0.6"
|
5
9
|
platform: ruby
|
6
10
|
authors:
|
7
11
|
- Axiombox
|
@@ -10,23 +14,26 @@ autorequire:
|
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
16
|
|
13
|
-
date:
|
14
|
-
default_executable:
|
17
|
+
date: 2010-03-05 00:00:00 -05:00
|
18
|
+
default_executable: feedbag
|
15
19
|
dependencies:
|
16
20
|
- !ruby/object:Gem::Dependency
|
17
21
|
name: hpricot
|
18
|
-
|
19
|
-
|
20
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
24
|
requirements:
|
22
25
|
- - ">="
|
23
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 6
|
24
30
|
version: "0.6"
|
25
|
-
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
26
33
|
description: Ruby's favorite feed auto-discoverty tool
|
27
34
|
email: david@axiombox.com
|
28
|
-
executables:
|
29
|
-
|
35
|
+
executables:
|
36
|
+
- feedbag
|
30
37
|
extensions: []
|
31
38
|
|
32
39
|
extra_rdoc_files:
|
@@ -35,6 +42,7 @@ extra_rdoc_files:
|
|
35
42
|
files:
|
36
43
|
- lib/feedbag.rb
|
37
44
|
- benchmark/rfeedfinder_benchmark.rb
|
45
|
+
- bin/feedbag
|
38
46
|
- README.markdown
|
39
47
|
- COPYING
|
40
48
|
has_rdoc: true
|
@@ -51,18 +59,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
59
|
requirements:
|
52
60
|
- - ">="
|
53
61
|
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
54
64
|
version: "0"
|
55
|
-
version:
|
56
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
66
|
requirements:
|
58
67
|
- - ">="
|
59
68
|
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
60
71
|
version: "0"
|
61
|
-
version:
|
62
72
|
requirements: []
|
63
73
|
|
64
74
|
rubyforge_project: feedbag
|
65
|
-
rubygems_version: 1.3.
|
75
|
+
rubygems_version: 1.3.6
|
66
76
|
signing_key:
|
67
77
|
specification_version: 3
|
68
78
|
summary: Ruby's favorite feed auto-discovery tool
|