feedtools 0.2.20 → 0.2.21
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/lib/feed_tools.rb +2 -3
- data/lib/feed_tools/database_feed_cache.rb +15 -1
- data/lib/feed_tools/feed.rb +5 -3
- data/lib/feed_tools/feed_item.rb +5 -4
- data/rakefile +1 -1
- data/test/unit/generation_test.rb +114 -3
- metadata +2 -2
data/CHANGELOG
CHANGED
data/lib/feed_tools.rb
CHANGED
@@ -32,7 +32,7 @@ FEED_TOOLS_ENV = ENV['FEED_TOOLS_ENV'] ||
|
|
32
32
|
ENV['RAILS_ENV'] ||
|
33
33
|
'development' # :nodoc:
|
34
34
|
|
35
|
-
FEED_TOOLS_VERSION = "0.2.
|
35
|
+
FEED_TOOLS_VERSION = "0.2.21"
|
36
36
|
|
37
37
|
FEED_TOOLS_NAMESPACES = {
|
38
38
|
"admin" => "http://webns.net/mvcb/",
|
@@ -173,8 +173,7 @@ module FeedTools
|
|
173
173
|
:url_normalization_enabled => true,
|
174
174
|
:strip_comment_count => false,
|
175
175
|
:max_ttl => 3.days.to_s,
|
176
|
-
:output_encoding => "utf-8"
|
177
|
-
:no_content_value => "[no description]"
|
176
|
+
:output_encoding => "utf-8"
|
178
177
|
}.merge(config_hash)
|
179
178
|
end
|
180
179
|
return @configurations
|
@@ -90,7 +90,21 @@ module FeedTools
|
|
90
90
|
end
|
91
91
|
return true
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
|
+
# False if there is an error of any kind
|
95
|
+
def DatabaseFeedCache.set_up_correctly?
|
96
|
+
begin
|
97
|
+
ActiveRecord::Base.connection
|
98
|
+
if !ActiveRecord::Base.configurations.nil? &&
|
99
|
+
!DatabaseFeedCache.table_exists?
|
100
|
+
return false
|
101
|
+
end
|
102
|
+
rescue Exception
|
103
|
+
return false
|
104
|
+
end
|
105
|
+
return true
|
106
|
+
end
|
107
|
+
|
94
108
|
# True if the appropriate database table already exists
|
95
109
|
def DatabaseFeedCache.table_exists?
|
96
110
|
begin
|
data/lib/feed_tools/feed.rb
CHANGED
@@ -177,6 +177,11 @@ module FeedTools
|
|
177
177
|
# Loads the feed from the remote url if the feed has expired from the cache or cannot be
|
178
178
|
# retrieved from the cache for some reason.
|
179
179
|
def update!
|
180
|
+
if !FeedTools.feed_cache.nil? &&
|
181
|
+
!FeedTools.feed_cache.set_up_correctly?
|
182
|
+
raise "Your feed cache system is incorrectly set up. " +
|
183
|
+
"Please see the documentation for more information."
|
184
|
+
end
|
180
185
|
if self.http_headers.blank? && !(self.cache_object.nil?) &&
|
181
186
|
!(self.cache_object.http_headers.nil?)
|
182
187
|
@http_headers = YAML.load(self.cache_object.http_headers)
|
@@ -2257,9 +2262,6 @@ module FeedTools
|
|
2257
2262
|
unless description.blank?
|
2258
2263
|
xml_builder.subtitle(self.subtitle,
|
2259
2264
|
"type" => "html")
|
2260
|
-
else
|
2261
|
-
xml_builder.subtitle(FeedTools.no_content_string,
|
2262
|
-
"type" => "html")
|
2263
2265
|
end
|
2264
2266
|
if self.updated != nil
|
2265
2267
|
xml_builder.updated(self.updated.iso8601)
|
data/lib/feed_tools/feed_item.rb
CHANGED
@@ -1958,11 +1958,12 @@ module FeedTools
|
|
1958
1958
|
"type" => "text/html",
|
1959
1959
|
"title" => FeedTools.escape_entities(title))
|
1960
1960
|
end
|
1961
|
-
if !
|
1962
|
-
xml_builder.content(
|
1961
|
+
if !self.content.blank?
|
1962
|
+
xml_builder.content(self.content,
|
1963
1963
|
"type" => "html")
|
1964
|
-
|
1965
|
-
|
1964
|
+
end
|
1965
|
+
if !self.summary.blank?
|
1966
|
+
xml_builder.content(self.summary,
|
1966
1967
|
"type" => "html")
|
1967
1968
|
end
|
1968
1969
|
if self.updated != nil
|
data/rakefile
CHANGED
@@ -19,7 +19,7 @@ class GenerationTest < Test::Unit::TestCase
|
|
19
19
|
item.content = "This is item number #{i}"
|
20
20
|
item.link = "http://example.com/item#{i}/"
|
21
21
|
feed.items << item
|
22
|
-
sleep(
|
22
|
+
sleep(0.5)
|
23
23
|
end
|
24
24
|
output_xml = feed.build_xml('rss', 2.0)
|
25
25
|
|
@@ -57,7 +57,7 @@ class GenerationTest < Test::Unit::TestCase
|
|
57
57
|
item.content = "This is item number #{i}"
|
58
58
|
item.link = "http://example.com/item#{i}/"
|
59
59
|
feed.items << item
|
60
|
-
sleep(
|
60
|
+
sleep(0.5)
|
61
61
|
end
|
62
62
|
output_xml = feed.build_xml('rss', 1.0)
|
63
63
|
|
@@ -95,7 +95,7 @@ class GenerationTest < Test::Unit::TestCase
|
|
95
95
|
item.content = "This is item number #{i}"
|
96
96
|
item.link = "http://example.com/item#{i}/"
|
97
97
|
feed.items << item
|
98
|
-
sleep(
|
98
|
+
sleep(0.5)
|
99
99
|
end
|
100
100
|
output_xml = feed.build_xml('atom', 1.0)
|
101
101
|
|
@@ -121,4 +121,115 @@ class GenerationTest < Test::Unit::TestCase
|
|
121
121
|
assert_equal('atom', parsed_feed.feed_type)
|
122
122
|
assert_equal(1.0, parsed_feed.feed_version)
|
123
123
|
end
|
124
|
+
|
125
|
+
def test_generate_rss_with_no_content
|
126
|
+
feed = FeedTools::Feed.new
|
127
|
+
feed.title = 'Test Feed'
|
128
|
+
feed.subtitle = nil
|
129
|
+
feed.link = 'http://example.com/'
|
130
|
+
3.times do |i|
|
131
|
+
item = FeedTools::FeedItem.new
|
132
|
+
item.content = nil
|
133
|
+
item.link = "http://example.com/item#{i}/"
|
134
|
+
feed.items << item
|
135
|
+
sleep(0.5)
|
136
|
+
end
|
137
|
+
output_xml = feed.build_xml('rss', 2.0)
|
138
|
+
|
139
|
+
# Now read it back in
|
140
|
+
parsed_feed = FeedTools::Feed.new
|
141
|
+
parsed_feed.feed_data = output_xml
|
142
|
+
parsed_feed.feed_data_type = :xml
|
143
|
+
|
144
|
+
assert_equal('Test Feed', parsed_feed.title)
|
145
|
+
assert_equal(nil, parsed_feed.description)
|
146
|
+
assert_equal('http://example.com/', parsed_feed.link)
|
147
|
+
|
148
|
+
# Note reverse chronological order
|
149
|
+
assert_equal(nil, parsed_feed.items[0].content)
|
150
|
+
assert_equal('http://example.com/item2/', parsed_feed.items[0].link)
|
151
|
+
assert_equal(nil, parsed_feed.items[1].content)
|
152
|
+
assert_equal('http://example.com/item1/', parsed_feed.items[1].link)
|
153
|
+
assert_equal(nil, parsed_feed.items[2].content)
|
154
|
+
assert_equal('http://example.com/item0/', parsed_feed.items[2].link)
|
155
|
+
|
156
|
+
# Check feed information
|
157
|
+
assert_equal(:xml, parsed_feed.feed_data_type)
|
158
|
+
assert_equal('rss', parsed_feed.feed_type)
|
159
|
+
assert_equal(2.0, parsed_feed.feed_version)
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_generate_rdf_with_no_content
|
163
|
+
feed = FeedTools::Feed.new
|
164
|
+
feed.title = 'Test Feed'
|
165
|
+
feed.subtitle = nil
|
166
|
+
feed.link = 'http://example.com/'
|
167
|
+
3.times do |i|
|
168
|
+
item = FeedTools::FeedItem.new
|
169
|
+
item.content = nil
|
170
|
+
item.link = "http://example.com/item#{i}/"
|
171
|
+
feed.items << item
|
172
|
+
sleep(0.5)
|
173
|
+
end
|
174
|
+
output_xml = feed.build_xml('rss', 1.0)
|
175
|
+
|
176
|
+
# Now read it back in
|
177
|
+
parsed_feed = FeedTools::Feed.new
|
178
|
+
parsed_feed.feed_data = output_xml
|
179
|
+
parsed_feed.feed_data_type = :xml
|
180
|
+
|
181
|
+
assert_equal('Test Feed', parsed_feed.title)
|
182
|
+
assert_equal(nil, parsed_feed.description)
|
183
|
+
assert_equal('http://example.com/', parsed_feed.link)
|
184
|
+
|
185
|
+
# Note reverse chronological order
|
186
|
+
assert_equal(nil, parsed_feed.items[0].content)
|
187
|
+
assert_equal('http://example.com/item2/', parsed_feed.items[0].link)
|
188
|
+
assert_equal(nil, parsed_feed.items[1].content)
|
189
|
+
assert_equal('http://example.com/item1/', parsed_feed.items[1].link)
|
190
|
+
assert_equal(nil, parsed_feed.items[2].content)
|
191
|
+
assert_equal('http://example.com/item0/', parsed_feed.items[2].link)
|
192
|
+
|
193
|
+
# Check feed information
|
194
|
+
assert_equal(:xml, parsed_feed.feed_data_type)
|
195
|
+
assert_equal('rss', parsed_feed.feed_type)
|
196
|
+
assert_equal(1.0, parsed_feed.feed_version)
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_generate_atom_with_no_content
|
200
|
+
feed = FeedTools::Feed.new
|
201
|
+
feed.title = 'Test Feed'
|
202
|
+
feed.subtitle = nil
|
203
|
+
feed.link = 'http://example.com/'
|
204
|
+
3.times do |i|
|
205
|
+
item = FeedTools::FeedItem.new
|
206
|
+
item.content = nil
|
207
|
+
item.link = "http://example.com/item#{i}/"
|
208
|
+
feed.items << item
|
209
|
+
sleep(0.5)
|
210
|
+
end
|
211
|
+
output_xml = feed.build_xml('atom', 1.0)
|
212
|
+
|
213
|
+
# Now read it back in
|
214
|
+
parsed_feed = FeedTools::Feed.new
|
215
|
+
parsed_feed.feed_data = output_xml
|
216
|
+
parsed_feed.feed_data_type = :xml
|
217
|
+
|
218
|
+
assert_equal('Test Feed', parsed_feed.title)
|
219
|
+
assert_equal(nil, parsed_feed.description)
|
220
|
+
assert_equal('http://example.com/', parsed_feed.link)
|
221
|
+
|
222
|
+
# Note reverse chronological order
|
223
|
+
assert_equal(nil, parsed_feed.items[0].content)
|
224
|
+
assert_equal('http://example.com/item2/', parsed_feed.items[0].link)
|
225
|
+
assert_equal(nil, parsed_feed.items[1].content)
|
226
|
+
assert_equal('http://example.com/item1/', parsed_feed.items[1].link)
|
227
|
+
assert_equal(nil, parsed_feed.items[2].content)
|
228
|
+
assert_equal('http://example.com/item0/', parsed_feed.items[2].link)
|
229
|
+
|
230
|
+
# Check feed information
|
231
|
+
assert_equal(:xml, parsed_feed.feed_data_type)
|
232
|
+
assert_equal('atom', parsed_feed.feed_type)
|
233
|
+
assert_equal(1.0, parsed_feed.feed_version)
|
234
|
+
end
|
124
235
|
end
|
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: 2006-01-
|
6
|
+
version: 0.2.21
|
7
|
+
date: 2006-01-22 00:00:00 -05:00
|
8
8
|
summary: "Parsing, generation, and caching system for xml news feeds."
|
9
9
|
require_paths:
|
10
10
|
- lib
|