feedparser 2.2.0 → 2.2.1

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
- SHA1:
3
- metadata.gz: 417617dcf5fa45dfb199a7e692d2602b8dcb9e3f
4
- data.tar.gz: 0fe1defd0d6bd634e228b067b781b21dcbb7bb3b
2
+ SHA256:
3
+ metadata.gz: daa2fcad3341d6e7ecc1beea5f05e5931c7763c863be715104a1317d491d774c
4
+ data.tar.gz: 95c673aa37b6bc8f81077155e5320f16723e7437356a39ac0082c4bf4661412e
5
5
  SHA512:
6
- metadata.gz: f0894102ebd9b750c12476782f2305b0d8a40946d2a209bc3e19a865ae32b9b17c210449b86f877d67922ba4ae860ba0e454d4de78b3c50b665e0933490a7b3a
7
- data.tar.gz: 4b6f400c017e704d85a2ce7ec512532752a905bf15b541d452c5d32a07ec0dcb46e6b80470e5708081b0dae0d203e0a3074555294e826534fd13bef00f887f6f
6
+ metadata.gz: aea5b0f826dd04602706cad85927e47656f3e2a91f930148460403f414ca11ffedc8736801b2ddb24decfa138bba580e70982e25612b54742aa06db47164836f
7
+ data.tar.gz: fecfa75ab226844282ee318f1760eed0abb9c7f7b76ce5404f3ef00b2bb85c055981252d30701a4cfa77347a308ce8cd91ed90c39a4e277ac29242c91cc4f299
data/CHANGELOG.md CHANGED
@@ -1,3 +1,4 @@
1
+ ### 2.2.1
1
2
  ### 0.1.0 / 2013-09-19
2
3
 
3
4
  * Everything is new. First release.
data/Rakefile CHANGED
@@ -8,10 +8,10 @@ Hoe.spec 'feedparser' do
8
8
  self.summary = 'feedparser - web feed parser and normalizer (RSS, Atom, JSON Feed, HTML h-entry, etc.)'
9
9
  self.description = summary
10
10
 
11
- self.urls = ['https://github.com/feedparser/feedparser']
11
+ self.urls = { home: 'https://github.com/feedparser/feedparser' }
12
12
 
13
13
  self.author = 'Gerald Bauer'
14
- self.email = 'wwwmake@googlegroups.com'
14
+ self.email = 'gerald.bauer@gmail.com'
15
15
 
16
16
  # switch extension to .markdown for gihub formatting
17
17
  self.readme_file = 'README.md'
@@ -1,23 +1,23 @@
1
- # encoding: utf-8
2
-
3
- module FeedParser
4
-
5
- class Attachment ## also known as Enclosure
6
-
7
- attr_accessor :url
8
- ## note: uri is an alias for url
9
- alias :uri :url ## add atom alias for uri - why? why not?
10
- alias :uri= :url=
11
-
12
- attr_accessor :length
13
- attr_accessor :type
14
-
15
- # Elements from the media namespace attachment
16
- attr_accessor :title
17
- attr_accessor :thumbnail
18
- attr_accessor :description
19
- attr_accessor :community
20
-
21
- end # class Attachment
22
-
23
- end # module FeedParser
1
+ # encoding: utf-8
2
+
3
+ module FeedParser
4
+
5
+ class Attachment ## also known as Enclosure
6
+
7
+ attr_accessor :url
8
+ ## note: uri is an alias for url
9
+ alias :uri :url ## add atom alias for uri - why? why not?
10
+ alias :uri= :url=
11
+
12
+ attr_accessor :length
13
+ attr_accessor :type
14
+
15
+ # Elements from the media namespace attachment
16
+ attr_accessor :title
17
+ attr_accessor :thumbnail
18
+ attr_accessor :description
19
+ attr_accessor :community
20
+
21
+ end # class Attachment
22
+
23
+ end # module FeedParser
@@ -1,39 +1,39 @@
1
- # encoding: utf-8
2
-
3
- module FeedParser
4
-
5
- class Author
6
-
7
- attr_accessor :name
8
- attr_accessor :url
9
- ## note: uri is an alias for url
10
- alias :uri :url ## add atom alias for uri - why? why not?
11
- alias :uri= :url=
12
-
13
- def email?() @email.nil? == false; end
14
- attr_accessor :email
15
-
16
- def avatar?() @avatar.nil? == false; end
17
- attr_accessor :avatar # todo/check: use avatar_url ?? used by json feed -check if always a url
18
-
19
-
20
- ## todo: add role - why? why not?
21
- ## e.g. add contributor (atom)
22
- ## or managingEditor (rss) or webMaster (rss) - why? why not??
23
-
24
- attr_accessor :text # note: holds "unparsed" text (content) line form dc:creator or rss:author
25
- alias :line :text # line|text (add str?? too)
26
-
27
- def to_s
28
- ## note: to_s - allows to use just author in templates
29
- ## will by default return name if present or as fallback "unparsed" text line
30
- if @name ## not blank
31
- @name
32
- else
33
- @text
34
- end
35
- end
36
-
37
- end # class Author
38
-
39
- end # module FeedParser
1
+ # encoding: utf-8
2
+
3
+ module FeedParser
4
+
5
+ class Author
6
+
7
+ attr_accessor :name
8
+ attr_accessor :url
9
+ ## note: uri is an alias for url
10
+ alias :uri :url ## add atom alias for uri - why? why not?
11
+ alias :uri= :url=
12
+
13
+ def email?() @email.nil? == false; end
14
+ attr_accessor :email
15
+
16
+ def avatar?() @avatar.nil? == false; end
17
+ attr_accessor :avatar # todo/check: use avatar_url ?? used by json feed -check if always a url
18
+
19
+
20
+ ## todo: add role - why? why not?
21
+ ## e.g. add contributor (atom)
22
+ ## or managingEditor (rss) or webMaster (rss) - why? why not??
23
+
24
+ attr_accessor :text # note: holds "unparsed" text (content) line form dc:creator or rss:author
25
+ alias :line :text # line|text (add str?? too)
26
+
27
+ def to_s
28
+ ## note: to_s - allows to use just author in templates
29
+ ## will by default return name if present or as fallback "unparsed" text line
30
+ if @name ## not blank
31
+ @name
32
+ else
33
+ @text
34
+ end
35
+ end
36
+
37
+ end # class Author
38
+
39
+ end # module FeedParser
@@ -1,111 +1,111 @@
1
- # encoding: utf-8
2
-
3
- module FeedParser
4
-
5
- class JsonFeedBuilder
6
-
7
- include LogUtils::Logging
8
-
9
-
10
- def self.build( hash )
11
- feed = self.new( hash )
12
- feed.to_feed
13
- end
14
-
15
- def initialize( hash )
16
- @feed = build_feed( hash )
17
- end
18
-
19
- def to_feed
20
- @feed
21
- end
22
-
23
-
24
-
25
- def build_feed( h )
26
- feed = Feed.new
27
- feed.format = 'json'
28
-
29
- feed.title = h['title']
30
- feed.url = h['home_page_url']
31
- feed.feed_url = h['feed_url']
32
- feed.summary = h['description']
33
-
34
-
35
- if h['author']
36
- feed.authors << build_author( h['author'] )
37
- end
38
-
39
-
40
- h['items'].each do |hash_item|
41
- feed.items << build_item( hash_item )
42
- end
43
-
44
- feed # return new feed
45
- end # method build_feed_from_json
46
-
47
-
48
- def build_author( h )
49
- author = Author.new
50
-
51
- author.name = h['name']
52
- author.url = h['url']
53
- author.avatar = h['avatar']
54
-
55
- author
56
- end
57
-
58
-
59
-
60
- def build_item( h )
61
- item = Item.new # Item.new
62
-
63
- item.guid = h['id']
64
- item.title = h['title']
65
- item.url = h['url']
66
- item.external_url = h['external_url']
67
-
68
- ## convert date if present (from string to date type)
69
- date_published_str = h['date_published']
70
- if date_published_str
71
- item.published_local = DateTime.iso8601( date_published_str )
72
- item.published = item.published_local.utc
73
- end
74
-
75
- date_modified_str = h['date_modified']
76
- if date_modified_str
77
- item.updated_local = DateTime.iso8601( date_modified_str )
78
- item.updated = item.updated_local.utc
79
- end
80
-
81
-
82
- item.content_html = h['content_html']
83
- item.content_text = h['content_text']
84
- item.summary = h['summary']
85
-
86
- if h['author']
87
- item.authors << build_author( h['author'] )
88
- end
89
-
90
- if h['tags']
91
- h['tags'].each do |json_tag|
92
- item.tags << build_tag( json_tag )
93
- end
94
- end
95
-
96
- item
97
- end # method build_item
98
-
99
-
100
- def build_tag( json_tag )
101
- ## pp rss_cat
102
- tag = Tag.new
103
-
104
- tag.name = json_tag
105
-
106
- tag
107
- end # build_tag
108
-
109
-
110
- end # JsonFeedBuilder
111
- end # FeedParser
1
+ # encoding: utf-8
2
+
3
+ module FeedParser
4
+
5
+ class JsonFeedBuilder
6
+
7
+ include LogUtils::Logging
8
+
9
+
10
+ def self.build( hash )
11
+ feed = self.new( hash )
12
+ feed.to_feed
13
+ end
14
+
15
+ def initialize( hash )
16
+ @feed = build_feed( hash )
17
+ end
18
+
19
+ def to_feed
20
+ @feed
21
+ end
22
+
23
+
24
+
25
+ def build_feed( h )
26
+ feed = Feed.new
27
+ feed.format = 'json'
28
+
29
+ feed.title = h['title']
30
+ feed.url = h['home_page_url']
31
+ feed.feed_url = h['feed_url']
32
+ feed.summary = h['description']
33
+
34
+
35
+ if h['author']
36
+ feed.authors << build_author( h['author'] )
37
+ end
38
+
39
+
40
+ h['items'].each do |hash_item|
41
+ feed.items << build_item( hash_item )
42
+ end
43
+
44
+ feed # return new feed
45
+ end # method build_feed_from_json
46
+
47
+
48
+ def build_author( h )
49
+ author = Author.new
50
+
51
+ author.name = h['name']
52
+ author.url = h['url']
53
+ author.avatar = h['avatar']
54
+
55
+ author
56
+ end
57
+
58
+
59
+
60
+ def build_item( h )
61
+ item = Item.new # Item.new
62
+
63
+ item.guid = h['id']
64
+ item.title = h['title']
65
+ item.url = h['url']
66
+ item.external_url = h['external_url']
67
+
68
+ ## convert date if present (from string to date type)
69
+ date_published_str = h['date_published']
70
+ if date_published_str
71
+ item.published_local = DateTime.iso8601( date_published_str )
72
+ item.published = item.published_local.utc
73
+ end
74
+
75
+ date_modified_str = h['date_modified']
76
+ if date_modified_str
77
+ item.updated_local = DateTime.iso8601( date_modified_str )
78
+ item.updated = item.updated_local.utc
79
+ end
80
+
81
+
82
+ item.content_html = h['content_html']
83
+ item.content_text = h['content_text']
84
+ item.summary = h['summary']
85
+
86
+ if h['author']
87
+ item.authors << build_author( h['author'] )
88
+ end
89
+
90
+ if h['tags']
91
+ h['tags'].each do |json_tag|
92
+ item.tags << build_tag( json_tag )
93
+ end
94
+ end
95
+
96
+ item
97
+ end # method build_item
98
+
99
+
100
+ def build_tag( json_tag )
101
+ ## pp rss_cat
102
+ tag = Tag.new
103
+
104
+ tag.name = json_tag
105
+
106
+ tag
107
+ end # build_tag
108
+
109
+
110
+ end # JsonFeedBuilder
111
+ end # FeedParser