feedzirra 0.0.31 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -14,36 +14,6 @@ The fetching and parsing logic have been decoupled so that either of them can be
14
14
 
15
15
  The final feature of Feedzirra is the ability to define custom parsing classes. In truth, Feedzirra could be used to parse much more than feeds. Microformats, page scraping, and almost anything else are fair game.
16
16
 
17
- === Installation
18
-
19
- For now Feedzirra exists only on github. It also has a few gem requirements that are only on github. Before you start you need to have libcurl[link:http://curl.haxx.se/] and libxml[link:http://xmlsoft.org/] installed. If you're on Leopard you have both. Otherwise, you'll need to grab them. Once you've got those libraries, these are the gems that get used: nokogiri, pauldix-sax-machine, taf2-curb (note that this is a fork that lives on github and not the Ruby Forge version of curb), and pauldix-feedzirra. The feedzirra gemspec has all the dependencies so you should be able to get up and running with the standard github gem install routine:
20
-
21
- gem sources -a http://gems.github.com # if you haven't already
22
- gem install pauldix-feedzirra
23
-
24
- *NOTE:*Some people have been reporting a few issues related to installation. First, the Ruby Forge version of curb is not what you want. It will not work. Nor will the curl-multi gem that lives on Ruby Forge. You have to get the taf2-curb[link:http://github.com/taf2/curb/tree/master] fork installed.
25
-
26
- If you see this error when doing a require:
27
-
28
- /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- curb_core (LoadError)
29
-
30
- It means that the taf2-curb gem didn't build correctly. To resolve this you can do a git clone git://github.com/taf2/curb.git then run rake gem in the curb directory, then sudo gem install pkg/curb-0.2.4.0.gem. After that you should be good.
31
-
32
- If you see something like this when trying to run it:
33
-
34
- NoMethodError: undefined method `on_success' for #<Curl::Easy:0x1182724>
35
- from ./lib/feedzirra/feed.rb:88:in `add_url_to_multi'
36
-
37
- This means that you are requiring curl-multi or the Ruby Forge version of Curb somewhere. You can't use those and need to get the taf2 version up and running.
38
-
39
- If you're on Debian or Ubuntu and getting errors while trying to install the taf2-curb gem, it could be because you don't have the latest version of libcurl installed. Do this to fix:
40
-
41
- sudo apt-get install libcurl4-gnutls-dev
42
-
43
- Another problem could be if you are running Mac Ports and you have libcurl installed through there. You need to uninstall it for curb to work! The version in Mac Ports is old and doesn't play nice with curb. If you're running Leopard, you can just uninstall and you should be golden. If you're on an older version of OS X, you'll then need to {download curl}[http://curl.haxx.se/download.html] and build from source. Then you'll have to install the taf2-curb gem again. You might have to perform the step above.
44
-
45
- If you're still having issues, please let me know on the mailing list. Also, {Todd Fisher (taf2)}[link:http://github.com/taf2] is working on fixing the gem install. Please send him a full error report.
46
-
47
17
  === Speedup date parsing
48
18
 
49
19
  In MRI the date parsing code is written in ruby and is optimized for readability over speed, to speed up this part you can install the {home_run}[https://github.com/jeremyevans/home_run] gem to replace it with an optimized C version.
@@ -3,30 +3,48 @@ module Feedzirra
3
3
  module Parser
4
4
  # Parser for dealing with RDF feed entries.
5
5
  class RSSEntry
6
+ include Enumerable
6
7
  include SAXMachine
7
8
  include FeedEntryUtilities
9
+
8
10
  element :title
9
11
  element :link, :as => :url
10
-
12
+
11
13
  element :"dc:creator", :as => :author
12
14
  element :author, :as => :author
13
15
  element :"content:encoded", :as => :content
14
16
  element :description, :as => :summary
15
-
17
+
16
18
  element :pubDate, :as => :published
17
19
  element :pubdate, :as => :published
18
20
  element :"dc:date", :as => :published
19
21
  element :"dc:Date", :as => :published
20
22
  element :"dcterms:created", :as => :published
21
-
22
-
23
+
24
+
23
25
  element :"dcterms:modified", :as => :updated
24
26
  element :issued, :as => :published
25
27
  elements :category, :as => :categories
26
-
28
+
27
29
  element :guid, :as => :entry_id
30
+
31
+ def each
32
+ @rss_fields ||= self.instance_variables
33
+
34
+ @rss_fields.each do |field|
35
+ yield(field.to_s.sub('@', ''), self.instance_variable_get(field))
36
+ end
37
+ end
38
+
39
+ def [](field)
40
+ self.instance_variable_get("@#{field.to_s}")
41
+ end
42
+
43
+ def []=(field, value)
44
+ self.instance_variable_set("@#{field.to_s}", value)
45
+ end
28
46
  end
29
47
 
30
48
  end
31
49
 
32
- end
50
+ end
@@ -1,3 +1,3 @@
1
1
  module Feedzirra
2
- VERSION = "0.0.31"
2
+ VERSION = '0.1.0'
3
3
  end
@@ -7,6 +7,13 @@ describe Feedzirra::Parser::RSSEntry do
7
7
  # but this is actually how it should work. You would never just pass entry xml straight to the AtomEnry
8
8
  @entry = Feedzirra::Parser::RSS.parse(sample_rss_feed).entries.first
9
9
  end
10
+
11
+ after(:each) do
12
+ # We change the title in one or more specs to test []=
13
+ if @entry.title != "Nokogiri’s Slop Feature"
14
+ @entry.title = Feedzirra::Parser::RSS.parse(sample_rss_feed).entries.first.title
15
+ end
16
+ end
10
17
 
11
18
  it "should parse the title" do
12
19
  @entry.title.should == "Nokogiri’s Slop Feature"
@@ -39,4 +46,40 @@ describe Feedzirra::Parser::RSSEntry do
39
46
  it "should parse the guid as id" do
40
47
  @entry.id.should == "http://tenderlovemaking.com/?p=198"
41
48
  end
42
- end
49
+
50
+ it "should support each" do
51
+ @entry.respond_to? :each
52
+ end
53
+
54
+ it "should be able to list out all fields with each" do
55
+ all_fields = []
56
+ @entry.each do |field, value|
57
+ all_fields << field
58
+ end
59
+ all_fields.sort == ['author', 'categories', 'content', 'id', 'published', 'summary', 'title', 'url']
60
+ end
61
+
62
+ it "should be able to list out all values with each" do
63
+ title_value = ''
64
+ @entry.each do |field, value|
65
+ title_value = value if field == 'title'
66
+ end
67
+ title_value.should == "Nokogiri’s Slop Feature"
68
+ end
69
+
70
+ it "should support checking if a field exists in the entry" do
71
+ @entry.include?('title') && @entry.include?('author')
72
+ end
73
+
74
+ it "should allow access to fields with hash syntax" do
75
+ @entry['title'] == @entry.title && \
76
+ @entry['title'].should == "Nokogiri’s Slop Feature" && \
77
+ @entry['author'] == @entry.author && \
78
+ @entry['author'].should == "Aaron Patterson"
79
+ end
80
+
81
+ it "should allow setting field values with hash syntax" do
82
+ @entry['title'] = "Foobar"
83
+ @entry.title.should == "Foobar"
84
+ end
85
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedzirra
3
3
  version: !ruby/object:Gem::Version
4
- hash: 33
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 31
10
- version: 0.0.31
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Dix
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-19 00:00:00 Z
19
+ date: 2011-09-30 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: nokogiri
@@ -42,12 +42,12 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 55
45
+ hash: 27
46
46
  segments:
47
47
  - 0
48
+ - 1
48
49
  - 0
49
- - 20
50
- version: 0.0.20
50
+ version: 0.1.0
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
@@ -74,12 +74,12 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- hash: 7
77
+ hash: 15
78
78
  segments:
79
- - 3
80
- - 0
81
- - 0
82
- version: 3.0.0
79
+ - 2
80
+ - 1
81
+ - 2
82
+ version: 2.1.2
83
83
  type: :runtime
84
84
  version_requirements: *id004
85
85
  - !ruby/object:Gem::Dependency
@@ -106,12 +106,12 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- hash: 23
109
+ hash: 31
110
110
  segments:
111
111
  - 1
112
+ - 2
112
113
  - 0
113
- - 0
114
- version: 1.0.0
114
+ version: 1.2.0
115
115
  type: :runtime
116
116
  version_requirements: *id006
117
117
  - !ruby/object:Gem::Dependency