jsl-myzofeedtosis 0.0.1.4 → 0.0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -0
- data/lib/myzofeedtosis/client.rb +4 -8
- data/lib/myzofeedtosis/result.rb +16 -11
- data/myzofeedtosis.gemspec +1 -1
- data/spec/myzofeedtosis/result_spec.rb +4 -0
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -131,6 +131,11 @@ Myzofeedtosis doesn't do anything about feed sanitizing, as other libraries have
|
|
131
131
|
been built for this purpose. FeedNormalizer has methods for escaping entries,
|
132
132
|
but to strip HTML I suggest that you look at the Ruby gem "sanitize".
|
133
133
|
|
134
|
+
== Credits
|
135
|
+
|
136
|
+
Thanks to Sander Hartlage (GitHub: Sander6) for useful feedback early in the
|
137
|
+
development of Myzofeedtosis.
|
138
|
+
|
134
139
|
== Feedback
|
135
140
|
|
136
141
|
Please let me know if you have any problems with or questions about
|
data/lib/myzofeedtosis/client.rb
CHANGED
@@ -24,14 +24,10 @@ module Myzofeedtosis
|
|
24
24
|
@options[:backend].except(:moneta_klass) )
|
25
25
|
end
|
26
26
|
|
27
|
-
# Retrieves the latest entries from this feed. Returns a
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
# request resulted in a 304 (Not Modified) response code since we don't have
|
32
|
-
# any new results. Depending on your business logic, you may want to do
|
33
|
-
# something in this case, such as putting this resource in a lower-priority
|
34
|
-
# queue if it is not frequently updated.
|
27
|
+
# Retrieves the latest entries from this feed. Returns a Myzofeedtosis::Result
|
28
|
+
# object which delegates methods to the Curl::Easy object making the request
|
29
|
+
# and the FeedNormalizer::Feed object that may have been created from the
|
30
|
+
# HTTP response body.
|
35
31
|
def fetch
|
36
32
|
curl = build_curl_easy
|
37
33
|
curl.perform
|
data/lib/myzofeedtosis/result.rb
CHANGED
@@ -5,7 +5,7 @@ module Myzofeedtosis
|
|
5
5
|
# method calls to the correct object. If FeedNormalizer wasn't able to process
|
6
6
|
# the response, calls which would be delegated to this object return nil. In
|
7
7
|
# these cases, depending on your business logic you may want to inspect the
|
8
|
-
# state of the Curl::Easy object.
|
8
|
+
# state of the Curl::Easy object by using methods forwarded to it.
|
9
9
|
class Result
|
10
10
|
|
11
11
|
# Methods which should be delegated to the FeedNormalizer::Feed object.
|
@@ -14,21 +14,26 @@ module Myzofeedtosis
|
|
14
14
|
:new_entries, :channel, :ttl, :skip_hours, :skip_days
|
15
15
|
] unless defined?(FEED_METHODS)
|
16
16
|
|
17
|
+
# Precompiled regexp for detecting removing setter methods from collection
|
18
|
+
# of methods to be delegated to the Curl::Easy object.
|
19
|
+
SETTER_METHOD_RE = /=$/o unless defined?(SETTER_METHOD_RE)
|
20
|
+
|
17
21
|
def initialize(curl, feed)
|
18
22
|
@curl = curl
|
19
23
|
@feed = feed
|
20
24
|
|
21
25
|
raise ArgumentError, "Curl object must not be nil" if curl.nil?
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
end
|
27
|
+
|
28
|
+
# See what the Curl::Easy object responds to, and send any appropriate
|
29
|
+
# messages its way. We don't worry about setter methods, since those
|
30
|
+
# aren't really useful to delegate.
|
31
|
+
Curl::Easy.instance_methods(false).reject do |m|
|
32
|
+
m =~ SETTER_METHOD_RE
|
33
|
+
end.each do |meth|
|
34
|
+
define_method meth do |*args|
|
35
|
+
@curl.send(meth, *args)
|
36
|
+
end
|
32
37
|
end
|
33
38
|
|
34
39
|
# Send methods through to the feed object unless it is nil. If feed
|
data/myzofeedtosis.gemspec
CHANGED
@@ -23,6 +23,10 @@ describe Myzofeedtosis::Result do
|
|
23
23
|
@r.body_str
|
24
24
|
end
|
25
25
|
|
26
|
+
it "should not respond to setter methods common in the Curl::Easy class" do
|
27
|
+
@r.should_not respond_to(:encoding=)
|
28
|
+
end
|
29
|
+
|
26
30
|
it "should return nil for author if the Feed is nil" do
|
27
31
|
r = Myzofeedtosis::Result.new(@c, nil)
|
28
32
|
r.author
|