feed_yamlizer 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,23 +26,26 @@ class FeedYamlizer
26
26
  @x = {:items => []}
27
27
  end
28
28
 
29
- def result; @x; end
29
+ def result
30
+ @x
31
+ end
30
32
 
31
33
  def tag_start(name, attrs)
32
34
  @nested_tags.push name
33
35
  case path
34
36
  when 'feed/link'
35
- @x[:link] = encode attrs['href']
37
+ @x[:link] ||= encode attrs['href']
36
38
  when *ITEM_START_TAGS
37
39
  @current_item = {}
38
40
  when 'feed/entry/link'
39
- @current_item[:link] = encode attrs['href']
41
+ (@current_item[:links] ||= []) << encode(attrs['href'])
40
42
  end
41
43
  end
42
44
 
43
45
  def tag_end(name)
44
46
  case path
45
47
  when *ITEM_START_TAGS
48
+ @current_item[:link] ||= @current_item[:links].detect {|x| x !~ /\.(jpg|png|gif)$/}
46
49
  @x[:items] << @current_item
47
50
  @current_item = nil
48
51
  end
@@ -54,7 +57,7 @@ class FeedYamlizer
54
57
  when *FEED_TITLE_TAGS
55
58
  @x[:title] = encode text.strip
56
59
  when *FEED_LINK_TAGS
57
- @x[:link] = encode text.strip
60
+ @x[:link] ||= encode text.strip
58
61
  when *ITEM_TITLE_TAGS
59
62
  @current_item[:title] = encode(text.strip)
60
63
  when *ITEM_AUTHOR_TAGS
@@ -64,7 +67,8 @@ class FeedYamlizer
64
67
  when *ITEM_PUB_DATE_TAGS
65
68
  @current_item[:pub_date] = DateTime.parse(encode(text))
66
69
  when *ITEM_LINK_TAGS
67
- @current_item[:link] = encode(text)
70
+ @current_item[:link] ||= encode(text)
71
+ (@current_item[:links] ||= []) << encode(text)
68
72
  when *ITEM_SUMMARY_TAGS
69
73
  if @current_item[:summary]
70
74
  @current_item[:summary] << encode(text)
@@ -1,3 +1,3 @@
1
1
  class FeedYamlizer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi