ruby-feedparser 0.9.7 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e198cf8ee7423ff4edf5ba4367ac809ba1fe2a9d6361fcf53d12b984aa138228
4
- data.tar.gz: bbbd8c024c4e85c991ae2ceae4494e24d8b0865d2fe6a4df2646007e798e96ac
3
+ metadata.gz: aed5dc094f3df2dc51b9d2be81c4966b4b48de319e91df05f13c550ddcc384f4
4
+ data.tar.gz: 9ff2a1c9b591222b79e59e52b3db1980c9515a5df937884c9731420102e94281
5
5
  SHA512:
6
- metadata.gz: ac90154cfa40180e03d4b7b1d631186c6db1d70d79bdbb7f4edb4c54a66eddab3085e04480ed965b7c2e055770976873224b9d12f20be3d282817d6cd34245be
7
- data.tar.gz: 4f658dc07c1d692b44f9abd0d400449cb0e1aa3d1cda8c782b052e45b193a8ad462ce7e2d8f951b3d15b301764e651f3781da93cf07f28c1ea8438ab87a1c989
6
+ metadata.gz: '09cb81364cab19764aec4b8ddd5a6d107b021d89c5372643be893abdee45c0c4706cbf19a854a499862efae27da75ad70157d7442943de105ef2d6054aebc342'
7
+ data.tar.gz: e315743c486510b9b441c96973470b5d333581dadae93b0659c631da7c91424be1f419a98dc881c21995123bdd10ba97e3d7a005d4d503b8be6978851f8a94c0
data/Rakefile CHANGED
@@ -9,13 +9,13 @@ require_relative 'lib/feedparser/version.rb'
9
9
  PKG_NAME = 'ruby-feedparser'
10
10
  PKG_VERSION = FeedParser::VERSION
11
11
 
12
- PKG_FILES = [ 'ChangeLog.md', 'README', 'COPYING', 'LICENSE', 'setup.rb', 'Rakefile']
12
+ PKG_FILES = [ 'README', 'COPYING', 'LICENSE', 'setup.rb', 'Rakefile']
13
13
  Find.find('lib/', 'test/', 'tools/') do |f|
14
- if FileTest.directory?(f) and f =~ /\.svn/
15
- Find.prune
16
- else
17
- PKG_FILES << f
18
- end
14
+ if FileTest.directory?(f) and f =~ /\.svn/
15
+ Find.prune
16
+ else
17
+ PKG_FILES << f
18
+ end
19
19
  end
20
20
 
21
21
  PKG_FILES.reject! { |f| f =~ /^test\/(source|.*_output)\// }
@@ -23,8 +23,9 @@ PKG_FILES.reject! { |f| f =~ /^test\/(source|.*_output)\// }
23
23
  task :default => [:test]
24
24
 
25
25
  Rake::TestTask.new do |t|
26
- t.libs << "test"
27
- t.test_files = FileList['test/tc_*.rb']
26
+ t.libs << "test"
27
+ t.test_files = FileList['test/tc_*.rb']
28
+ t.verbose = true
28
29
  end
29
30
 
30
31
  Rake::RDocTask.new do |rd|
@@ -50,36 +51,36 @@ end
50
51
 
51
52
  task :doctoweb => [:rdoc] do |t|
52
53
  # copies the rdoc to the CVS repository for ruby-feedparser website
53
- # repository is in $CVSDIR (default: ~/dev/ruby-feedparser-web)
54
+ # repository is in $CVSDIR (default: ~/dev/ruby-feedparser-web)
54
55
  sh "tools/doctoweb.bash"
55
56
  end
56
57
 
57
58
  Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
58
- p.need_tar = true
59
+ p.need_tar = true
59
60
  p.need_zip = true
60
- p.package_files = PKG_FILES
61
+ p.package_files = PKG_FILES
61
62
  end
62
63
 
63
64
  # "Gem" part of the Rakefile
64
65
  begin
65
- spec = Gem::Specification.new do |s|
66
- s.platform = Gem::Platform::RUBY
67
- s.summary = "Ruby library to parse ATOM and RSS feeds"
68
- s.name = PKG_NAME
69
- s.version = PKG_VERSION
70
- s.requirements << 'none'
71
- s.require_path = 'lib'
72
- s.autorequire = 'feedparser'
73
- s.files = PKG_FILES
74
- s.description = "Ruby library to parse ATOM and RSS feeds"
75
- s.authors = ['Lucas Nussbaum']
76
- s.add_runtime_dependency 'magic'
77
- end
66
+ spec = Gem::Specification.new do |s|
67
+ s.platform = Gem::Platform::RUBY
68
+ s.summary = "Ruby library to parse ATOM and RSS feeds"
69
+ s.name = PKG_NAME
70
+ s.version = PKG_VERSION
71
+ s.requirements << 'none'
72
+ s.require_path = 'lib'
73
+ s.autorequire = 'feedparser'
74
+ s.files = PKG_FILES
75
+ s.description = "Ruby library to parse ATOM and RSS feeds"
76
+ s.authors = ['Lucas Nussbaum']
77
+ s.add_runtime_dependency 'magic'
78
+ end
78
79
 
79
- Gem::PackageTask.new(spec) do |pkg|
80
- pkg.need_zip = true
81
- pkg.need_tar = true
82
- end
80
+ Gem::PackageTask.new(spec) do |pkg|
81
+ pkg.need_zip = true
82
+ pkg.need_tar = true
83
+ end
83
84
  rescue LoadError
84
85
  puts "Will not generate gem."
85
86
  end
@@ -2,38 +2,78 @@ require 'feedparser'
2
2
  require 'feedparser/filesizes'
3
3
 
4
4
  module FeedParser
5
+ STYLESHEET = <<~EOF
6
+ <style type="text/css">
7
+ body {
8
+ margin: 2em auto;
9
+ max-width: 960px;
10
+ }
11
+
12
+ table.header {
13
+ margin-bottom: 1em;
14
+ }
15
+
16
+ table.header, table.metadata, table.attachments {
17
+ font-family: Helvetica, Verdana, sans-serif;
18
+ }
19
+
20
+ table.header, table.metadata, table.attachments, pre {
21
+ width: 100%;
22
+ padding: 0.5em;
23
+ background: #eeeeec;
24
+ border: 1px solid #babdb6;
25
+ }
26
+
27
+ table.header th, table.metadata th, table.attachments th {
28
+ text-align: right;
29
+ width: 50px;
30
+ }
31
+
32
+ blockquote {
33
+ font-style: italic;
34
+ color: #2e3436;
35
+ border-left: 2px solid #babdb6;
36
+ padding-left: 0.5em;
37
+ }
38
+
39
+ hr {
40
+ border: none;
41
+ border-top: 1px solid #babdb6;
42
+ margin: 1em auto
43
+ }
44
+ </style>
45
+ EOF
5
46
  class Feed
6
47
  def to_html(localtime = true)
7
48
  s = ''
8
- s += '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'
9
- s += "\n"
10
- s += "<html>\n"
49
+ s += "<!doctype html>\n"
50
+ s += "<html lang=en>\n"
11
51
  s += "<head>\n"
52
+ s += "<meta charset=\"utf-8\"/>\n"
12
53
  s += "<title>#{@title.escape_html}</title>\n"
13
- s += "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n"
54
+ s += FeedParser::STYLESHEET
14
55
  s += "</head>\n"
15
56
  s += "<body>\n"
16
57
 
17
58
  s += <<-EOF
18
- <table border="1" width="100%" cellpadding="0" cellspacing="0" borderspacing="0"><tr><td>
19
- <table width="100%" bgcolor="#EDEDED" cellpadding="4" cellspacing="2">
59
+ <table class="feed-header">
20
60
  EOF
21
61
  r = ""
22
62
  r += "<a href=\"#{@link}\">\n" if @link
23
63
  if @title
24
- r += "<b>#{@title.escape_html}</b>\n"
64
+ r += @title.escape_html
25
65
  elsif @link
26
- r += "<b>#{@link.escape_html}</b>\n"
66
+ r += @link.escape_html
27
67
  else
28
- r += "<b>Unnamed feed</b>\n"
68
+ r += "Unnamed feed"
29
69
  end
30
70
  r += "</a>\n" if @link
31
- headline = "<tr><td align=\"right\"><b>%s</b></td>\n<td width=\"100%%\">%s</td></tr>"
71
+ headline = "<tr><th>%s</th>\n<td>%s</td></tr>"
32
72
  s += (headline % ["Feed title:", r])
33
73
  s += (headline % ["Type:", @type])
34
74
  s += (headline % ["Encoding:", @encoding])
35
75
  s += (headline % ["Creator:", @creator.escape_html]) if @creator
36
- s += "</table></td></tr></table>\n"
76
+ s += "</table>\n"
37
77
 
38
78
  if @description and @description !~ /\A\s*</m
39
79
  s += "<br/>\n"
@@ -51,44 +91,47 @@ module FeedParser
51
91
 
52
92
  class FeedItem
53
93
  def to_html_with_headers(localtime = true)
54
- s = <<-EOF
55
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
56
- <html>
57
- <body>
58
- EOF
94
+ s = "<!doctype html>\n"
95
+ s += '<html lang="en">'
96
+ s += '<head>'
97
+ s += '<meta charset="utf-8"/>'
98
+ s += "<title>#{@title.escape_html}</title>\n"
99
+ s += FeedParser::STYLESHEET
100
+ s += '</head>'
101
+ s += '<body>'
59
102
  s += to_html(localtime)
60
- s += "\n</body>\n</html>"
103
+ s += "</body>"
104
+ s += "</html>"
61
105
  s
62
106
  end
63
107
 
64
108
  def to_html(localtime = true)
65
109
  s = <<-EOF
66
- <table border="1" width="100%" cellpadding="0" cellspacing="0" borderspacing="0"><tr><td>
67
- <table width="100%" bgcolor="#EDEDED" cellpadding="4" cellspacing="2">
110
+ <table class="header">
68
111
  EOF
69
112
  r = ""
70
113
  r += "<a href=\"#{@feed.link}\">\n" if @feed.link
71
114
  if @feed.title
72
- r += "<b>#{@feed.title.escape_html}</b>\n"
115
+ r += @feed.title.escape_html
73
116
  elsif @feed.link
74
- r += "<b>#{@feed.link.escape_html}</b>\n"
117
+ r += @feed.link.escape_html
75
118
  else
76
- r += "<b>Unnamed feed</b>\n"
119
+ r += "Unnamed feed"
77
120
  end
78
121
  r += "</a>\n" if @feed.link
79
- headline = "<tr><td align=\"right\"><b>%s</b></td>\n<td width=\"100%%\">%s</td></tr>"
122
+ headline = "<tr><th>%s</th>\n<td>%s</td></tr>"
80
123
  s += (headline % ["Feed:", r])
81
124
 
82
125
  r = ""
83
126
  r += "<a href=\"#{link}\">" if link
84
127
  if @title
85
- r += "<b>#{@title.escape_html}</b>\n"
128
+ r += @title.escape_html
86
129
  elsif link
87
- r += "<b>#{link.escape_html}</b>\n"
130
+ r += link.escape_html
88
131
  end
89
132
  r += "</a>\n" if link
90
133
  s += (headline % ["Item:", r])
91
- s += "</table></td></tr></table>\n"
134
+ s += "</table>\n"
92
135
  s += "\n"
93
136
  if @content and @content !~ /\A\s*</m
94
137
  s += "<br/>\n"
@@ -96,19 +139,18 @@ module FeedParser
96
139
  s += "#{@content}" if @content
97
140
  if @enclosures and @enclosures.length > 0
98
141
  s += <<-EOF
99
- <table border="1" width="100%" cellpadding="0" cellspacing="0" borderspacing="0"><tr><td>
100
- <table width="100%" bgcolor="#EDEDED" cellpadding="2" cellspacing="2">
142
+ <table class="attachments">
101
143
  EOF
102
- s += '<tr><td width="100%"><b>Files:</b></td></tr>'
144
+ s += '<tr><th>Files:</th></tr>'
103
145
  s += "\n"
104
146
  @enclosures.each do |e|
105
- s += "<tr><td>&nbsp;&nbsp;&nbsp;<a href=\"#{e[0]}\">#{e[0].split('/')[-1]}</a> (#{e[1].to_i.to_human_readable}, #{e[2]})</td></tr>\n"
147
+ s += "<tr><td><a href=\"#{e[0]}\">#{e[0].split('/')[-1]}</a> (#{e[1].to_i.to_human_readable}, #{e[2]})</td></tr>\n"
106
148
  end
107
- s += "</table></td></tr></table>\n"
149
+ s += "</table>\n"
108
150
  end
109
- s += "\n<hr width=\"100%\"/>\n"
110
- s += '<table width="100%" cellpadding="0" cellspacing="0">' + "\n"
111
- l = '<tr><td align="right"><font color="#ababab">%s</font>&nbsp;&nbsp;</td><td><font color="#ababab">%s</font></td></tr>' + "\n"
151
+ s += "\n<hr/>\n"
152
+ s += '<table class="metadata">' + "\n"
153
+ l = '<tr><th>%s</th><td>%s</td></tr>' + "\n"
112
154
  if @date
113
155
  if localtime
114
156
  s += l % [ 'Date:', @date.to_s ]
@@ -1,3 +1,3 @@
1
1
  module FeedParser
2
- VERSION = "0.9.7"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -0,0 +1,17 @@
1
+ require 'test/unit'
2
+ require 'feedparser'
3
+ require 'feedparser/html-output'
4
+
5
+
6
+ class ItemHTMLOutputTest < Test::Unit::TestCase
7
+ def test_html_with_headers
8
+ feed = FeedParser::Feed.new
9
+ item = FeedParser::FeedItem.new(nil, feed)
10
+ item.title = "Some great title"
11
+ item.content = "Lorem ipsum ..."
12
+ html = item.to_html_with_headers(false)
13
+ assert_match(/Some great title/, html)
14
+ assert_match(/Lorem ipsum .../, html)
15
+ assert_match(/<style type="text\/css">/, html)
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-feedparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Nussbaum
8
8
  autorequire: feedparser
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-06 00:00:00.000000000 Z
11
+ date: 2021-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: magic
@@ -31,7 +31,6 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - COPYING
34
- - ChangeLog.md
35
34
  - LICENSE
36
35
  - README
37
36
  - Rakefile
@@ -50,6 +49,7 @@ files:
50
49
  - test/tc_feeditem.rb
51
50
  - test/tc_html2text_parser.rb
52
51
  - test/tc_htmloutput.rb
52
+ - test/tc_item_htmloutput.rb
53
53
  - test/tc_parser.rb
54
54
  - test/tc_sgml_parser.rb
55
55
  - test/tc_textoutput.rb
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  requirements:
77
77
  - none
78
- rubygems_version: 3.2.5
78
+ rubygems_version: 3.2.27
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: Ruby library to parse ATOM and RSS feeds
data/ChangeLog.md DELETED
@@ -1,66 +0,0 @@
1
- # 0.9.4 (25/03/2016)
2
-
3
- Bug fixes:
4
-
5
- * feedparser: relax exception check for Magic errors; by Eric Wong
6
- * Always sort author list to avoid unecessary invalidation of caches; by Sébastien Dailly
7
-
8
- # 0.7 (27/07/2009)
9
-
10
- * Handled several creators per feed item
11
- * Fix bug with urls into tag attributes
12
- * Better item categories support
13
- * Reworked text output formatting
14
- * Ignore &shy;, as some blog software (dotclear2) misuse it.
15
-
16
- # 0.6 (23/07/2008)
17
-
18
- * Moved `to_human_readable` from class Fixnum to class Integer.
19
- * Correctly parse http://www.tbray.org/ongoing/ongoing.atom. Thanks
20
- to Janico Greifenberg for reporting this.
21
- * String#html2text now takes an additional wrapto parameter, allowing
22
- to wrap the text to a specified number of chars. Thanks to
23
- Maxime Petazzoni for the patch.
24
-
25
- # 0.5 (26/10/2007)
26
-
27
- * Fixed a bug with items with both non-escaped and escaped HTML. Reported,
28
- then patch provided by Gregory Hartman <gghartma@cs.cmu.edu>.
29
- * In Atom feeds, use the date provided in <updated>, and use it in
30
- preference to the one in <published> if both are available.
31
- Closes gna bug #8987.
32
- * "require 'feedparser'" now requires 'feedparser/text-output'. Fixes a bug
33
- reported by Sebastian Probst Eide.
34
- * Make checks for HTML tags case-insensitive. Broke Dilbert feeds!!
35
- Reported by Michal Čihař. Closes gna bug #10199.
36
-
37
- # 0.4 (01/05/2007)
38
-
39
- * Fixed a problem with html entities in the items' titles.
40
- * Date was not fetched for blogspot's atom feeds.
41
- Patch from Jason Ling <jason.ling@jeyel.com>.
42
- * Tests are now timezone-friendly. (closes GNA bug #8145).
43
- * Much nicer text output.
44
-
45
- # 0.3 (01/12/2006)
46
-
47
- * Much nicer HTML output
48
- * Fixed a problem with some feeds with broken enclosures (without url)
49
- * Now automatically fixes non-absolute `<a href>` or `<img src>`
50
- * Fixed small parser bugs
51
- * Now displays enclosures in the text and html outputs. Ready for
52
- podcasting :-)
53
- * Now escape title, creator, subject and category internally. This minor
54
- fix avoids &amp; stuff in the titles, for example.
55
-
56
- * 0.2 (05/06/2006)
57
-
58
- * Fixed a problem when parsing some ATOM feeds with <link> without type
59
- attribute. (Thanks Michal Cihar !)
60
- * FeedParser::Feed and FeedParser::FeedItem now have an xml attribute to
61
- get the related REXML::Element.
62
- * <enclosure/> support in RSS.
63
-
64
- # 0.1 (24/11/2005)
65
-
66
- * first public release.