feed_yamlizer 0.1.9 → 0.2.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,6 +22,7 @@ class FeedYamlizer
22
22
  ITEM_SUMMARY_TAGS = %w[ feed/entry/summary rss/channel/item/description rdf:RDF/item/description ]
23
23
  ITEM_CONTENT_TAGS = [ %r{feed/entry/content}, %r{rss/channel/item/content}, %r{rss/channel/item/content:encoded}, %r{rss/item/content}, %r{rdf:RDF/item/content} ]
24
24
 
25
+
25
26
  def initialize
26
27
  @nested_tags = []
27
28
  @x = {:items => []}
@@ -42,6 +43,12 @@ class FeedYamlizer
42
43
  if (attrs['rel'] != 'replies') && (attrs['rel'] == 'alternate' || attrs['type'] == 'text/html')
43
44
  (@current_item[:links] ||= []) << encode(attrs['href'])
44
45
  end
46
+ when /enclosure$/
47
+ @current_item[:enclosure] ||= encode(attrs['url'])
48
+ when /itunes:image$/
49
+ if @current_item
50
+ @current_item[:podcast_image] ||= encode(attrs['href'])
51
+ end
45
52
  end
46
53
  end
47
54
 
@@ -1,3 +1,3 @@
1
1
  class FeedYamlizer
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/feed_yamlizer.rb CHANGED
@@ -15,6 +15,10 @@ require 'yaml'
15
15
  require 'htmlentities'
16
16
  require 'string_ext'
17
17
 
18
+ if ENV['FEED2YAML_ENV'] == 'debug'
19
+ $debug = true
20
+ end
21
+
18
22
  class FeedYamlizer
19
23
  include FileUtils::Verbose
20
24
 
@@ -62,7 +66,7 @@ class FeedYamlizer
62
66
  end
63
67
 
64
68
  def add_item_metaresult(item, index)
65
- fields = [:title, :author, :guid, :pub_date, :link]
69
+ fields = [:title, :author, :guid, :pub_date, :link, :enclosure, :podcast_image]
66
70
  x = {:title => inner_text(item[:title])}
67
71
  metaresult = fields.reduce(x) {|memo, field|
68
72
  memo[field] = item[field]
@@ -94,7 +98,9 @@ class FeedYamlizer
94
98
  class << self
95
99
  def xml_encoding(rawxml)
96
100
  encoding = rawxml.encode("ascii", invalid: :replace, undef: :replace)[/encoding=["']([^"']+)["']/,1]
97
- STDERR.puts "xml encoding: #{encoding.inspect}"
101
+ if $debug
102
+ STDERR.puts "xml encoding: #{encoding.inspect}"
103
+ end
98
104
  encoding
99
105
  end
100
106
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feed_yamlizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-09 00:00:00.000000000Z
12
+ date: 2012-02-11 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &23173960 !ruby/object:Gem::Requirement
16
+ requirement: &70122607994360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *23173960
24
+ version_requirements: *70122607994360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: htmlentities
27
- requirement: &23173180 !ruby/object:Gem::Requirement
27
+ requirement: &70122607992900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *23173180
35
+ version_requirements: *70122607992900
36
36
  description: Converts feeds to YAML and converts entries to plain text
37
37
  email:
38
38
  - dhchoi@gmail.com