jsl-feedtosis 0.0.3.2 → 0.0.3.4
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.
- data/feedtosis.gemspec +3 -3
- data/lib/feedtosis/client.rb +6 -6
- data/spec/feedtosis/client_spec.rb +19 -0
- metadata +2 -3
- data/lib/extensions/core/array.rb +0 -8
data/feedtosis.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{feedtosis}
|
3
|
-
s.version = "0.0.3.
|
3
|
+
s.version = "0.0.3.4"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Justin Leitgeb"]
|
7
|
-
s.date = %q{2009-
|
7
|
+
s.date = %q{2009-07-15}
|
8
8
|
s.description = %q{Feedtosis finds new information in feeds quickly using smart fetching and matching of previously read entries}
|
9
9
|
s.email = %q{justin@phq.org}
|
10
10
|
|
11
|
-
s.files = ["lib/extensions/core/
|
11
|
+
s.files = ["lib/extensions/core/hash.rb",
|
12
12
|
"lib/extensions/feed_normalizer/feed_instance_methods.rb",
|
13
13
|
"lib/feedtosis/result.rb",
|
14
14
|
"lib/feedtosis/client.rb", "lib/feedtosis.rb", "LICENSE",
|
data/lib/feedtosis/client.rb
CHANGED
@@ -24,14 +24,14 @@ module Feedtosis
|
|
24
24
|
} unless defined?(DEFAULTS)
|
25
25
|
|
26
26
|
# Initializes a new feedtosis library. It must be initialized with a valid URL as the first argument.
|
27
|
-
# A following
|
27
|
+
# A following optional +options+ Hash may take the arguments:
|
28
28
|
# * backend: a key-value store to be used for summary structures of feeds fetched. Moneta backends work well, but any object acting like a Hash is valid.
|
29
29
|
# * retained_digest_size: an Integer specifying the number of previous MD5 sets of entries to keep, used for new feed detection
|
30
|
-
def initialize(
|
31
|
-
@url =
|
30
|
+
def initialize(url, options = { })
|
31
|
+
@url = url
|
32
32
|
|
33
|
-
|
34
|
-
@options =
|
33
|
+
raise ArgumentError, "Feedtosis::Client options must be in Hash form if provided" unless options.is_a?(Hash)
|
34
|
+
@options = options.reverse_merge(DEFAULTS)
|
35
35
|
|
36
36
|
@backend = @options[:backend]
|
37
37
|
|
@@ -94,7 +94,7 @@ module Feedtosis
|
|
94
94
|
# Sets options for the Curl::Easy object, including parameters for HTTP
|
95
95
|
# conditional GET.
|
96
96
|
def build_curl_easy
|
97
|
-
curl = new_curl_easy(url)
|
97
|
+
curl = new_curl_easy(@url)
|
98
98
|
|
99
99
|
# Many feeds have a 302 redirect to another URL. For more recent versions
|
100
100
|
# of Curl, we need to specify this.
|
@@ -26,6 +26,12 @@ describe Feedtosis::Client do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
it "should raise ArgumentError if options is not a Hash" do
|
30
|
+
lambda {
|
31
|
+
Feedtosis::Client.new('http://www.example.com', Object.new)
|
32
|
+
}.should raise_error(ArgumentError)
|
33
|
+
end
|
34
|
+
|
29
35
|
it "should set the If-None-Match and If-Modified-Since headers to the value of the summary hash" do
|
30
36
|
curl_headers = mock('headers')
|
31
37
|
curl_headers.expects(:[]=).with('If-None-Match', '42ab')
|
@@ -90,6 +96,18 @@ describe Feedtosis::Client do
|
|
90
96
|
@fr.fetch
|
91
97
|
end
|
92
98
|
|
99
|
+
describe "when called more than once" do
|
100
|
+
it "should call new_curl_easy with #{@url}" do
|
101
|
+
mock_curl = mock('curl')
|
102
|
+
mock_curl.expects(:follow_location=).with(true).twice
|
103
|
+
mock_curl.expects(:perform).twice
|
104
|
+
mock_curl.expects(:response_code).twice
|
105
|
+
@fr.expects(:new_curl_easy).with(@url).twice.returns(mock_curl)
|
106
|
+
@fr.fetch
|
107
|
+
@fr.fetch
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
93
111
|
describe "when the response code is not 200" do
|
94
112
|
it "should return nil for feed methods such as #title and #author" do
|
95
113
|
curl = mock('curl', :perform => true, :response_code => 304)
|
@@ -140,4 +158,5 @@ describe Feedtosis::Client do
|
|
140
158
|
end
|
141
159
|
end
|
142
160
|
end
|
161
|
+
|
143
162
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsl-feedtosis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.3.
|
4
|
+
version: 0.0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Leitgeb
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-15 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -61,7 +61,6 @@ extensions: []
|
|
61
61
|
extra_rdoc_files:
|
62
62
|
- README.rdoc
|
63
63
|
files:
|
64
|
-
- lib/extensions/core/array.rb
|
65
64
|
- lib/extensions/core/hash.rb
|
66
65
|
- lib/extensions/feed_normalizer/feed_instance_methods.rb
|
67
66
|
- lib/feedtosis/result.rb
|