feedtools 0.2.9 → 0.2.10
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/CHANGELOG +5 -0
- data/db/schema.mysql.sql +10 -0
- data/db/schema.postgresql.sql +9 -0
- data/db/schema.sqlite.sql +9 -0
- data/lib/database_feed_cache.rb +0 -61
- data/lib/feed_tools.rb +49 -7
- data/rakefile +6 -4
- metadata +6 -3
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== FeedTools 0.2.10
|
2
|
+
* http error messages now sport a list of redirections to simplify debugging
|
3
|
+
* automatic table creation removed
|
4
|
+
* database schema information included in rdoc and package files
|
5
|
+
* deals with servers returning 404 if passed a User-Agent http header
|
1
6
|
== FeedTools 0.2.9
|
2
7
|
* changed ordering of elements checked for the item content
|
3
8
|
* added dependancy on uuidtools, uuids used in feed generation
|
data/db/schema.mysql.sql
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
CREATE TABLE `feeds` (
|
2
|
+
`id` int(10) unsigned NOT NULL auto_increment,
|
3
|
+
`url` varchar(255) default NULL,
|
4
|
+
`title` varchar(255) default NULL,
|
5
|
+
`link` varchar(255) default NULL,
|
6
|
+
`xml_data` longtext default NULL,
|
7
|
+
`http_headers` text default NULL,
|
8
|
+
`last_retrieved` datetime default NULL,
|
9
|
+
PRIMARY KEY (`id`)
|
10
|
+
)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
CREATE TABLE feeds (
|
2
|
+
id SERIAL PRIMARY KEY NOT NULL,
|
3
|
+
url varchar(255) default NULL,
|
4
|
+
title varchar(255) default NULL,
|
5
|
+
link varchar(255) default NULL,
|
6
|
+
xml_data text default NULL,
|
7
|
+
http_headers text default NULL,
|
8
|
+
last_retrieved timestamp default NULL
|
9
|
+
);
|
@@ -0,0 +1,9 @@
|
|
1
|
+
CREATE TABLE 'feeds' (
|
2
|
+
'id' INTEGER PRIMARY KEY NOT NULL,
|
3
|
+
'url' VARCHAR(255) DEFAULT NULL,
|
4
|
+
'title' VARCHAR(255) DEFAULT NULL,
|
5
|
+
'link' VARCHAR(255) DEFAULT NULL,
|
6
|
+
'xml_data' TEXT DEFAULT NULL,
|
7
|
+
'http_headers' TEXT DEFAULT NULL,
|
8
|
+
'last_retrieved' DATETIME DEFAULT NULL
|
9
|
+
);
|
data/lib/database_feed_cache.rb
CHANGED
@@ -51,11 +51,6 @@ module FeedTools
|
|
51
51
|
rescue
|
52
52
|
end
|
53
53
|
end
|
54
|
-
# Verify that the necessary database tables are in place
|
55
|
-
# and if they're missing, create them
|
56
|
-
unless DatabaseFeedCache.table_exists?
|
57
|
-
DatabaseFeedCache.create_table
|
58
|
-
end
|
59
54
|
return nil
|
60
55
|
end
|
61
56
|
|
@@ -85,61 +80,5 @@ module FeedTools
|
|
85
80
|
end
|
86
81
|
return true
|
87
82
|
end
|
88
|
-
|
89
|
-
# Creates the appropriate database table
|
90
|
-
# Deprecated.
|
91
|
-
def DatabaseFeedCache.create_table
|
92
|
-
warn("The table creation methods will be removed in a future version " +
|
93
|
-
"and any reliance on this method should be removed.")
|
94
|
-
unless DatabaseFeedCache.table_exists?
|
95
|
-
feeds_mysql = <<-SQL_END
|
96
|
-
CREATE TABLE `#{self.table_name()}` (
|
97
|
-
`id` int(10) unsigned NOT NULL auto_increment,
|
98
|
-
`url` varchar(255) default NULL,
|
99
|
-
`title` varchar(255) default NULL,
|
100
|
-
`link` varchar(255) default NULL,
|
101
|
-
`xml_data` longtext default NULL,
|
102
|
-
`http_headers` text default NULL,
|
103
|
-
`last_retrieved` datetime default NULL,
|
104
|
-
PRIMARY KEY (`id`)
|
105
|
-
)
|
106
|
-
SQL_END
|
107
|
-
feeds_sqlite = <<-SQL_END
|
108
|
-
CREATE TABLE '#{self.table_name()}' (
|
109
|
-
'id' INTEGER PRIMARY KEY NOT NULL,
|
110
|
-
'url' VARCHAR(255) DEFAULT NULL,
|
111
|
-
'title' VARCHAR(255) DEFAULT NULL,
|
112
|
-
'link' VARCHAR(255) DEFAULT NULL,
|
113
|
-
'xml_data' TEXT DEFAULT NULL,
|
114
|
-
'http_headers' TEXT DEFAULT NULL,
|
115
|
-
'last_retrieved' DATETIME DEFAULT NULL
|
116
|
-
);
|
117
|
-
SQL_END
|
118
|
-
feeds_psql = <<-SQL_END
|
119
|
-
CREATE TABLE #{self.table_name()} (
|
120
|
-
id SERIAL PRIMARY KEY NOT NULL,
|
121
|
-
url varchar(255) default NULL,
|
122
|
-
title varchar(255) default NULL,
|
123
|
-
link varchar(255) default NULL,
|
124
|
-
xml_data text default NULL,
|
125
|
-
http_headers text default NULL,
|
126
|
-
last_retrieved timestamp default NULL
|
127
|
-
);
|
128
|
-
SQL_END
|
129
|
-
table_creation_sql = nil
|
130
|
-
if configurations["adapter"] == "mysql"
|
131
|
-
table_creation_sql = feeds_mysql
|
132
|
-
elsif configurations["adapter"] == "sqlite"
|
133
|
-
table_creation_sql = feeds_sqlite
|
134
|
-
elsif configurations["adapter"] == "postgresql"
|
135
|
-
table_creation_sql = feeds_psql
|
136
|
-
end
|
137
|
-
if table_creation_sql.nil?
|
138
|
-
raise "Could not build #{self.table_name()} table."
|
139
|
-
else
|
140
|
-
connection.execute table_creation_sql
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
83
|
end
|
145
84
|
end
|
data/lib/feed_tools.rb
CHANGED
@@ -32,7 +32,7 @@ FEED_TOOLS_ENV = ENV['FEED_TOOLS_ENV'] ||
|
|
32
32
|
ENV['RAILS_ENV'] ||
|
33
33
|
'production' # :nodoc:
|
34
34
|
|
35
|
-
FEED_TOOLS_VERSION = "0.2.
|
35
|
+
FEED_TOOLS_VERSION = "0.2.10"
|
36
36
|
|
37
37
|
$:.unshift(File.dirname(__FILE__))
|
38
38
|
$:.unshift(File.dirname(__FILE__) + "/feed_tools/vendor")
|
@@ -75,7 +75,7 @@ require 'pp'
|
|
75
75
|
require 'yaml'
|
76
76
|
|
77
77
|
require_gem('activerecord', '>= 1.10.1')
|
78
|
-
require_gem('uuidtools', '>= 0.1.
|
78
|
+
require_gem('uuidtools', '>= 0.1.2')
|
79
79
|
|
80
80
|
require 'database_feed_cache'
|
81
81
|
|
@@ -832,7 +832,7 @@ module FeedTools
|
|
832
832
|
|
833
833
|
# The http feed access method
|
834
834
|
http_fetch = lambda do |feed_url, http_headers, redirect_limit,
|
835
|
-
response_chain|
|
835
|
+
response_chain, no_headers|
|
836
836
|
raise FeedAccessError, 'Redirect too deep' if redirect_limit == 0
|
837
837
|
feed_uri = nil
|
838
838
|
begin
|
@@ -850,10 +850,11 @@ module FeedTools
|
|
850
850
|
# So override it here explicitly.
|
851
851
|
http_headers['Host'] = feed_uri.host
|
852
852
|
http_headers['Host'] += ":#{feed_uri.port}" if feed_uri.port
|
853
|
-
|
853
|
+
|
854
854
|
Net::HTTP.start(feed_uri.host, (feed_uri.port or 80)) do |http|
|
855
855
|
final_uri = feed_uri.path
|
856
856
|
final_uri += ('?' + feed_uri.query) if feed_uri.query
|
857
|
+
http_headers = {} if no_headers
|
857
858
|
response = http.request_get(final_uri, http_headers)
|
858
859
|
|
859
860
|
case response
|
@@ -889,16 +890,50 @@ module FeedTools
|
|
889
890
|
# in Location header
|
890
891
|
# =================================================
|
891
892
|
http_fetch.call(new_location, http_headers,
|
892
|
-
redirect_limit - 1, response_chain)
|
893
|
+
redirect_limit - 1, response_chain, no_headers)
|
893
894
|
end
|
894
895
|
else
|
896
|
+
class << response
|
897
|
+
def response_chain
|
898
|
+
return @response_chain
|
899
|
+
end
|
900
|
+
end
|
901
|
+
response.instance_variable_set("@response_chain",
|
902
|
+
response_chain)
|
895
903
|
response.error!
|
896
904
|
end
|
897
905
|
end
|
898
906
|
end
|
899
907
|
|
900
908
|
begin
|
901
|
-
|
909
|
+
begin
|
910
|
+
@http_response = http_fetch.call(self.url, headers, 10, [], false)
|
911
|
+
rescue => error
|
912
|
+
if error.respond_to?(:response)
|
913
|
+
# You might not believe this, but...
|
914
|
+
#
|
915
|
+
# Under certain circumstances, web servers will try to block
|
916
|
+
# based on the User-Agent header. This is *retarded*. But
|
917
|
+
# we won't let their stupid error stop us!
|
918
|
+
#
|
919
|
+
# This is, of course, a quick-n-dirty hack. But at least
|
920
|
+
# we get to blame other people's bad software and/or bad
|
921
|
+
# configuration files.
|
922
|
+
if error.response.code.to_i == 404 &&
|
923
|
+
FeedTools.user_agent != nil
|
924
|
+
@http_response = http_fetch.call(self.url, {}, 10, [], true)
|
925
|
+
if @http_response != nil && @http_response.code.to_i == 200
|
926
|
+
warn("The server appears to be blocking based on the " +
|
927
|
+
"User-Agent header. This is stupid, and you should " +
|
928
|
+
"inform the webmaster of this.")
|
929
|
+
end
|
930
|
+
else
|
931
|
+
raise error
|
932
|
+
end
|
933
|
+
else
|
934
|
+
raise error
|
935
|
+
end
|
936
|
+
end
|
902
937
|
@http_headers = {}
|
903
938
|
self.http_response.each_header do |header|
|
904
939
|
self.http_headers[header.first.downcase] = header.last
|
@@ -948,7 +983,14 @@ module FeedTools
|
|
948
983
|
end
|
949
984
|
@live = false
|
950
985
|
if self.xml_data.nil?
|
951
|
-
|
986
|
+
if error.respond_to?(:response) &&
|
987
|
+
error.response.respond_to?(:response_chain)
|
988
|
+
redirects = error.response.response_chain.map do |pair|
|
989
|
+
pair.first
|
990
|
+
end
|
991
|
+
error.message << (" - Redirects: " + redirects.inspect)
|
992
|
+
end
|
993
|
+
raise error
|
952
994
|
end
|
953
995
|
end
|
954
996
|
elsif retrieval_method == "https"
|
data/rakefile
CHANGED
@@ -7,7 +7,7 @@ require 'rake/gempackagetask'
|
|
7
7
|
require 'rake/contrib/rubyforgepublisher'
|
8
8
|
|
9
9
|
PKG_NAME = 'feedtools'
|
10
|
-
PKG_VERSION = '0.2.
|
10
|
+
PKG_VERSION = '0.2.10'
|
11
11
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
12
12
|
|
13
13
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
@@ -16,7 +16,8 @@ RUBY_FORGE_PROJECT = "feedtools"
|
|
16
16
|
RUBY_FORGE_USER = "vacindak"
|
17
17
|
|
18
18
|
PKG_FILES = FileList[
|
19
|
-
"lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "
|
19
|
+
"lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "db/**/*",
|
20
|
+
"[A-Z]*", "install.rb", "rakefile"
|
20
21
|
].exclude(/\bCVS\b|~$/).exclude(/database\.yml/)
|
21
22
|
|
22
23
|
desc "Default Task"
|
@@ -39,11 +40,12 @@ Rake::RDocTask.new { |rdoc|
|
|
39
40
|
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
40
41
|
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
41
42
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
43
|
+
rdoc.rdoc_files.include('db/**/*.sql')
|
42
44
|
}
|
43
45
|
|
44
46
|
# Create compressed packages
|
45
47
|
|
46
|
-
dist_dirs = [ "lib", "test" ]
|
48
|
+
dist_dirs = [ "lib", "test", "db" ]
|
47
49
|
|
48
50
|
spec = Gem::Specification.new do |s|
|
49
51
|
s.name = PKG_NAME
|
@@ -59,7 +61,7 @@ spec = Gem::Specification.new do |s|
|
|
59
61
|
end
|
60
62
|
|
61
63
|
s.add_dependency('activerecord', '>= 1.10.1')
|
62
|
-
s.add_dependency('uuidtools', '>= 0.1.
|
64
|
+
s.add_dependency('uuidtools', '>= 0.1.2')
|
63
65
|
|
64
66
|
s.require_path = 'lib'
|
65
67
|
s.autorequire = 'feed_tools'
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: feedtools
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2005-09-
|
6
|
+
version: 0.2.10
|
7
|
+
date: 2005-09-26 00:00:00 -04:00
|
8
8
|
summary: "Parsing, generation, and caching system for xml news feeds."
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -78,6 +78,9 @@ files:
|
|
78
78
|
- test/helper_test.rb
|
79
79
|
- test/nonstandard_test.rb
|
80
80
|
- test/rss_test.rb
|
81
|
+
- db/schema.mysql.sql
|
82
|
+
- db/schema.postgresql.sql
|
83
|
+
- db/schema.sqlite.sql
|
81
84
|
test_files: []
|
82
85
|
rdoc_options:
|
83
86
|
- "--main"
|
@@ -106,5 +109,5 @@ dependencies:
|
|
106
109
|
-
|
107
110
|
- ">="
|
108
111
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0.1.
|
112
|
+
version: 0.1.2
|
110
113
|
version:
|