syndication 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +21 -0
- data/examples/podcast.rb +24 -0
- data/lib/syndication/atom.rb +53 -3
- data/rakefile +10 -1
- data/test/google.rb +2 -1
- data/test/rsstest.rb +3 -3
- metadata +59 -49
data/CHANGES
CHANGED
@@ -1,6 +1,27 @@
|
|
1
|
+
# == Changes in 0.6.2
|
2
|
+
#
|
3
|
+
# - Removed unnecessary subdirectory.
|
4
|
+
# - Migrated repository to bzr.
|
5
|
+
# - Added more examples written to answer e-mails I received.
|
6
|
+
# - Fixed rake tests, verified that code passes them using Ruby 1.9.1.
|
7
|
+
#
|
8
|
+
# == Changes in 0.6.1
|
9
|
+
#
|
10
|
+
# - Misc bug fix, added #xml to get raw XML from inside feeds.
|
11
|
+
# - Made CDATA support work for any element, not just HTML encoded content.
|
12
|
+
# - Added feedburner support.
|
13
|
+
#
|
14
|
+
# == Changes in 0.6
|
15
|
+
#
|
16
|
+
# - Added some Google Calendar support.
|
17
|
+
# - Added Rake unit test task.
|
18
|
+
# - Fixed some unit tests.
|
19
|
+
# - Fixed handling of XML-style <foo/> closed elements in TagSoup.
|
20
|
+
#
|
1
21
|
# == Changes in 0.5.1
|
2
22
|
#
|
3
23
|
# - Fixes for handling of CDATA-encoded text.
|
24
|
+
# - Added example for RSS 2.0 with content module.
|
4
25
|
#
|
5
26
|
# == Changes in 0.5
|
6
27
|
#
|
data/examples/podcast.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Example of reading a Podcast
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'syndication/rss'
|
5
|
+
require 'open-uri'
|
6
|
+
|
7
|
+
url = 'http://www.npr.org/rss/podcast.php?id=510093'
|
8
|
+
|
9
|
+
parser = Syndication::RSS::Parser.new
|
10
|
+
|
11
|
+
xml = nil
|
12
|
+
|
13
|
+
open(url) { |http|
|
14
|
+
xml = http.read
|
15
|
+
}
|
16
|
+
|
17
|
+
feed = parser.parse(xml)
|
18
|
+
|
19
|
+
for i in feed.items
|
20
|
+
puts i.enclosure.url
|
21
|
+
puts i.enclosure.type
|
22
|
+
puts i.enclosure.length
|
23
|
+
puts
|
24
|
+
end
|
data/lib/syndication/atom.rb
CHANGED
@@ -212,6 +212,50 @@ module Syndication
|
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
+
# XML or text content
|
216
|
+
class Content < Data
|
217
|
+
attr_accessor :xml # The raw XML contents of the content element.
|
218
|
+
|
219
|
+
def initialize(parent, tag = nil, attrs = nil)
|
220
|
+
@xml = ""
|
221
|
+
super
|
222
|
+
end
|
223
|
+
|
224
|
+
def store(tag, obj)
|
225
|
+
#puts "[obj:#{tag}]"
|
226
|
+
end
|
227
|
+
|
228
|
+
def tag_start(tag, attrs = nil)
|
229
|
+
#puts "[tag:#{tag}]"
|
230
|
+
attrlist = ""
|
231
|
+
if attrs
|
232
|
+
for a in attrs.keys
|
233
|
+
if attrlist != ""
|
234
|
+
attrlist += " "
|
235
|
+
end
|
236
|
+
attrlist += "#{a}=\"#{attrs[a]}\""
|
237
|
+
end
|
238
|
+
@xml += "<#{tag} #{attrlist}>"
|
239
|
+
else
|
240
|
+
@xml += "<#{tag}>"
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def tag_end(endtag, current)
|
245
|
+
if @tag == endtag
|
246
|
+
return @parent
|
247
|
+
end
|
248
|
+
@xml += "</#{endtag}>"
|
249
|
+
return self
|
250
|
+
end
|
251
|
+
|
252
|
+
def text(s)
|
253
|
+
#puts "[text:#{s}]"
|
254
|
+
@xml += s
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
|
215
259
|
# A person, corporation or similar entity within an Atom feed.
|
216
260
|
class Person < Container
|
217
261
|
attr_accessor :name # Human-readable name of person.
|
@@ -354,8 +398,6 @@ module Syndication
|
|
354
398
|
attr_accessor :author
|
355
399
|
# Copyright or other rights information.
|
356
400
|
attr_accessor :rights
|
357
|
-
# Content of entry.
|
358
|
-
attr_accessor :content
|
359
401
|
# Globally unique ID of Entry.
|
360
402
|
attr_accessor :id
|
361
403
|
# Array of taxonomic categories for feed.
|
@@ -366,6 +408,8 @@ module Syndication
|
|
366
408
|
attr_reader :contributors
|
367
409
|
# Atom 0.3 creation date/time (obsolete)
|
368
410
|
attr_writer :created
|
411
|
+
# Content element as Atom::Content object
|
412
|
+
attr_reader :content
|
369
413
|
|
370
414
|
# For Atom 0.3 compatibility
|
371
415
|
def modified=(x)
|
@@ -382,6 +426,11 @@ module Syndication
|
|
382
426
|
@rights = x
|
383
427
|
end
|
384
428
|
|
429
|
+
# Add a Content object to the entry
|
430
|
+
def content=(obj)
|
431
|
+
@content = obj
|
432
|
+
end
|
433
|
+
|
385
434
|
# Add a Category object to the entry
|
386
435
|
def category=(obj)
|
387
436
|
if !defined? @categories
|
@@ -440,7 +489,8 @@ module Syndication
|
|
440
489
|
'summary' => Data,
|
441
490
|
'link' => Link,
|
442
491
|
'source' => Feed,
|
443
|
-
'category' => Category
|
492
|
+
'category' => Category,
|
493
|
+
'content' => Content
|
444
494
|
}
|
445
495
|
|
446
496
|
# Called when REXML finds a text fragment.
|
data/rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
|
|
5
5
|
require 'rake/testtask'
|
6
6
|
require 'rubygems'
|
7
7
|
|
8
|
-
PKG_VERSION = "0.6.
|
8
|
+
PKG_VERSION = "0.6.2"
|
9
9
|
|
10
10
|
desc "Create HTML documentation from RDOC"
|
11
11
|
Rake::RDocTask.new do |rd|
|
@@ -28,6 +28,15 @@ spec = Gem::Specification.new do |s|
|
|
28
28
|
s.email = "meta@pobox.com"
|
29
29
|
s.homepage = "http://www.pobox.com/~meta/"
|
30
30
|
s.platform = Gem::Platform::RUBY
|
31
|
+
s.description = <<-EOF
|
32
|
+
Syndication is a parser for RSS and Atom feeds. It uses either REXML or
|
33
|
+
its built-in "tag soup" parser for feed parsing. It supports extensions
|
34
|
+
to web feeds including Dublin Core metadata, Apple iTunes podcasts, and
|
35
|
+
extensions from Google and Feedburner. It is written in pure Ruby, and
|
36
|
+
designed to be easy to understand and extend. It is compatible with Ruby
|
37
|
+
1.8.x and 1.9.x.
|
38
|
+
EOF
|
39
|
+
s.rubyforge_project = 'syndication'
|
31
40
|
s.summary = "A web syndication parser for Atom and RSS with a uniform API"
|
32
41
|
candidates = Dir.glob("{bin,docs,lib,test,examples}/**/*")
|
33
42
|
candidates << "rakefile"
|
data/test/google.rb
CHANGED
@@ -84,7 +84,8 @@ EOF
|
|
84
84
|
f = Syndication::Atom::Parser.new.parse(xml)
|
85
85
|
baseline_assertions(f)
|
86
86
|
entry = f.entries.first
|
87
|
-
assert
|
87
|
+
assert entry.gd_when[0].to_s == "2006-03-30T22:00:00+00:00"
|
88
|
+
assert entry.gd_when[1].to_s == "2006-03-30T23:00:00+00:00"
|
88
89
|
end
|
89
90
|
|
90
91
|
end
|
data/test/rsstest.rb
CHANGED
@@ -259,7 +259,7 @@ class Tests < Test::Unit::TestCase
|
|
259
259
|
<?xml version="1.0"?>
|
260
260
|
<rdf:RDF
|
261
261
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
262
|
-
xmlns:
|
262
|
+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
263
263
|
xmlns="http://purl.org/rss/1.0/">
|
264
264
|
<channel rdf:about="http://www.otternet.com/">
|
265
265
|
<title>OtterNet</title>
|
@@ -271,13 +271,13 @@ class Tests < Test::Unit::TestCase
|
|
271
271
|
<title>The Sea Otter</title>
|
272
272
|
<link>http://www.otternet.com/species/seaotter.htm</link>
|
273
273
|
<description>The enticingly cute enhydra lontris.</description>
|
274
|
-
<
|
274
|
+
<content:encoded>The enticingly cute <i>enhydra lontris</i></content:encoded>
|
275
275
|
</item>
|
276
276
|
<item rdf:about="http://www.ruby-lang.org/">
|
277
277
|
<title>Ruby</title>
|
278
278
|
<link>http://www.ruby-lang.org/</link>
|
279
279
|
<description>There's this language called Ruby, you may have heard of it.</description>
|
280
|
-
<
|
280
|
+
<content:encoded>There's this language called <strong>Ruby</strong>, you <em>may</em> have heard of it.</content:encoded>
|
281
281
|
</item>
|
282
282
|
</rdf:RDF>
|
283
283
|
EOF
|
metadata
CHANGED
@@ -1,75 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.11
|
3
|
-
specification_version: 1
|
4
2
|
name: syndication
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.6.
|
7
|
-
date: 2006-07-17 00:00:00 -05:00
|
8
|
-
summary: A web syndication parser for Atom and RSS with a uniform API
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: meta@pobox.com
|
12
|
-
homepage: http://www.pobox.com/~meta/
|
13
|
-
rubyforge_project:
|
14
|
-
description:
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.6.2
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
6
|
authors:
|
29
7
|
- mathew
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-19 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: " Syndication is a parser for RSS and Atom feeds. It uses either REXML or\n its built-in \"tag soup\" parser for feed parsing. It supports extensions\n to web feeds including Dublin Core metadata, Apple iTunes podcasts, and \n extensions from Google and Feedburner. It is written in pure Ruby, and\n designed to be easy to understand and extend. It is compatible with Ruby \n 1.8.x and 1.9.x.\n"
|
17
|
+
email: meta@pobox.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- IMPLEMENTATION
|
25
|
+
- CHANGES
|
26
|
+
- DEVELOPER
|
30
27
|
files:
|
31
|
-
- lib/syndication
|
32
|
-
- lib/syndication/dublincore.rb
|
33
|
-
- lib/syndication/common.rb
|
34
28
|
- lib/syndication/podcast.rb
|
29
|
+
- lib/syndication/common.rb
|
30
|
+
- lib/syndication/rss.rb
|
31
|
+
- lib/syndication/google.rb
|
32
|
+
- lib/syndication/feedburner.rb
|
35
33
|
- lib/syndication/content.rb
|
34
|
+
- lib/syndication/atom.rb
|
35
|
+
- lib/syndication/dublincore.rb
|
36
36
|
- lib/syndication/tagsoup.rb
|
37
|
-
- lib/syndication/google.rb
|
38
|
-
- lib/syndication/rss.rb
|
39
37
|
- lib/syndication/syndication.rb
|
40
|
-
- lib/syndication/atom.rb
|
41
|
-
- lib/syndication/feedburner.rb
|
42
|
-
- test/feedburntest.rb
|
43
38
|
- test/tagsouptest.rb
|
39
|
+
- test/atomtest.rb
|
40
|
+
- test/feedburntest.rb
|
44
41
|
- test/google.rb
|
45
42
|
- test/rsstest.rb
|
46
|
-
-
|
47
|
-
- examples/apple.rb
|
48
|
-
- examples/yahoo.rb
|
43
|
+
- examples/podcast.rb
|
49
44
|
- examples/google.rb
|
45
|
+
- examples/yahoo.rb
|
46
|
+
- examples/apple.rb
|
50
47
|
- rakefile
|
51
48
|
- README
|
52
49
|
- IMPLEMENTATION
|
53
50
|
- CHANGES
|
54
51
|
- DEVELOPER
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://www.pobox.com/~meta/
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
version:
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
version:
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project: syndication
|
76
|
+
rubygems_version: 1.3.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: A web syndication parser for Atom and RSS with a uniform API
|
55
80
|
test_files:
|
56
81
|
- test/atomtest.rb
|
57
82
|
- test/rsstest.rb
|
58
83
|
- test/google.rb
|
59
84
|
- test/tagsouptest.rb
|
60
85
|
- test/feedburntest.rb
|
61
|
-
rdoc_options: []
|
62
|
-
|
63
|
-
extra_rdoc_files:
|
64
|
-
- README
|
65
|
-
- IMPLEMENTATION
|
66
|
-
- CHANGES
|
67
|
-
- DEVELOPER
|
68
|
-
executables: []
|
69
|
-
|
70
|
-
extensions: []
|
71
|
-
|
72
|
-
requirements: []
|
73
|
-
|
74
|
-
dependencies: []
|
75
|
-
|