feedutils 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fc27ca90a5876fa6ae3ca6abaad1dba94d95a19b
4
+ data.tar.gz: 704c4187ca9e9b903fe99ecee3f45c7e5d0150cc
5
+ SHA512:
6
+ metadata.gz: 19f0245d4dd3e01403ef6d822ddca5022178b6718201af402fcdd9f7963252acea856cdc45b3e28103f1e5efc92f9be5c2ee4abd78d2896d85af2f7929c96584
7
+ data.tar.gz: 8b684e82f2ba8473dc80ec5f4a02a0c10df15e0342aa4b182aaba6a55746dc8fd343d620e864a718056e1c6df4253c1e7d10e8e3d169d3551711e9c7a31c706f
File without changes
data/Manifest.txt CHANGED
@@ -1,4 +1,4 @@
1
- History.md
1
+ HISTORY.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
@@ -9,6 +9,9 @@ lib/feedutils/feed.rb
9
9
  lib/feedutils/item.rb
10
10
  lib/feedutils/parser.rb
11
11
  lib/feedutils/version.rb
12
+ test/feeds/googlegroups.atom
13
+ test/feeds/googlegroups2.atom
12
14
  test/helper.rb
13
15
  test/test_atom.rb
16
+ test/test_atom_from_file.rb
14
17
  test/test_rss.rb
data/README.md CHANGED
@@ -26,3 +26,4 @@ TBD
26
26
 
27
27
  The `feedutils` scripts are dedicated to the public domain.
28
28
  Use it as you please with no restrictions whatsoever.
29
+
data/Rakefile CHANGED
@@ -15,19 +15,18 @@ Hoe.spec 'feedutils' 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 = 'HISTORY.md'
19
19
 
20
20
  self.extra_deps = [
21
- ['logutils', '>= 0.5']
21
+ ['logutils', '>= 0.6.1']
22
22
  ]
23
-
23
+
24
24
  ### todo: add fetcher dep for testing (e.g. development only)
25
25
 
26
26
  self.licenses = ['Public Domain']
27
27
 
28
28
  self.spec_extras = {
29
- :required_ruby_version => '>= 1.9.2'
29
+ required_ruby_version: '>= 1.9.2'
30
30
  }
31
31
 
32
-
33
- end
32
+ end
data/lib/feedutils.rb CHANGED
@@ -20,20 +20,6 @@ require 'feedutils/item'
20
20
  require 'feedutils/parser'
21
21
 
22
22
 
23
- module FeedUtils
24
-
25
- def self.banner
26
- "feedutils/#{VERSION} (with stdlib rss/#{RSS::VERSION}) on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
27
- end
28
-
29
- =begin
30
- def self.root
31
- "#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
32
- end
33
- =end
34
-
35
- end # module FeedUtils
36
-
37
-
38
- puts FeedUtils.banner # say hello
39
23
 
24
+ # say hello
25
+ puts FeedUtils.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)
@@ -27,6 +27,34 @@ class AtomFeedBuilder
27
27
  feed.title = atom_feed.title.content
28
28
  logger.debug " atom | title.content >#{atom_feed.title.content}< : #{atom_feed.title.content.class.name}"
29
29
 
30
+
31
+ ## note: for now assume id is feed (html)url
32
+ ## use url only if starts_with http
33
+ ## might not be link e.g blogger uses for ids =>
34
+ ## <id>tag:blogger.com,1999:blog-4704664917418794835</id>
35
+ ##
36
+ ## Note: remove (strip) leading and trailing spaces and newlines
37
+
38
+ if atom_feed.id.content.strip.start_with?( 'http' )
39
+ feed.url = atom_feed.id.content.strip
40
+ else
41
+ feed.url = nil
42
+ end
43
+
44
+ logger.debug " atom | id.content >#{atom_feed.id.content}< : #{atom_feed.id.content.class.name}"
45
+
46
+ ## note: use links (plural to allow multiple links e.g. self,alternate,etc.)
47
+ atom_feed.links.each_with_index do |link,i|
48
+ logger.debug " atom | link[#{i+1}] link rel=>#{link.rel}< : #{link.rel.class.name} type=#{link.type} href=#{link.href}"
49
+
50
+ ## for now assume alternate is link or no rel specified (assumes alterante)
51
+ ## note: only set if feed.url is NOT already set (via <id> for example)
52
+ if feed.url.nil? && (link.rel == 'alternate' || link.rel.nil?)
53
+ feed.url = link.href
54
+ end
55
+ end
56
+
57
+
30
58
  if atom_feed.updated
31
59
  # NOTE: empty updated.content e.g. used by google groups feed
32
60
  # will return nil : NilClass
@@ -38,7 +66,8 @@ class AtomFeedBuilder
38
66
  end
39
67
 
40
68
  if atom_feed.generator
41
- feed.generator = atom_feed.generator.content
69
+ ## Note: remove (strip) leading and trailing spaces and newlines
70
+ feed.generator = atom_feed.generator.content.strip
42
71
  logger.debug " atom | generator.content >#{atom_feed.generator.content}< : #{atom_feed.generator.content.class.name}"
43
72
 
44
73
  # pp atom_feed.generator
@@ -1,4 +1,24 @@
1
+ # encoding: utf-8
1
2
 
2
3
  module FeedUtils
3
- VERSION = '0.4.0'
4
- end
4
+
5
+ MAJOR = 0
6
+ MINOR = 5
7
+ PATCH = 0
8
+ VERSION = [MAJOR,MINOR,PATCH].join('.')
9
+
10
+ def self.version
11
+ VERSION
12
+ end
13
+
14
+
15
+ def self.banner
16
+ "feedutils/#{VERSION} (with stdlib rss/#{RSS::VERSION}) on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
17
+ end
18
+
19
+ def self.root
20
+ "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
21
+ end
22
+
23
+ end # module FeedUtils
24
+
@@ -0,0 +1,18 @@
1
+ <feed xmlns="http://www.w3.org/2005/Atom">
2
+ <id>https://groups.google.com/d/forum/beerdb</id>
3
+ <title type="text">Open Beer &amp; Brewery Database (beer.db)</title>
4
+ <subtitle>Free open public domain beer database &amp;amp; schema (beer.db) for use in any (programming) language (e.g. uses plain text fixtures/data sets). Questions? Comments?</subtitle>
5
+ <link rel="self" href="https://groups.google.com/forum/feed/beerdb/topics/atom_v1_0.xml" title="beerdb feed"></link>
6
+ <updated></updated>
7
+ <generator>Google Groups</generator>
8
+ <entry>
9
+ <author>
10
+ <name>Joe Sixpack</name>
11
+ </author>
12
+ <updated>2014-12-17T11:54:43Z</updated>
13
+ <id>https://groups.google.com/d/topic/beerdb/KpQOUDYJ3J8</id>
14
+ <link href="https://groups.google.com/d/topic/beerdb/KpQOUDYJ3J8"></link>
15
+ <title type="text">Planet Beer (Austria, Belgium) - Feeds Incl. Craft Fest Wien, Beer-A-Day, proBier n Friends</title>
16
+ <summary type="html">Hello, I&apos;ve started putting together a planet site for beer, that is, Planet Beer [1]. The first feed lists include: - Austria [2] - Belgium [3] You&apos;re welcome and invited to suggest new countries and feeds. Cheers. Prost. [1] http://planetbeer.herokuapp.com [2] http://github.com/openbeer/planet/blob/master/</summary>
17
+ </entry>
18
+ </feed>
@@ -0,0 +1,20 @@
1
+ <feed xmlns="http://www.w3.org/2005/Atom">
2
+ <id>https://groups.google.com/d/forum/beerdb</id>
3
+ <title type="text">Open Beer &amp; Brewery Database (beer.db)</title>
4
+ <subtitle>Free open public domain beer database &amp;amp; schema (beer.db) for use in any (programming) language (e.g. uses plain text fixtures/data sets). Questions? Comments?</subtitle>
5
+ <link rel="self" href="https://groups.google.com/forum/feed/beerdb/topics/atom_v1_0.xml" title="beerdb feed"></link>
6
+ <updated></updated>
7
+ <generator>
8
+ Google Groups (w/ leading n trailing newlines stripped)
9
+ </generator>
10
+ <entry>
11
+ <author>
12
+ <name>Joe Sixpack</name>
13
+ </author>
14
+ <updated>2014-12-17T11:54:43Z</updated>
15
+ <id>https://groups.google.com/d/topic/beerdb/KpQOUDYJ3J8</id>
16
+ <link href="https://groups.google.com/d/topic/beerdb/KpQOUDYJ3J8"></link>
17
+ <title type="text">Planet Beer (Austria, Belgium) - Feeds Incl. Craft Fest Wien, Beer-A-Day, proBier n Friends</title>
18
+ <summary type="html">Hello, I&apos;ve started putting together a planet site for beer, that is, Planet Beer [1]. The first feed lists include: - Austria [2] - Belgium [3] You&apos;re welcome and invited to suggest new countries and feeds. Cheers. Prost. [1] http://planetbeer.herokuapp.com [2] http://github.com/openbeer/planet/blob/master/</summary>
19
+ </entry>
20
+ </feed>
data/test/helper.rb CHANGED
@@ -3,11 +3,8 @@
3
3
 
4
4
  ## minitest setup
5
5
 
6
- # require 'minitest/unit'
7
6
  require 'minitest/autorun'
8
7
 
9
- # include MiniTest::Unit # lets us use TestCase instead of MiniTest::Unit::TestCase
10
-
11
8
  require 'logutils'
12
9
  require 'fetcher'
13
10
 
@@ -18,8 +15,16 @@ require 'feedutils'
18
15
 
19
16
  LogUtils::Logger.root.level = :debug
20
17
 
21
- def parse_feed( feed_url )
22
- xml = Fetcher.read( feed_url )
18
+ def parse_feed( url )
19
+ xml = Fetcher.read( url )
23
20
 
24
21
  FeedUtils::Parser.parse( xml )
25
22
  end
23
+
24
+
25
+ def parse_feed_from_file( name )
26
+ xml = File.read( "#{FeedUtils.root}/test/feeds/#{name}")
27
+
28
+ FeedUtils::Parser.parse( xml )
29
+ end
30
+
data/test/test_atom.rb CHANGED
@@ -1,29 +1,34 @@
1
1
  ###
2
2
  # to run use
3
- # ruby -I ./lib -I ./test test/test_rss.rb
3
+ # ruby -I ./lib -I ./test test/test_atom.rb
4
4
  # or better
5
5
  # rake test
6
6
 
7
7
  require 'helper'
8
8
 
9
- class TestAtom < MiniTest::Unit::TestCase
9
+ class TestAtom < MiniTest::Test
10
10
 
11
11
  def test_rubyonrails
12
12
  feed = parse_feed( 'http://weblog.rubyonrails.org/feed/atom.xml' )
13
13
 
14
- assert_equal 'atom', feed.format
14
+ assert_equal 'atom', feed.format
15
+ assert_equal 'http://weblog.rubyonrails.org/', feed.url
15
16
  end
16
17
 
18
+
17
19
  def test_railstutorial
18
20
  feed = parse_feed( 'http://feeds.feedburner.com/railstutorial?format=xml' )
19
21
 
20
- assert_equal 'atom', feed.format
22
+ assert_equal 'atom', feed.format
23
+ assert_equal 'http://news.railstutorial.org/', feed.url
21
24
  end
22
25
 
26
+
23
27
  def test_googlegroup
24
28
  feed = parse_feed( 'https://groups.google.com/forum/feed/beerdb/topics/atom.xml?num=15' )
25
29
 
26
30
  assert_equal 'atom', feed.format
31
+ assert_equal 'https://groups.google.com/d/forum/beerdb', feed.url
27
32
  end
28
33
 
29
34
 
@@ -34,6 +39,7 @@ class TestAtom < MiniTest::Unit::TestCase
34
39
  assert_equal 'Blogger', feed.generator
35
40
  assert_equal 'Headius', feed.title
36
41
  assert_equal 'Helping the JVM Into the 21st Century', feed.title2 # aka subtitle in atom
42
+ assert_equal 'http://blog.headius.com/', feed.url
37
43
  end
38
44
 
39
45
  end
@@ -0,0 +1,28 @@
1
+ ###
2
+ # to run use
3
+ # ruby -I ./lib -I ./test test/test_atom_from_file.rb
4
+ # or better
5
+ # rake test
6
+
7
+ require 'helper'
8
+
9
+
10
+ class TestAtomFromFile < MiniTest::Test
11
+
12
+ def test_googlegroup
13
+ feed = parse_feed_from_file( 'googlegroups.atom' )
14
+
15
+ assert_equal 'atom', feed.format
16
+ assert_equal 'Google Groups', feed.generator
17
+ assert_equal 'https://groups.google.com/d/forum/beerdb', feed.url
18
+ end
19
+
20
+ def test_googlegroup2
21
+ feed = parse_feed_from_file( 'googlegroups2.atom' )
22
+
23
+ assert_equal 'atom', feed.format
24
+ assert_equal 'Google Groups (w/ leading n trailing newlines stripped)', feed.generator
25
+ assert_equal 'https://groups.google.com/d/forum/beerdb', feed.url
26
+ end
27
+
28
+ end # class TestAtomFromFile
data/test/test_rss.rb CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  require 'helper'
8
8
 
9
- class TestRss < MiniTest::Unit::TestCase
9
+ class TestRss < MiniTest::Test
10
10
 
11
11
 
12
12
  def test_rubyflow
metadata CHANGED
@@ -1,57 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
5
- prerelease:
4
+ version: 0.5.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gerald Bauer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-09 00:00:00.000000000 Z
11
+ date: 2014-12-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: logutils
16
- requirement: &74494180 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '0.5'
19
+ version: 0.6.1
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *74494180
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.1
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: rdoc
27
- requirement: &74493890 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ~>
31
+ - - "~>"
31
32
  - !ruby/object:Gem::Version
32
- version: '3.10'
33
+ version: '4.0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *74493890
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: hoe
38
- requirement: &74493660 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ~>
45
+ - - "~>"
42
46
  - !ruby/object:Gem::Version
43
- version: '3.3'
47
+ version: '3.13'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *74493660
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.13'
47
55
  description: feedutils - web feed parser and normalizer (RSS 2.0, Atom, etc.)
48
56
  email: feedreader@googlegroups.com
49
57
  executables: []
50
58
  extensions: []
51
59
  extra_rdoc_files:
60
+ - HISTORY.md
52
61
  - Manifest.txt
62
+ - README.md
53
63
  files:
54
- - History.md
64
+ - ".gemtest"
65
+ - HISTORY.md
55
66
  - Manifest.txt
56
67
  - README.md
57
68
  - Rakefile
@@ -62,37 +73,39 @@ files:
62
73
  - lib/feedutils/item.rb
63
74
  - lib/feedutils/parser.rb
64
75
  - lib/feedutils/version.rb
76
+ - test/feeds/googlegroups.atom
77
+ - test/feeds/googlegroups2.atom
65
78
  - test/helper.rb
66
79
  - test/test_atom.rb
80
+ - test/test_atom_from_file.rb
67
81
  - test/test_rss.rb
68
- - .gemtest
69
82
  homepage: https://github.com/rubylibs/feedutils
70
83
  licenses:
71
84
  - Public Domain
85
+ metadata: {}
72
86
  post_install_message:
73
87
  rdoc_options:
74
- - --main
88
+ - "--main"
75
89
  - README.md
76
90
  require_paths:
77
91
  - lib
78
92
  required_ruby_version: !ruby/object:Gem::Requirement
79
- none: false
80
93
  requirements:
81
- - - ! '>='
94
+ - - ">="
82
95
  - !ruby/object:Gem::Version
83
96
  version: 1.9.2
84
97
  required_rubygems_version: !ruby/object:Gem::Requirement
85
- none: false
86
98
  requirements:
87
- - - ! '>='
99
+ - - ">="
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  requirements: []
91
- rubyforge_project: feedutils
92
- rubygems_version: 1.8.17
103
+ rubyforge_project:
104
+ rubygems_version: 2.4.2
93
105
  signing_key:
94
- specification_version: 3
106
+ specification_version: 4
95
107
  summary: feedutils - web feed parser and normalizer (RSS 2.0, Atom, etc.)
96
108
  test_files:
97
109
  - test/test_atom.rb
110
+ - test/test_atom_from_file.rb
98
111
  - test/test_rss.rb