feedparser 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: ec4aa58ed835c53c649f6289eebf236e25802c69
4
- data.tar.gz: e536aa9a2bd29ce9beb2f22765d40c5a027c920f
3
+ metadata.gz: 747fe0251bd3069a2c17b9ef047673386410b314
4
+ data.tar.gz: 2d5e9a169f84b90e3fd5b66c4b614e5b57adc82e
5
5
  SHA512:
6
- metadata.gz: 50fe366a7bd6d003f280a0c291d2569ad5122f78fbe7c48f988264ddd32244182ec9684bd8c4e26ea14215c143a7d6770704dee975743b98c7a10fdd34620c1e
7
- data.tar.gz: f6d0210aa31b7b9878a25d27c208efe47a0aca840a7253116ea04f3ec4a1da51da069a07d7741f4e645263a440e1b4245a8df677534a70d536d5f3b10348a72c
6
+ metadata.gz: 4042d15f3212979e796b7e979acf27f8da6d19fa8105580649d7bd8239f3f73620a0b99ec7254b11f6a77f3e7db10abe7b87126f10551265c6e8574ba1b62efa
7
+ data.tar.gz: 1b1545a13e22c2320020d32b3d4a7a817c6d22d692df9d5a72c70cb1cb6a383cc12d59f279f9ef5734034f17f9a8169561db8d263cfa2c56471dfdd964ecb80e
data/Manifest.txt CHANGED
@@ -6,7 +6,6 @@ lib/feedparser.rb
6
6
  lib/feedparser/builder/atom.rb
7
7
  lib/feedparser/builder/rss.rb
8
8
  lib/feedparser/feed.rb
9
- lib/feedparser/helper/atom_v03.rb
10
9
  lib/feedparser/item.rb
11
10
  lib/feedparser/parser.rb
12
11
  lib/feedparser/version.rb
@@ -16,5 +15,4 @@ test/feeds/quirksblog.atom.v03
16
15
  test/helper.rb
17
16
  test/test_atom.rb
18
17
  test/test_atom_from_file.rb
19
- test/test_atom_v03.rb
20
18
  test/test_rss.rb
data/README.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  feedparser gems - web feed parser and normalizer (RSS 2.0, Atom, etc.)
4
4
 
5
- * home :: [github.com/rubylibs/feedutils](https://github.com/rubylibs/feedutils)
6
- * bugs :: [github.com/rubylibs/feedutils/issues](https://github.com/rubylibs/feedutils/issues)
7
- * gem :: [rubygems.org/gems/feedutils](https://rubygems.org/gems/feedutils)
8
- * rdoc :: [rubydoc.info/gems/feedutils](http://rubydoc.info/gems/feedutils)
5
+ * home :: [github.com/feedreader/feed.parser](https://github.com/feedreader/feed.parser)
6
+ * bugs :: [github.com/feedreader/feed.parser/issues](https://github.com/feedreader/feed.parser/issues)
7
+ * gem :: [rubygems.org/gems/feedparser](https://rubygems.org/gems/feedparser)
8
+ * rdoc :: [rubydoc.info/gems/feedparser](http://rubydoc.info/gems/feedparser)
9
9
  * forum :: [groups.google.com/group/feedreader](http://groups.google.com/group/feedreader)
10
10
 
11
11
 
@@ -69,11 +69,11 @@ end
69
69
 
70
70
  ~~~
71
71
  require 'open-uri'
72
- require 'feedutils'
72
+ require 'feedparser'
73
73
 
74
74
  xml = open( 'http://openfootball.github.io/atom.xml' ).read
75
75
 
76
- feed = FeedUtils::Parser.parse( xml )
76
+ feed = FeedParser::Parser.parse( xml )
77
77
  pp feed
78
78
  ~~~
79
79
 
@@ -88,8 +88,21 @@ pp feed
88
88
  TBD
89
89
 
90
90
 
91
+
92
+ ## Install
93
+
94
+ Just install the gem:
95
+
96
+ $ gem install feedparser
97
+
98
+
91
99
  ## License
92
100
 
93
- The `feedutils` scripts are dedicated to the public domain.
101
+ The `feedparser` scripts are dedicated to the public domain.
94
102
  Use it as you please with no restrictions whatsoever.
95
103
 
104
+
105
+ ## Questions? Comments?
106
+
107
+ Send them along to the [Planet Pluto and Friends Forum/Mailing List](http://groups.google.com/group/feedreader).
108
+ Thanks!
data/lib/feedparser.rb CHANGED
@@ -15,8 +15,6 @@ require 'feedparser/version' # let it always go first
15
15
  require 'feedparser/builder/atom'
16
16
  require 'feedparser/builder/rss'
17
17
 
18
- require 'feedparser/helper/atom_v03'
19
-
20
18
  require 'feedparser/feed'
21
19
  require 'feedparser/item'
22
20
  require 'feedparser/parser'
@@ -14,20 +14,13 @@ class Parser
14
14
  ### Note: lets keep/use same API as RSS::Parser for now
15
15
  def initialize( xml )
16
16
  @xml = xml
17
- @atomv03helper = AtomV03Helper.new
18
17
  end
19
18
 
20
19
 
21
20
  def parse
22
21
  logger.debug "using stdlib rss/#{RSS::VERSION}"
23
22
 
24
- ## old (obsolete) Atom Version 0.3 - try to patch/upgrade to 1.0(-ish)
25
- if @atomv03helper.match?( @xml )
26
- logger.warn "*** atom v0.3 feed; try to patch/upgrade to 1.0(-ish); please use/find atom v1.0 feed"
27
- parser = RSS::Parser.new( @atomv03helper.convert( @xml ))
28
- else
29
- parser = RSS::Parser.new( @xml )
30
- end
23
+ parser = RSS::Parser.new( @xml )
31
24
 
32
25
  parser.do_validate = false
33
26
  parser.ignore_unknown_element = true
@@ -3,7 +3,7 @@
3
3
  module FeedParser
4
4
 
5
5
  MAJOR = 0
6
- MINOR = 1
6
+ MINOR = 2
7
7
  PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
data/test/helper.rb CHANGED
@@ -10,7 +10,7 @@ require 'fetcher'
10
10
 
11
11
  ## our own code
12
12
 
13
- require 'feedutils'
13
+ require 'feedparser'
14
14
 
15
15
 
16
16
  LogUtils::Logger.root.level = :debug
@@ -18,18 +18,18 @@ LogUtils::Logger.root.level = :debug
18
18
  def parse_feed( url )
19
19
  xml = Fetcher.read( url )
20
20
 
21
- FeedUtils::Parser.parse( xml )
21
+ FeedParser::Parser.parse( xml )
22
22
  end
23
23
 
24
24
 
25
25
 
26
26
  def read_feed_from_file( name )
27
- File.read( "#{FeedUtils.root}/test/feeds/#{name}")
27
+ File.read( "#{FeedParser.root}/test/feeds/#{name}")
28
28
  end
29
29
 
30
30
  def parse_feed_from_file( name )
31
31
  xml = read_feed_from_file( name )
32
32
 
33
- FeedUtils::Parser.parse( xml )
33
+ FeedParser::Parser.parse( xml )
34
34
  end
35
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -70,7 +70,6 @@ files:
70
70
  - lib/feedparser/builder/atom.rb
71
71
  - lib/feedparser/builder/rss.rb
72
72
  - lib/feedparser/feed.rb
73
- - lib/feedparser/helper/atom_v03.rb
74
73
  - lib/feedparser/item.rb
75
74
  - lib/feedparser/parser.rb
76
75
  - lib/feedparser/version.rb
@@ -80,7 +79,6 @@ files:
80
79
  - test/helper.rb
81
80
  - test/test_atom.rb
82
81
  - test/test_atom_from_file.rb
83
- - test/test_atom_v03.rb
84
82
  - test/test_rss.rb
85
83
  homepage: https://github.com/feedreader/feed.parser
86
84
  licenses:
@@ -109,7 +107,6 @@ signing_key:
109
107
  specification_version: 4
110
108
  summary: feedparser - web feed parser and normalizer (RSS 2.0, Atom, etc.)
111
109
  test_files:
112
- - test/test_atom_v03.rb
113
110
  - test/test_atom.rb
114
111
  - test/test_atom_from_file.rb
115
112
  - test/test_rss.rb
@@ -1,66 +0,0 @@
1
- # encoding: utf-8
2
-
3
-
4
- ###
5
- # hack:
6
- ## try to patch/convert old obsolete atom v0.3 to v1(-ish)
7
- ##
8
- ## in <feed> convert
9
- ## version="0.3" => removed/dropped! - use ns for version
10
- ## xmlns="http://purl.org/atom/ns#" => xmlns="http://www.w3.org/2005/Atom"
11
- ##
12
- ## <modified>2014-12-31T15:33:00Z</modified> => <updated>
13
- ## <issued>2014-12-31T13:02:07Z</issued> => <published>
14
- ##
15
- ##
16
- ## more changes:
17
- ## author url => author uri
18
- ## generator @url => generator @uri
19
- ## tagline => subtitle
20
- ## copyright => rights
21
- ## <created>2014-12-31T13:02:07Z</created> => removed/dropped!
22
- ##
23
- ## todo/fix: fix/convert content @type @mode - why?? why not??
24
- ##
25
- ## content @mode => removed/dropped!
26
- ## @type=text/plain @mode=escaped => @type=text
27
- ## @type=text/html @mode=escaped => @type=html
28
-
29
-
30
- ## see also
31
- ## - rakaz.nl/2005/07/moving-from-atom-03-to-10.html
32
-
33
-
34
- module FeedParser
35
-
36
- class AtomV03Helper
37
-
38
- include LogUtils::Logging
39
-
40
- def match?( xml )
41
- ## Note: =~ return nil on match; convert to boolean e.g. always return true|false
42
- (xml =~ /<feed\s+version="0\.3"/) != nil
43
- end
44
-
45
- def convert( xml )
46
- xml = xml.sub( /<feed[^>]+>/ ) do |m|
47
- ## Note: m passed in is just a string w/ the match (NOT a match data object!)
48
- ## puts "match (#{m.class.name}): "
49
- ## pp m
50
- el = m.sub( /version="0\.3"/, '' )
51
- el = el.sub( /xmlns="http:\/\/purl\.org\/atom\/ns#"/, 'xmlns="http://www.w3.org/2005/Atom"' )
52
- el
53
- end
54
-
55
- xml = xml.gsub( /<modified>/, '<updated>' )
56
- xml = xml.gsub( /<\/modified>/, '</updated>' )
57
-
58
- xml = xml.gsub( /<issued>/, '<published>' )
59
- xml = xml.gsub( /<\/issued>/, '</published>' )
60
- xml
61
- end
62
-
63
- end # class AtomV03Helper
64
-
65
- end # module FeedParser
66
-
@@ -1,41 +0,0 @@
1
- ###
2
- # to run use
3
- # ruby -I ./lib -I ./test test/test_atom_v03.rb
4
- # or better
5
- # rake test
6
-
7
- require 'helper'
8
-
9
-
10
- class TestAtomV03 < MiniTest::Test
11
-
12
- def test_match
13
- xmlv1 = read_feed_from_file( 'googlegroups.atom' )
14
- xmlv03 = read_feed_from_file( 'quirksblog.atom.v03' )
15
-
16
- atomv03helper = FeedUtils::AtomV03Helper.new
17
-
18
- assert_equal false, atomv03helper.match?( xmlv1 )
19
- assert_equal true, atomv03helper.match?( xmlv03 )
20
-
21
- xmlv03up = atomv03helper.convert( xmlv03 )
22
- assert_equal false, atomv03helper.match?( xmlv03up )
23
-
24
- pp xmlv03up[0..1000]
25
- end
26
-
27
- def test_parse
28
- feed = parse_feed_from_file( 'quirksblog.atom.v03' )
29
-
30
- pp feed.updated
31
- assert_equal '2014-12-31T15:33:00+00:00', feed.updated.to_s
32
-
33
- pp feed.items[0].updated
34
- assert_equal '2014-12-31T15:33:00+00:00', feed.items[0].updated.to_s
35
-
36
- pp feed.items[1].updated
37
- assert_equal '2014-11-26T12:11:25+00:00', feed.items[1].updated.to_s
38
- end
39
-
40
- end # class TestAtomV03
41
-