resourceful 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +22 -23
- data/lib/resourceful/authentication_manager.rb +1 -1
- data/lib/resourceful/cache_manager.rb +8 -9
- data/lib/resourceful/memcache_cache_manager.rb +4 -4
- data/lib/resourceful/response.rb +3 -4
- data/lib/resourceful.rb +1 -1
- data/resourceful.gemspec +4 -4
- metadata +33 -33
data/Manifest
CHANGED
@@ -1,30 +1,29 @@
|
|
1
|
-
|
2
|
-
spec/spec.opts
|
3
|
-
spec/simple_sinatra_server_spec.rb
|
4
|
-
spec/simple_sinatra_server.rb
|
5
|
-
spec/acceptance/header_spec.rb
|
6
|
-
spec/acceptance/caching_spec.rb
|
7
|
-
spec/acceptance/resource_spec.rb
|
8
|
-
spec/acceptance/redirecting_spec.rb
|
9
|
-
spec/acceptance/authorization_spec.rb
|
10
|
-
spec/acceptance_shared_specs.rb
|
11
|
-
spec/spec_helper.rb
|
12
|
-
spec/old_acceptance_specs.rb
|
13
|
-
README.markdown
|
14
|
-
resourceful.gemspec
|
15
|
-
lib/resourceful/cache_manager.rb
|
16
|
-
lib/resourceful/exceptions.rb
|
1
|
+
lib/resourceful.rb
|
17
2
|
lib/resourceful/net_http_adapter.rb
|
18
3
|
lib/resourceful/stubbed_resource_proxy.rb
|
19
4
|
lib/resourceful/header.rb
|
20
|
-
lib/resourceful/
|
21
|
-
lib/resourceful/request.rb
|
22
|
-
lib/resourceful/resource.rb
|
5
|
+
lib/resourceful/memcache_cache_manager.rb
|
23
6
|
lib/resourceful/response.rb
|
24
7
|
lib/resourceful/util.rb
|
25
|
-
lib/resourceful/http_accessor.rb
|
26
8
|
lib/resourceful/options_interpreter.rb
|
27
|
-
lib/resourceful/
|
28
|
-
lib/resourceful.rb
|
29
|
-
|
9
|
+
lib/resourceful/cache_manager.rb
|
10
|
+
lib/resourceful/request.rb
|
11
|
+
lib/resourceful/resource.rb
|
12
|
+
lib/resourceful/exceptions.rb
|
13
|
+
lib/resourceful/http_accessor.rb
|
14
|
+
lib/resourceful/authentication_manager.rb
|
15
|
+
README.markdown
|
30
16
|
MIT-LICENSE
|
17
|
+
Rakefile
|
18
|
+
Manifest
|
19
|
+
spec/simple_sinatra_server_spec.rb
|
20
|
+
spec/old_acceptance_specs.rb
|
21
|
+
spec/acceptance_shared_specs.rb
|
22
|
+
spec/spec_helper.rb
|
23
|
+
spec/simple_sinatra_server.rb
|
24
|
+
spec/acceptance/authorization_spec.rb
|
25
|
+
spec/acceptance/header_spec.rb
|
26
|
+
spec/acceptance/resource_spec.rb
|
27
|
+
spec/acceptance/caching_spec.rb
|
28
|
+
spec/acceptance/redirecting_spec.rb
|
29
|
+
spec/spec.opts
|
@@ -1,6 +1,4 @@
|
|
1
1
|
require 'resourceful/header'
|
2
|
-
require 'andand'
|
3
|
-
require 'facets/kernel/returning'
|
4
2
|
require 'digest/md5'
|
5
3
|
|
6
4
|
module Resourceful
|
@@ -72,9 +70,9 @@ module Resourceful
|
|
72
70
|
end
|
73
71
|
|
74
72
|
def lookup(request)
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
response = @collection[request.uri.to_s][request]
|
74
|
+
response.authoritative = false if response
|
75
|
+
response
|
78
76
|
end
|
79
77
|
|
80
78
|
def store(request, response)
|
@@ -104,9 +102,9 @@ module Resourceful
|
|
104
102
|
end
|
105
103
|
|
106
104
|
def lookup(request)
|
107
|
-
|
108
|
-
|
109
|
-
|
105
|
+
response = cache_entries_for(request)[request]
|
106
|
+
response.authoritative = false if response
|
107
|
+
response
|
110
108
|
end
|
111
109
|
|
112
110
|
def store(request, response)
|
@@ -161,7 +159,8 @@ module Resourceful
|
|
161
159
|
# @return [Resourceful::Response]
|
162
160
|
# The cached response for the specified request if one is available.
|
163
161
|
def [](request)
|
164
|
-
find { |
|
162
|
+
entry = find { |entry| entry.valid_for?(request) }
|
163
|
+
entry.response if entry
|
165
164
|
end
|
166
165
|
|
167
166
|
# Saves an entry into the collection. Replaces any existing ones that could
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require "resourceful/cache_manager"
|
2
2
|
|
3
3
|
require 'memcache'
|
4
|
-
require 'facets/kernel/returning'
|
5
4
|
|
6
5
|
module Resourceful
|
7
6
|
class MemcacheCacheManager < AbstractCacheManager
|
@@ -45,9 +44,10 @@ module Resourceful
|
|
45
44
|
def store(request, response)
|
46
45
|
return unless response.cachable?
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
entries = cache_entries_for(request)
|
48
|
+
entries[request] = response
|
49
|
+
|
50
|
+
@memcache[request.to_mc_key] = entries
|
51
51
|
end
|
52
52
|
|
53
53
|
# Invalidates a all cached entries for a uri.
|
data/lib/resourceful/response.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'time'
|
3
|
-
require 'rubygems'
|
4
|
-
require 'facets/kernel/ergo'
|
5
3
|
require 'zlib'
|
6
4
|
|
7
5
|
module Resourceful
|
@@ -86,7 +84,8 @@ module Resourceful
|
|
86
84
|
end
|
87
85
|
|
88
86
|
def body
|
89
|
-
|
87
|
+
encoding = header['Content-Encoding'] && header['Content-Encoding'].first
|
88
|
+
case encoding
|
90
89
|
when nil
|
91
90
|
# body is identity encoded; just return it
|
92
91
|
@body
|
@@ -97,7 +96,7 @@ module Resourceful
|
|
97
96
|
header.delete('Content-Encoding')
|
98
97
|
@body
|
99
98
|
else
|
100
|
-
raise UnsupportedContentCoding, "Resourceful does not support #{
|
99
|
+
raise UnsupportedContentCoding, "Resourceful does not support #{encoding} content coding"
|
101
100
|
end
|
102
101
|
end
|
103
102
|
|
data/lib/resourceful.rb
CHANGED
@@ -12,7 +12,7 @@ require 'resourceful/http_accessor'
|
|
12
12
|
|
13
13
|
# Resourceful is a library that provides a high level HTTP interface.
|
14
14
|
module Resourceful
|
15
|
-
VERSION = "0.5.
|
15
|
+
VERSION = "0.5.1"
|
16
16
|
RESOURCEFUL_USER_AGENT_TOKEN = "Resourceful/#{VERSION}(Ruby/#{RUBY_VERSION})"
|
17
17
|
|
18
18
|
end
|
data/resourceful.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{resourceful}
|
5
|
-
s.version = "0.5.
|
5
|
+
s.version = "0.5.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Paul Sadauskas"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-15}
|
10
10
|
s.description = %q{An HTTP library for Ruby that takes advantage of everything HTTP has to offer.}
|
11
11
|
s.email = %q{psadauskas@gmail.com}
|
12
|
-
s.extra_rdoc_files = ["
|
13
|
-
s.files = ["
|
12
|
+
s.extra_rdoc_files = ["lib/resourceful.rb", "lib/resourceful/net_http_adapter.rb", "lib/resourceful/stubbed_resource_proxy.rb", "lib/resourceful/header.rb", "lib/resourceful/memcache_cache_manager.rb", "lib/resourceful/response.rb", "lib/resourceful/util.rb", "lib/resourceful/options_interpreter.rb", "lib/resourceful/cache_manager.rb", "lib/resourceful/request.rb", "lib/resourceful/resource.rb", "lib/resourceful/exceptions.rb", "lib/resourceful/http_accessor.rb", "lib/resourceful/authentication_manager.rb", "README.markdown"]
|
13
|
+
s.files = ["lib/resourceful.rb", "lib/resourceful/net_http_adapter.rb", "lib/resourceful/stubbed_resource_proxy.rb", "lib/resourceful/header.rb", "lib/resourceful/memcache_cache_manager.rb", "lib/resourceful/response.rb", "lib/resourceful/util.rb", "lib/resourceful/options_interpreter.rb", "lib/resourceful/cache_manager.rb", "lib/resourceful/request.rb", "lib/resourceful/resource.rb", "lib/resourceful/exceptions.rb", "lib/resourceful/http_accessor.rb", "lib/resourceful/authentication_manager.rb", "README.markdown", "MIT-LICENSE", "Rakefile", "Manifest", "spec/simple_sinatra_server_spec.rb", "spec/old_acceptance_specs.rb", "spec/acceptance_shared_specs.rb", "spec/spec_helper.rb", "spec/simple_sinatra_server.rb", "spec/acceptance/authorization_spec.rb", "spec/acceptance/header_spec.rb", "spec/acceptance/resource_spec.rb", "spec/acceptance/caching_spec.rb", "spec/acceptance/redirecting_spec.rb", "spec/spec.opts", "resourceful.gemspec"]
|
14
14
|
s.homepage = %q{http://github.com/paul/resourceful}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Resourceful", "--main", "README.markdown"]
|
16
16
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resourceful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Sadauskas
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-15 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -99,52 +99,52 @@ executables: []
|
|
99
99
|
extensions: []
|
100
100
|
|
101
101
|
extra_rdoc_files:
|
102
|
-
-
|
103
|
-
- lib/resourceful/cache_manager.rb
|
104
|
-
- lib/resourceful/exceptions.rb
|
102
|
+
- lib/resourceful.rb
|
105
103
|
- lib/resourceful/net_http_adapter.rb
|
106
104
|
- lib/resourceful/stubbed_resource_proxy.rb
|
107
105
|
- lib/resourceful/header.rb
|
108
|
-
- lib/resourceful/
|
109
|
-
- lib/resourceful/request.rb
|
110
|
-
- lib/resourceful/resource.rb
|
106
|
+
- lib/resourceful/memcache_cache_manager.rb
|
111
107
|
- lib/resourceful/response.rb
|
112
108
|
- lib/resourceful/util.rb
|
113
|
-
- lib/resourceful/http_accessor.rb
|
114
109
|
- lib/resourceful/options_interpreter.rb
|
115
|
-
- lib/resourceful/memcache_cache_manager.rb
|
116
|
-
- lib/resourceful.rb
|
117
|
-
files:
|
118
|
-
- Manifest
|
119
|
-
- spec/spec.opts
|
120
|
-
- spec/simple_sinatra_server_spec.rb
|
121
|
-
- spec/simple_sinatra_server.rb
|
122
|
-
- spec/acceptance/header_spec.rb
|
123
|
-
- spec/acceptance/caching_spec.rb
|
124
|
-
- spec/acceptance/resource_spec.rb
|
125
|
-
- spec/acceptance/redirecting_spec.rb
|
126
|
-
- spec/acceptance/authorization_spec.rb
|
127
|
-
- spec/acceptance_shared_specs.rb
|
128
|
-
- spec/spec_helper.rb
|
129
|
-
- spec/old_acceptance_specs.rb
|
130
|
-
- README.markdown
|
131
|
-
- resourceful.gemspec
|
132
110
|
- lib/resourceful/cache_manager.rb
|
111
|
+
- lib/resourceful/request.rb
|
112
|
+
- lib/resourceful/resource.rb
|
133
113
|
- lib/resourceful/exceptions.rb
|
114
|
+
- lib/resourceful/http_accessor.rb
|
115
|
+
- lib/resourceful/authentication_manager.rb
|
116
|
+
- README.markdown
|
117
|
+
files:
|
118
|
+
- lib/resourceful.rb
|
134
119
|
- lib/resourceful/net_http_adapter.rb
|
135
120
|
- lib/resourceful/stubbed_resource_proxy.rb
|
136
121
|
- lib/resourceful/header.rb
|
137
|
-
- lib/resourceful/
|
138
|
-
- lib/resourceful/request.rb
|
139
|
-
- lib/resourceful/resource.rb
|
122
|
+
- lib/resourceful/memcache_cache_manager.rb
|
140
123
|
- lib/resourceful/response.rb
|
141
124
|
- lib/resourceful/util.rb
|
142
|
-
- lib/resourceful/http_accessor.rb
|
143
125
|
- lib/resourceful/options_interpreter.rb
|
144
|
-
- lib/resourceful/
|
145
|
-
- lib/resourceful.rb
|
146
|
-
-
|
126
|
+
- lib/resourceful/cache_manager.rb
|
127
|
+
- lib/resourceful/request.rb
|
128
|
+
- lib/resourceful/resource.rb
|
129
|
+
- lib/resourceful/exceptions.rb
|
130
|
+
- lib/resourceful/http_accessor.rb
|
131
|
+
- lib/resourceful/authentication_manager.rb
|
132
|
+
- README.markdown
|
147
133
|
- MIT-LICENSE
|
134
|
+
- Rakefile
|
135
|
+
- Manifest
|
136
|
+
- spec/simple_sinatra_server_spec.rb
|
137
|
+
- spec/old_acceptance_specs.rb
|
138
|
+
- spec/acceptance_shared_specs.rb
|
139
|
+
- spec/spec_helper.rb
|
140
|
+
- spec/simple_sinatra_server.rb
|
141
|
+
- spec/acceptance/authorization_spec.rb
|
142
|
+
- spec/acceptance/header_spec.rb
|
143
|
+
- spec/acceptance/resource_spec.rb
|
144
|
+
- spec/acceptance/caching_spec.rb
|
145
|
+
- spec/acceptance/redirecting_spec.rb
|
146
|
+
- spec/spec.opts
|
147
|
+
- resourceful.gemspec
|
148
148
|
has_rdoc: true
|
149
149
|
homepage: http://github.com/paul/resourceful
|
150
150
|
licenses: []
|