feedutils 0.2.0 → 0.3.0

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.
@@ -22,9 +22,28 @@ class AtomFeedBuilder
22
22
  def build_feed( atom_feed )
23
23
  feed = Feed.new
24
24
  feed.object = atom_feed
25
- feed.title = atom_feed.title.content
26
25
  feed.format = 'atom'
27
26
 
27
+ feed.title = atom_feed.title.content
28
+
29
+ if atom_feed.updated
30
+ # NOTE: empty updated.content e.g. used by google groups feed
31
+ # will return nil : NilClass
32
+ feed.updated = atom_feed.updated.content # .utc.strftime( "%Y-%m-%d %H:%M" )
33
+ logger.debug " atom | updated.content >#{atom_feed.updated.content}< : #{atom_feed.updated.content.class.name}"
34
+ end
35
+
36
+ if atom_feed.generator
37
+ feed.generator = atom_feed.generator.content
38
+ logger.debug " atom | generator.content >#{atom_feed.generator.content}< : #{atom_feed.generator.content.class.name}"
39
+ end
40
+
41
+ if atom_feed.subtitle
42
+ feed.title2 = atom_feed.subtitle.content
43
+ logger.debug " atom | subtitle.content >#{atom_feed.subtitle.content}< : #{atom_feed.subtitle.content.class.name}"
44
+ end
45
+
46
+
28
47
  items = []
29
48
  atom_feed.items.each do |atom_item|
30
49
  items << build_feed_item( atom_item )
@@ -45,15 +64,18 @@ class AtomFeedBuilder
45
64
  logger.debug " atom | item.link.href: >#{atom_item.link.href}< : #{atom_item.link.href.class.name}"
46
65
 
47
66
 
48
- ## todo: check if updated or published present
49
- # set
50
- item.updated = atom_item.updated.content # .utc.strftime( "%Y-%m-%d %H:%M" )
67
+ if atom_item.updated
68
+ item.updated = atom_item.updated.content # .utc.strftime( "%Y-%m-%d %H:%M" )
51
69
 
70
+ ## change time to utc if present? why? why not?
52
71
 
53
- ## change time to utc if present? why? why not?
54
-
55
- ### todo: use/try published first? why? why not?
56
- logger.debug " atom | item.updated >#{atom_item.updated.content}< : #{atom_item.updated.content.class.name}"
72
+ logger.debug " atom | item.updated.content >#{atom_item.updated.content}< : #{atom_item.updated.content.class.name}"
73
+ end
74
+
75
+ if atom_item.published
76
+ item.published = atom_item.published.content # .utc.strftime( "%Y-%m-%d %H:%M" )
77
+ logger.debug " atom | item.published.content >#{atom_item.published.content}< : #{atom_item.published.content.class.name}"
78
+ end
57
79
 
58
80
  # - todo/check: does it exist in atom format?
59
81
  # item.published = item.updated # fix: check if publshed set
@@ -69,11 +91,15 @@ class AtomFeedBuilder
69
91
  ## fix/todo:
70
92
  # also save/include full content in content
71
93
 
94
+ if atom_item.content
95
+ item.content = atom_item.content.content
96
+ end
97
+
72
98
  if atom_item.summary
73
99
  item.summary = atom_item.summary.content
74
100
  else
75
101
  if atom_item.content
76
- text = atom_item.content.content.dup
102
+ text = atom_item.content.content
77
103
  ## strip all html tags
78
104
  text = text.gsub( /<[^>]+>/, '' )
79
105
  text = text[ 0..400 ] # get first 400 chars
@@ -1,4 +1,4 @@
1
1
 
2
2
  module FeedUtils
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
data/test/test_atom.rb CHANGED
@@ -13,4 +13,14 @@ class TestAtom < MiniTest::Unit::TestCase
13
13
  assert( feed.format == 'atom' )
14
14
  end
15
15
 
16
+ def test_railstutorial
17
+ feed = parse_feed( 'http://feeds.feedburner.com/railstutorial?format=xml' )
18
+ assert( feed.format == 'atom' )
19
+ end
20
+
21
+ def test_googlegroup
22
+ feed = parse_feed( 'https://groups.google.com/forum/feed/beerdb/topics/atom.xml?num=15' )
23
+ assert( feed.format == 'atom' )
24
+ end
25
+
16
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logutils
16
- requirement: &68865360 !ruby/object:Gem::Requirement
16
+ requirement: &74860390 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.5'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *68865360
24
+ version_requirements: *74860390
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &68864940 !ruby/object:Gem::Requirement
27
+ requirement: &74859360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.10'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *68864940
35
+ version_requirements: *74859360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: hoe
38
- requirement: &68864560 !ruby/object:Gem::Requirement
38
+ requirement: &74858200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '3.3'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *68864560
46
+ version_requirements: *74858200
47
47
  description: feedutils - web feed parser and normalizer (RSS 2.0, Atom, etc.)
48
48
  email: webslideshow@googlegroups.com
49
49
  executables: []