rack-cachely 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/rack-cachely/key.rb +2 -2
- data/lib/rack-cachely/store.rb +3 -2
- data/lib/rack-cachely/version.rb +1 -1
- data/spec/rack-cachely/key_spec.rb +10 -0
- data/spec/rack-cachely/store_spec.rb +3 -2
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/rack-cachely/key.rb
CHANGED
data/lib/rack-cachely/store.rb
CHANGED
@@ -9,7 +9,7 @@ module Rack
|
|
9
9
|
|
10
10
|
def get(key)
|
11
11
|
remote do
|
12
|
-
url = "#{config.cachely_url}?url=#{CGI.escape(key.to_s)}"
|
12
|
+
url = "#{config.cachely_url}?_version=#{Rack::Cachely::VERSION}&url=#{CGI.escape(key.to_s)}"
|
13
13
|
uri = URI(url)
|
14
14
|
http = Net::HTTP.new(uri.host, uri.port)
|
15
15
|
request = Net::HTTP::Get.new(uri.request_uri)
|
@@ -43,7 +43,8 @@ module Rack
|
|
43
43
|
"document[url]" => key,
|
44
44
|
"document[status]" => rack[0].to_i,
|
45
45
|
"document[body]" => body,
|
46
|
-
"document[age]" => options[:age] || 0
|
46
|
+
"document[age]" => options[:age] || 0,
|
47
|
+
"_version" => Rack::Cachely::VERSION
|
47
48
|
}
|
48
49
|
rack[1].each do |key, value|
|
49
50
|
data["document[headers][#{key}]"] = value
|
data/lib/rack-cachely/version.rb
CHANGED
@@ -16,6 +16,16 @@ describe Rack::Cachely::Key do
|
|
16
16
|
Rack::Cachely.config.ignore_query_params = ["A", "c"]
|
17
17
|
key.to_s.should eql("http://example.com/foo/bar?b=B&d=D")
|
18
18
|
end
|
19
|
+
|
20
|
+
context "no query string" do
|
21
|
+
|
22
|
+
let(:request) { double(scheme: "http", host: "example.com", port: 80, script_name: "/foo", path_info: "/bar", query_string: "") }
|
23
|
+
|
24
|
+
it "does not have an empty ? at the end" do
|
25
|
+
key.to_s.should eql("http://example.com/foo/bar")
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
19
29
|
|
20
30
|
end
|
21
31
|
|
@@ -10,7 +10,7 @@ describe Rack::Cachely::Store do
|
|
10
10
|
it "retreives a page from the service" do
|
11
11
|
response_mock = double(code: "200", body: "hello!")
|
12
12
|
response_mock.stub!(:each_header).and_yield("Content-Type", "text/html")
|
13
|
-
Net::HTTP::Get.should_receive(:new).with("/v1/cache?url=http%3A%2F%2Fexample.com").and_return {
|
13
|
+
Net::HTTP::Get.should_receive(:new).with("/v1/cache?_version=#{Rack::Cachely::VERSION}&url=http%3A%2F%2Fexample.com").and_return {
|
14
14
|
m = double
|
15
15
|
m.should_receive(:basic_auth).with("1234567890", nil)
|
16
16
|
m
|
@@ -47,7 +47,8 @@ describe Rack::Cachely::Store do
|
|
47
47
|
"document[status]" => 200,
|
48
48
|
"document[body]" => "hello!",
|
49
49
|
"document[age]" => 30,
|
50
|
-
"document[headers][Content-Type]" => "text/html"
|
50
|
+
"document[headers][Content-Type]" => "text/html",
|
51
|
+
"_version" => Rack::Cachely::VERSION
|
51
52
|
}
|
52
53
|
end
|
53
54
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-cachely
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|