pavlov_rss 0.0.2 → 0.0.3

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
2
  SHA1:
3
- metadata.gz: 66830b65cb32b2621ca5a1bd39c998bcf31a85d3
4
- data.tar.gz: 0eaef59029d535f119636e3576d490f698332106
3
+ metadata.gz: 124cdf8d9daf80cd1469a706a6c3c910070b3e7b
4
+ data.tar.gz: 5e73a02d74061640507c3157eedce1e09067e14d
5
5
  SHA512:
6
- metadata.gz: d3f50ceed01ec6cef120233ead2fc7f58c640e91a87538bacf15b16e998677dd619ec494429b6d2e3e41298ffd03f6cf1bb128ce10848dd42048804183cb5a27
7
- data.tar.gz: 5c3575dfb1b5a48bd704419a95f6770ff4a01847d698985b46d6b3a2762f1868568eba0bbb53a6145689b3778b864d491f1a538aad4a5a73b1a541293c7459bb
6
+ metadata.gz: 41318068f97592b7e7ca3a82912c8aee572ae211c77c1be46bd1147dcfc4f00cec03189bd0e3b89b01bb94c6a0bb2280e1ca34218b1f89d8b659915368c57587
7
+ data.tar.gz: d2dd2b40e53d911cb9d9887922272545a9e8978cc68c73c56524f5c5d50fb8a9202a71a673e7132d6a806e968f20728581630290707e5ab44913ea4313c875a9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pavlov_rss (0.0.2)
4
+ pavlov_rss (0.0.3)
5
5
  activesupport
6
6
  nokogiri
7
7
 
@@ -26,7 +26,14 @@ module PavlovRss
26
26
  end
27
27
 
28
28
  def item_to_json rss
29
- result = Hash.from_xml(rss.to_xml)['rss']['channel']['item'] || []
29
+ value = Hash.from_xml(rss.to_xml)
30
+ result = case
31
+ when value.has_key?('rss')
32
+ value['rss']['channel']['item']
33
+ when value.has_key?('feed')
34
+ value['feed']['entry']
35
+ end
36
+ result ||= []
30
37
  return result if result.is_a? Array
31
38
  return [result]
32
39
  end
@@ -1,3 +1,3 @@
1
1
  module PavlovRss
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,8 @@
1
+ <?xml version="2.0" encoding="UTF-8"?>
2
+ <feed xmlns="http://www.w3.org/2005/Atom">
3
+ <entry>
4
+ <title>title</title>
5
+ <id>tag_string</id>
6
+ <content>content</content>
7
+ </entry>
8
+ </feed>
@@ -121,6 +121,15 @@ describe PavlovRss::Reader do
121
121
  result = @reader.item_to_json rss
122
122
  result.should == []
123
123
  end
124
+ it "works on atom" do
125
+ atom = Nokogiri.XML(feed('atom.xml'))
126
+ result = @reader.item_to_json atom
127
+ result.should == [{
128
+ "title"=>"title",
129
+ "id"=>"tag_string",
130
+ "content"=>"content"
131
+ }]
132
+ end
124
133
  end
125
134
  end
126
135
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pavlov_rss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minwoo Lee
@@ -185,6 +185,7 @@ files:
185
185
  - lib/pavlov_rss/reader.rb
186
186
  - lib/pavlov_rss/version.rb
187
187
  - pavlov_rss.gemspec
188
+ - spec/fixtures/atom.xml
188
189
  - spec/fixtures/rss0.xml
189
190
  - spec/fixtures/rss1.xml
190
191
  - spec/fixtures/rss2.xml
@@ -218,6 +219,7 @@ signing_key:
218
219
  specification_version: 4
219
220
  summary: Pavlov's RSS
220
221
  test_files:
222
+ - spec/fixtures/atom.xml
221
223
  - spec/fixtures/rss0.xml
222
224
  - spec/fixtures/rss1.xml
223
225
  - spec/fixtures/rss2.xml