feedparser 2.1.1 → 2.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98fe29b4b37ab3f10f52e1eb8b928807cf911f6e
4
- data.tar.gz: ca67cc643a6c0219efe13dbf4bd99ccd76c359a0
3
+ metadata.gz: fdd14a8952605dcb40547f1675bc234fb16af21f
4
+ data.tar.gz: de37586ae452d80ebc2042ebfda9c29dabfa2aa0
5
5
  SHA512:
6
- metadata.gz: e5fef03a0a3680af0d825c4169af41dbd16ebee7b68d8b34ef2548d12b7105d6748dc62b8e9fe3bf5be0513dbfe5530359c65b73ab0f8f83848364c8657587ed
7
- data.tar.gz: 94a342686dc2b21e6fe9e0d963b08ab3d7c0701f4981e354d698818106e77eb1b7dfc46bf03164140aa03a0221af8ee6a6c31c846419c36e95a4dd96bce9c35b
6
+ metadata.gz: b79665575a1596f1c644d48307e5660a52cf6ac1b0124bf6bc5df4ce66123cabada4dacebcf9240665dc2e0d5e2e52d14d764e9183bcf5bf25d9766385996b73
7
+ data.tar.gz: 8cb7a605620667f035a635826c29690835a4b38fa50e932d6b2fa6ac054d34f9c37a10585b5d9fcf0438836e3462081f85bb24a67ca2c1baa04fa4659cbd59eb
File without changes
@@ -1,4 +1,4 @@
1
- HISTORY.md
1
+ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ Hoe.spec 'feedparser' do
15
15
 
16
16
  # switch extension to .markdown for gihub formatting
17
17
  self.readme_file = 'README.md'
18
- self.history_file = 'HISTORY.md'
18
+ self.history_file = 'CHANGELOG.md'
19
19
 
20
20
  self.extra_deps = [
21
21
  ['logutils', '>=0.6.1'],
@@ -27,7 +27,7 @@ Hoe.spec 'feedparser' do
27
27
  self.licenses = ['Public Domain']
28
28
 
29
29
  self.spec_extras = {
30
- required_ruby_version: '>= 2.3'
30
+ required_ruby_version: '>= 2.2.2'
31
31
  }
32
32
 
33
33
  end
@@ -16,38 +16,53 @@ class Parser
16
16
  ### Note: lets keep/use same API as RSS::Parser for now
17
17
  def initialize( text )
18
18
  @text = text
19
+ @head = @text[0..100].strip # note: remove leading spaces if present
19
20
  end
20
21
 
21
22
 
22
23
 
23
- def parse
24
- head = @text[0..100].strip # note: remove leading spaces if present
25
-
26
- jsonfeed_version_regex = %r{"version":\s*"https://jsonfeed.org/version/1"}
24
+ #### note:
25
+ # make format checks callable from outside (that is, use builtin helper methods)
27
26
 
27
+ def is_xml?
28
28
  ## check if starts with knownn xml prologs
29
- if head.start_with?( '<?xml' ) ||
30
- head.start_with?( '<feed/' ) ||
31
- head.start_with?( '<rss/' )
29
+ @head.start_with?( '<?xml' ) ||
30
+ @head.start_with?( '<feed' ) ||
31
+ @head.start_with?( '<rss' )
32
+ end
33
+ alias_method :xml?, :is_xml?
34
+
35
+ JSONFEED_VERSION_RE = %r{"version":\s*"https://jsonfeed.org/version/1"}
36
+ def is_json?
32
37
  ## check if starts with { for json object/hash
33
38
  ## or if includes jsonfeed prolog
39
+ @head.start_with?( '{' ) ||
40
+ @head =~ JSONFEED_VERSION_RE
41
+ end
42
+ alias_method :json?, :is_json?
43
+
44
+ def is_microformats?
45
+ # for now check for microformats v2 (e.g. h-entry, h-feed)
46
+ # check for v1 too - why? why not? (e.g. hentry, hatom ??)
47
+ @text.include?( 'h-entry' ) ||
48
+ @text.include?( 'h-feed' )
49
+ end
50
+ alias_method :microformats?, :is_microformats?
51
+
52
+
53
+
54
+ def parse
55
+ if is_xml?
34
56
  parse_xml
35
- elsif head.start_with?( '{' ) ||
36
- head =~ jsonfeed_version_regex
57
+ elsif is_json?
37
58
  parse_json
38
59
  ## note: reading/parsing microformat is for now optional
39
60
  ## microformats gem requires nokogiri
40
61
  ## nokogiri (uses libxml c-extensions) makes it hard to install (sometime)
41
62
  ## thus, if you want to use it, please opt-in to keep the install "light"
42
- #
43
- # for now check for microformats v2 (e.g. h-entry, h-feed)
44
- # check for v1 too - why? why not? (e.g. hentry, hatom ??)
45
- elsif defined?( Microformats ) &&
46
- (@text.include?( 'h-entry' ) ||
47
- @text.include?( 'h-feed' )
48
- )
49
- parse_microformats
50
- else ## assume xml for now
63
+ elsif defined?( Microformats ) && is_microformats?
64
+ parse_microformats
65
+ else ## fallback - assume xml for now
51
66
  parse_xml
52
67
  end
53
68
  end # method parse
@@ -4,7 +4,7 @@ module FeedParser
4
4
 
5
5
  MAJOR = 2
6
6
  MINOR = 1
7
- PATCH = 1
7
+ PATCH = 2
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -4,6 +4,8 @@
4
4
  # or better
5
5
  # rake test
6
6
 
7
+
8
+
7
9
  require 'helper'
8
10
 
9
11
  class TestAtomLive < MiniTest::Test
@@ -11,16 +13,18 @@ class TestAtomLive < MiniTest::Test
11
13
  def test_rubyonrails
12
14
  feed = fetch_and_parse_feed( 'http://weblog.rubyonrails.org/feed/atom.xml' )
13
15
 
14
- assert_equal 'atom', feed.format
15
- assert_equal 'http://weblog.rubyonrails.org/', feed.url
16
+ assert_equal 'atom', feed.format
17
+ assert_equal 'https://weblog.rubyonrails.org/', feed.url
18
+ ## note was (2020/1): 'http://weblog.rubyonrails.org/', feed.url
16
19
  end
17
20
 
18
21
 
19
22
  def test_railstutorial
20
23
  feed = fetch_and_parse_feed( 'http://feeds.feedburner.com/railstutorial?format=xml' )
21
24
 
22
- assert_equal 'atom', feed.format
23
- assert_equal 'http://news.learnenough.com/', feed.url
25
+ assert_equal 'atom', feed.format
26
+ assert_equal 'https://news.learnenough.com/', feed.url
27
+ ## note was (2020/1): assert_equal 'http://news.learnenough.com/', feed.url
24
28
  ## note was (2017/5): assert_equal 'http://news.railstutorial.org/', feed.url
25
29
  end
26
30
 
@@ -38,13 +42,19 @@ class TestAtomLive < MiniTest::Test
38
42
 
39
43
 
40
44
  def test_headius
41
- feed = fetch_and_parse_feed( 'http://blog.headius.com/feeds/posts/default' )
45
+ feed = fetch_and_parse_feed( 'http://blog.headius.com/feed.xml' )
46
+ ## note was (2020/1): 'http://blog.headius.com/feeds/posts/default'
42
47
 
43
48
  assert_equal 'atom', feed.format
44
- assert_equal 'Blogger', feed.generator.name
45
- assert_equal 'Headius', feed.title
46
- assert_equal 'Helping the JVM Into the 21st Century', feed.summary # aka subtitle in atom
47
- assert_equal 'http://blog.headius.com/', feed.url
49
+ assert_equal 'Jekyll', feed.generator.name
50
+ ## note was (2020/1): 'Blogger'
51
+
52
+ assert_equal 'Charles Oliver Nutter', feed.title
53
+ ## note was (2020/1): 'Headius', feed.title
54
+ assert_equal 'Java, Ruby, and JVM guy trying to make sense of it all', feed.summary # aka subtitle in atom
55
+ ## note was (2020/1): 'Helping the JVM Into the 21st Century', feed.title
56
+ assert_equal 'https://headius.github.io/', feed.url
57
+ ## note was (2020/1): 'http://blog.headius.com/'
48
58
  end
49
59
 
50
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-05 00:00:00.000000000 Z
11
+ date: 2020-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logutils
@@ -72,11 +72,11 @@ email: wwwmake@googlegroups.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files:
75
- - HISTORY.md
75
+ - CHANGELOG.md
76
76
  - Manifest.txt
77
77
  - README.md
78
78
  files:
79
- - HISTORY.md
79
+ - CHANGELOG.md
80
80
  - Manifest.txt
81
81
  - README.md
82
82
  - Rakefile
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: '2.3'
116
+ version: 2.2.2
117
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - ">="