chuckle 1.0.0 → 1.0.1
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/.travis.yml +5 -0
- data/chuckle.gemspec +2 -2
- data/lib/chuckle/cache.rb +7 -5
- data/lib/chuckle/client.rb +1 -1
- data/lib/chuckle/response.rb +3 -2
- data/lib/chuckle/version.rb +1 -1
- data/test/helper.rb +9 -0
- data/test/test_requests.rb +7 -0
- metadata +6 -5
data/.travis.yml
ADDED
data/chuckle.gemspec
CHANGED
|
@@ -10,8 +10,8 @@ Gem::Specification.new do |s|
|
|
|
10
10
|
s.authors = ["Adam Doppelt"]
|
|
11
11
|
s.email = ["amd@gurge.com"]
|
|
12
12
|
s.homepage = "http://github.com/gurgeous/chuckle"
|
|
13
|
-
s.summary = "Chuckle -
|
|
14
|
-
s.description = "
|
|
13
|
+
s.summary = "Chuckle - an http client that caches on disk."
|
|
14
|
+
s.description = "An http client that caches on disk."
|
|
15
15
|
|
|
16
16
|
s.rubyforge_project = "chuckle"
|
|
17
17
|
|
data/lib/chuckle/cache.rb
CHANGED
|
@@ -20,11 +20,13 @@ module Chuckle
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def set(request, curl)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
# mkdirs
|
|
24
|
+
FileUtils.mkdir_p([File.dirname(request.headers_path), File.dirname(request.body_path)])
|
|
25
|
+
|
|
26
|
+
# now mv
|
|
27
|
+
FileUtils.mv(curl.headers_path, request.headers_path)
|
|
28
|
+
FileUtils.mv(curl.body_path, request.body_path)
|
|
29
|
+
|
|
28
30
|
Response.new(request)
|
|
29
31
|
end
|
|
30
32
|
|
data/lib/chuckle/client.rb
CHANGED
data/lib/chuckle/response.rb
CHANGED
|
@@ -29,15 +29,16 @@ module Chuckle
|
|
|
29
29
|
def parse
|
|
30
30
|
self.curl_exit_code = Curl.exit_code_from_headers(headers)
|
|
31
31
|
|
|
32
|
+
self.uri = request.uri
|
|
32
33
|
locations = headers.scan(/^Location: ([^\r\n]+)/m).flatten
|
|
33
34
|
if !locations.empty?
|
|
34
35
|
location = locations.last
|
|
35
36
|
# some buggy servers do this. sigh.
|
|
36
37
|
location = location.gsub(" ", "%20")
|
|
37
|
-
self.uri
|
|
38
|
+
self.uri += location
|
|
38
39
|
end
|
|
39
40
|
|
|
40
|
-
codes = headers.scan(/^HTTP\/\d\.\d (\d+).*?\r\n
|
|
41
|
+
codes = headers.scan(/^HTTP\/\d\.\d (\d+).*?\r\n/m).flatten
|
|
41
42
|
codes = codes.map(&:to_i)
|
|
42
43
|
self.code = codes.last
|
|
43
44
|
end
|
data/lib/chuckle/version.rb
CHANGED
data/test/helper.rb
CHANGED
data/test/test_requests.rb
CHANGED
|
@@ -24,6 +24,13 @@ class TestRequests < Minitest::Test
|
|
|
24
24
|
assert_equal "hello\n", response.body
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
def test_302_relative
|
|
28
|
+
response = mcurl(HTTP_302_RELATIVE) { client.get(URL) }
|
|
29
|
+
assert_equal 200, response.code
|
|
30
|
+
assert_equal URI.parse("#{URL}/two"), response.uri
|
|
31
|
+
assert_equal "hello\n", response.body
|
|
32
|
+
end
|
|
33
|
+
|
|
27
34
|
def test_404
|
|
28
35
|
e = assert_raises Chuckle::Error do
|
|
29
36
|
mcurl(HTTP_404) do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chuckle
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.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: 2013-05-
|
|
12
|
+
date: 2013-05-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: awesome_print
|
|
@@ -91,7 +91,7 @@ dependencies:
|
|
|
91
91
|
- - ! '>='
|
|
92
92
|
- !ruby/object:Gem::Version
|
|
93
93
|
version: '0'
|
|
94
|
-
description:
|
|
94
|
+
description: An http client that caches on disk.
|
|
95
95
|
email:
|
|
96
96
|
- amd@gurge.com
|
|
97
97
|
executables: []
|
|
@@ -99,6 +99,7 @@ extensions: []
|
|
|
99
99
|
extra_rdoc_files: []
|
|
100
100
|
files:
|
|
101
101
|
- .gitignore
|
|
102
|
+
- .travis.yml
|
|
102
103
|
- Gemfile
|
|
103
104
|
- LICENSE
|
|
104
105
|
- README.md
|
|
@@ -139,13 +140,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
139
140
|
version: '0'
|
|
140
141
|
segments:
|
|
141
142
|
- 0
|
|
142
|
-
hash:
|
|
143
|
+
hash: -3317364503700294322
|
|
143
144
|
requirements: []
|
|
144
145
|
rubyforge_project: chuckle
|
|
145
146
|
rubygems_version: 1.8.24
|
|
146
147
|
signing_key:
|
|
147
148
|
specification_version: 3
|
|
148
|
-
summary: Chuckle -
|
|
149
|
+
summary: Chuckle - an http client that caches on disk.
|
|
149
150
|
test_files:
|
|
150
151
|
- test/helper.rb
|
|
151
152
|
- test/test_cache.rb
|