ruby-feedparser 0.9.7 → 0.11.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: '09a6faaf07007f6b349f2655b4e113d5e2603ebb511335860aa04c7b731710bd'
4
+ data.tar.gz: d8ae04113897d7fec060c875c2989e20d6d77e5c9b29a95403557054baa2242a
5
5
  SHA512:
6
- metadata.gz: ac90154cfa40180e03d4b7b1d631186c6db1d70d79bdbb7f4edb4c54a66eddab3085e04480ed965b7c2e055770976873224b9d12f20be3d282817d6cd34245be
7
- data.tar.gz: 4f658dc07c1d692b44f9abd0d400449cb0e1aa3d1cda8c782b052e45b193a8ad462ce7e2d8f951b3d15b301764e651f3781da93cf07f28c1ea8438ab87a1c989
6
+ metadata.gz: 20d3c60812c4a56ef287e9fbf797e283451f6f045fdf368cc9d8e8689f88251ea9e26e53ca91666a46e73f073bd6b05cc1e7c21a6adc89e67d278b0a1176d097
7
+ data.tar.gz: d0375bf45d0dfd6fa47408b9135ed6e30af4d031e06085ade50b3c2c85060e4c3cd9c0cefe6c7292cb516ed73e0e11f8001786097fc28fc14f6358f7c465f92d
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,88 @@ 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: 1em auto;
9
+ padding: 0px 1em;
10
+ max-width: 960px;
11
+ }
12
+
13
+ img {
14
+ max-width: 100%;
15
+ height: auto;
16
+ }
17
+
18
+ figure {
19
+ margin: 0px;
20
+ }
21
+
22
+ table.header {
23
+ margin-bottom: 1em;
24
+ }
25
+
26
+ table.header, table.metadata, table.attachments {
27
+ font-family: Helvetica, Verdana, sans-serif;
28
+ }
29
+
30
+ table.header, table.metadata, table.attachments, pre {
31
+ width: 100%;
32
+ padding: 0.5em;
33
+ background: #eeeeec;
34
+ border: 1px solid #babdb6;
35
+ }
36
+
37
+ table.header th, table.metadata th, table.attachments th {
38
+ text-align: right;
39
+ width: 50px;
40
+ }
41
+
42
+ blockquote {
43
+ font-style: italic;
44
+ color: #2e3436;
45
+ border-left: 2px solid #babdb6;
46
+ padding-left: 0.5em;
47
+ }
48
+
49
+ hr {
50
+ border: none;
51
+ border-top: 1px solid #babdb6;
52
+ margin: 1em auto
53
+ }
54
+ </style>
55
+ EOF
5
56
  class Feed
6
57
  def to_html(localtime = true)
7
58
  s = ''
8
- s += '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'
9
- s += "\n"
10
- s += "<html>\n"
59
+ s += "<!doctype html>\n"
60
+ s += "<html lang=en>\n"
11
61
  s += "<head>\n"
62
+ s += "<meta charset=\"utf-8\"/>\n"
12
63
  s += "<title>#{@title.escape_html}</title>\n"
13
- s += "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n"
64
+ s += FeedParser::STYLESHEET
14
65
  s += "</head>\n"
15
66
  s += "<body>\n"
16
67
 
17
68
  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">
69
+ <table class="feed-header">
20
70
  EOF
21
71
  r = ""
22
72
  r += "<a href=\"#{@link}\">\n" if @link
23
73
  if @title
24
- r += "<b>#{@title.escape_html}</b>\n"
74
+ r += @title.escape_html
25
75
  elsif @link
26
- r += "<b>#{@link.escape_html}</b>\n"
76
+ r += @link.escape_html
27
77
  else
28
- r += "<b>Unnamed feed</b>\n"
78
+ r += "Unnamed feed"
29
79
  end
30
80
  r += "</a>\n" if @link
31
- headline = "<tr><td align=\"right\"><b>%s</b></td>\n<td width=\"100%%\">%s</td></tr>"
81
+ headline = "<tr><th>%s</th>\n<td>%s</td></tr>"
32
82
  s += (headline % ["Feed title:", r])
33
83
  s += (headline % ["Type:", @type])
34
84
  s += (headline % ["Encoding:", @encoding])
35
85
  s += (headline % ["Creator:", @creator.escape_html]) if @creator
36
- s += "</table></td></tr></table>\n"
86
+ s += "</table>\n"
37
87
 
38
88
  if @description and @description !~ /\A\s*</m
39
89
  s += "<br/>\n"
@@ -51,44 +101,47 @@ module FeedParser
51
101
 
52
102
  class FeedItem
53
103
  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
104
+ s = "<!doctype html>\n"
105
+ s += '<html lang="en">'
106
+ s += '<head>'
107
+ s += '<meta charset="utf-8"/>'
108
+ s += "<title>#{@title.escape_html}</title>\n"
109
+ s += FeedParser::STYLESHEET
110
+ s += '</head>'
111
+ s += '<body>'
59
112
  s += to_html(localtime)
60
- s += "\n</body>\n</html>"
113
+ s += "</body>"
114
+ s += "</html>"
61
115
  s
62
116
  end
63
117
 
64
118
  def to_html(localtime = true)
65
119
  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">
120
+ <table class="header">
68
121
  EOF
69
122
  r = ""
70
123
  r += "<a href=\"#{@feed.link}\">\n" if @feed.link
71
124
  if @feed.title
72
- r += "<b>#{@feed.title.escape_html}</b>\n"
125
+ r += @feed.title.escape_html
73
126
  elsif @feed.link
74
- r += "<b>#{@feed.link.escape_html}</b>\n"
127
+ r += @feed.link.escape_html
75
128
  else
76
- r += "<b>Unnamed feed</b>\n"
129
+ r += "Unnamed feed"
77
130
  end
78
131
  r += "</a>\n" if @feed.link
79
- headline = "<tr><td align=\"right\"><b>%s</b></td>\n<td width=\"100%%\">%s</td></tr>"
132
+ headline = "<tr><th>%s</th>\n<td>%s</td></tr>"
80
133
  s += (headline % ["Feed:", r])
81
134
 
82
135
  r = ""
83
136
  r += "<a href=\"#{link}\">" if link
84
137
  if @title
85
- r += "<b>#{@title.escape_html}</b>\n"
138
+ r += @title.escape_html
86
139
  elsif link
87
- r += "<b>#{link.escape_html}</b>\n"
140
+ r += link.escape_html
88
141
  end
89
142
  r += "</a>\n" if link
90
143
  s += (headline % ["Item:", r])
91
- s += "</table></td></tr></table>\n"
144
+ s += "</table>\n"
92
145
  s += "\n"
93
146
  if @content and @content !~ /\A\s*</m
94
147
  s += "<br/>\n"
@@ -96,19 +149,18 @@ module FeedParser
96
149
  s += "#{@content}" if @content
97
150
  if @enclosures and @enclosures.length > 0
98
151
  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">
152
+ <table class="attachments">
101
153
  EOF
102
- s += '<tr><td width="100%"><b>Files:</b></td></tr>'
154
+ s += '<tr><th>Files:</th></tr>'
103
155
  s += "\n"
104
156
  @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"
157
+ 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
158
  end
107
- s += "</table></td></tr></table>\n"
159
+ s += "</table>\n"
108
160
  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"
161
+ s += "\n<hr/>\n"
162
+ s += '<table class="metadata">' + "\n"
163
+ l = '<tr><th>%s</th><td>%s</td></tr>' + "\n"
112
164
  if @date
113
165
  if localtime
114
166
  s += l % [ 'Date:', @date.to_s ]
@@ -1,3 +1,3 @@
1
1
  module FeedParser
2
- VERSION = "0.9.7"
2
+ VERSION = "0.11.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.11.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: 2023-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: magic
@@ -25,13 +25,12 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: Ruby library to parse ATOM and RSS feeds
28
- email:
28
+ email:
29
29
  executables: []
30
30
  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,16 +49,17 @@ 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
56
56
  - test/tc_textwrappedoutput.rb
57
57
  - test/ts_feedparser.rb
58
58
  - tools/doctoweb.bash
59
- homepage:
59
+ homepage:
60
60
  licenses: []
61
61
  metadata: {}
62
- post_install_message:
62
+ post_install_message:
63
63
  rdoc_options: []
64
64
  require_paths:
65
65
  - lib
@@ -75,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  requirements:
77
77
  - none
78
- rubygems_version: 3.2.5
79
- signing_key:
78
+ rubygems_version: 3.3.15
79
+ signing_key:
80
80
  specification_version: 4
81
81
  summary: Ruby library to parse ATOM and RSS feeds
82
82
  test_files: []
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.