syndication 0.5.0 → 0.5.1

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/CHANGES CHANGED
@@ -1,6 +1,10 @@
1
+ # == Changes in 0.5.1
2
+ #
3
+ # - Fixes for handling of CDATA-encoded text.
4
+ #
1
5
  # == Changes in 0.5
2
6
  #
3
- # - Fixed problem with syndication/dublincore reported by Ura Takefumi
7
+ # - Fixed problem with syndication/dublincore reported by Ura Takefumi.
4
8
  #
5
9
  # - Added new TagSoup completely-non-validating parser, tests for same,
6
- # and option to use it for parsing feeds
10
+ # and option to use it for parsing feeds.
data/examples/apple.rb ADDED
@@ -0,0 +1,24 @@
1
+ # Example of using RSS 1.0 content module in RSS 2.0.
2
+ # (Naughty, but there you go.)
3
+
4
+ require 'rubygems'
5
+ require 'syndication/rss'
6
+ require 'syndication/content'
7
+ require 'open-uri'
8
+
9
+ url = 'http://docs.info.apple.com/rss/allproducts.rss'
10
+
11
+ parser = Syndication::RSS::Parser.new
12
+
13
+ xml = nil
14
+
15
+ open(url) { |http|
16
+ xml = http.read
17
+ }
18
+
19
+ feed = parser.parse(xml)
20
+
21
+ for i in feed.items
22
+ puts i.content_encoded
23
+ puts
24
+ end
@@ -3,7 +3,7 @@
3
3
  # Copyright � mathew <meta@pobox.com> 2005.
4
4
  # Licensed under the same terms as Ruby.
5
5
  #
6
- # $Header: /var/cvs/syndication/syndication/lib/syndication/common.rb,v 1.3 2005/10/17 15:05:21 meta Exp $
6
+ # $Header: /var/cvs/syndication/syndication/lib/syndication/common.rb,v 1.4 2005/10/23 22:51:17 meta Exp $
7
7
 
8
8
  require 'uri'
9
9
  require 'rexml/parsers/streamparser'
@@ -268,5 +268,15 @@ module Syndication
268
268
  @textstack.last << s
269
269
  end
270
270
  end
271
+
272
+ # Supposed to be called when REXML finds a CDATA-encoded piece of text.
273
+ def cdata(s)
274
+ # We re-encode, because (a) the API for RSS content module provides both
275
+ # encoded and decoded results to the user, and (b) REXML doesn't always
276
+ # seem to pass CDATA via this callback method.
277
+ if @textstack.last
278
+ @textstack.last << "<![CDATA[#{s}]]>"
279
+ end
280
+ end
271
281
  end
272
282
  end
@@ -1,7 +1,7 @@
1
1
  # Copyright � mathew <meta@pobox.com> 2005.
2
2
  # Licensed under the same terms as Ruby.
3
3
  #
4
- # $Header: /var/cvs/syndication/syndication/lib/syndication/content.rb,v 1.2 2005/10/17 15:05:21 meta Exp $
4
+ # $Header: /var/cvs/syndication/syndication/lib/syndication/content.rb,v 1.5 2005/11/11 22:01:46 meta Exp $
5
5
 
6
6
  module Syndication
7
7
 
@@ -20,11 +20,11 @@ module Syndication
20
20
  if !@content_encoded or @content_encoded == ''
21
21
  return @content_encoded
22
22
  end
23
- # CDATA is the easier
24
- if @content_encoded.match(/<!\[CDATA\[(.*)\]\]!>/)
23
+ # CDATA is the easier case
24
+ if @content_encoded.match(/<!\[CDATA\[(.*)\]\]>/m)
25
25
  return $1
26
26
  end
27
- # OK, must be entity-encoded
27
+ # Decode escaped entities
28
28
  x = @content_encoded.gsub(/&lt;/, '<')
29
29
  x.gsub!(/&gt;/, '>')
30
30
  return x.gsub(/&amp;/, '&')
@@ -36,6 +36,9 @@ module Syndication
36
36
  class Item
37
37
  include Content
38
38
  end
39
+ class Channel
40
+ include Content
41
+ end
39
42
  end
40
43
 
41
44
  end
data/rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/packagetask'
4
4
  require 'rake/gempackagetask'
5
5
  require 'rubygems'
6
6
 
7
- PKG_VERSION = "0.5.0"
7
+ PKG_VERSION = "0.5.1"
8
8
 
9
9
  desc "Create HTML documentation from RDOC"
10
10
  Rake::RDocTask.new do |rd|
data/test/rsstest.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # Copyright � mathew <meta@pobox.com> 2005.
2
2
  # Licensed under the same terms as Ruby.
3
3
  #
4
- # $Header: /var/cvs/syndication/syndication/test/rsstest.rb,v 1.2 2005/10/17 20:06:51 meta Exp $
4
+ # $Header: /var/cvs/syndication/syndication/test/rsstest.rb,v 1.4 2005/10/23 23:00:59 meta Exp $
5
5
 
6
6
  require 'syndication/rss'
7
7
  require 'test/unit'
@@ -290,9 +290,12 @@ class Tests < Test::Unit::TestCase
290
290
  i2 = il.last
291
291
  assert_not_nil(i1.content_encoded, "content_encoded nil, shouldn't be")
292
292
  assert_not_nil(i2.content_encoded, "content_encoded nil, shouldn't be")
293
+ assert(i1.content_encoded == 'The enticingly cute <i>enhydra lontris</i>')
293
294
  assert(i1.content_decoded == 'The enticingly cute <i>enhydra lontris</i>')
294
295
  assert(i2.content_decoded == "There's this language called <strong>Ruby</strong>, you <em>may</em> have heard of it.")
295
296
  c = f.channel
297
+ assert(c.content_encoded == '<![CDATA[<p><cite>OtterNet</cite> has <em>dozens</em> of pages of information about otters.</p>]]>')
298
+ assert(c.content_decoded == '<p><cite>OtterNet</cite> has <em>dozens</em> of pages of information about otters.</p>')
296
299
  assert_not_nil(c)
297
300
  assert_kind_of(Syndication::RSS::Channel, c)
298
301
  assert_not_nil(c.title)
metadata CHANGED
@@ -1,13 +1,13 @@
1
- --- !ruby/object:Gem::Specification
1
+ !ruby/object:Gem::Specification
2
2
  rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: syndication
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.0
7
- date: 2005-10-17 00:00:00 -05:00
6
+ version: 0.5.1
7
+ date: 2005-11-11 00:00:00 -06:00
8
8
  summary: A web syndication parser for Atom and RSS with a uniform API
9
9
  require_paths:
10
- - lib
10
+ - lib
11
11
  email: meta@pobox.com
12
12
  homepage: http://www.pobox.com/~meta/
13
13
  rubyforge_project:
@@ -18,46 +18,51 @@ bindir: bin
18
18
  has_rdoc: true
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
- -
22
- - ">"
23
- - !ruby/object:Gem::Version
24
- version: 0.0.0
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
25
24
  version:
26
25
  platform: ruby
27
26
  signing_key:
28
27
  cert_chain:
29
28
  authors:
30
- - mathew
29
+ - mathew
31
30
  files:
32
- - lib/syndication
33
- - lib/syndication/dublincore.rb
34
- - lib/syndication/common.rb
35
- - lib/syndication/podcast.rb
36
- - lib/syndication/content.rb
37
- - lib/syndication/tagsoup.rb
38
- - lib/syndication/rss.rb
39
- - lib/syndication/syndication.rb
40
- - lib/syndication/atom.rb
41
- - test/tagsouptest.rb
42
- - test/rsstest.rb
43
- - test/atomtest.rb
44
- - examples/yahoo.rb
45
- - rakefile
46
- - README
47
- - IMPLEMENTATION
48
- - CHANGES
49
- - DEVELOPER
31
+ - lib/syndication
32
+ - lib/syndication/dublincore.rb
33
+ - lib/syndication/common.rb
34
+ - lib/syndication/podcast.rb
35
+ - lib/syndication/content.rb
36
+ - lib/syndication/tagsoup.rb
37
+ - lib/syndication/rss.rb
38
+ - lib/syndication/syndication.rb
39
+ - lib/syndication/atom.rb
40
+ - test/tagsouptest.rb
41
+ - test/rsstest.rb
42
+ - test/atomtest.rb
43
+ - examples/apple.rb
44
+ - examples/yahoo.rb
45
+ - rakefile
46
+ - README
47
+ - IMPLEMENTATION
48
+ - CHANGES
49
+ - DEVELOPER
50
50
  test_files:
51
- - test/atomtest.rb
52
- - test/rsstest.rb
53
- - test/tagsouptest.rb
51
+ - test/atomtest.rb
52
+ - test/rsstest.rb
53
+ - test/tagsouptest.rb
54
54
  rdoc_options: []
55
+
55
56
  extra_rdoc_files:
56
- - README
57
- - IMPLEMENTATION
58
- - CHANGES
59
- - DEVELOPER
57
+ - README
58
+ - IMPLEMENTATION
59
+ - CHANGES
60
+ - DEVELOPER
60
61
  executables: []
62
+
61
63
  extensions: []
64
+
62
65
  requirements: []
63
- dependencies: []
66
+
67
+ dependencies: []
68
+