resourceful 0.6.4 → 1.0.0
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/History.txt +5 -0
- data/Manifest +7 -5
- data/README.markdown +5 -6
- data/Rakefile +1 -1
- data/lib/resourceful.rb +4 -1
- data/lib/resourceful/cache_manager.rb +5 -3
- data/lib/resourceful/header.rb +9 -2
- data/lib/resourceful/resource.rb +12 -15
- data/lib/resourceful/response.rb +2 -0
- data/lib/resourceful/simple.rb +36 -0
- data/resourceful.gemspec +7 -7
- data/spec/resourceful_spec.rb +79 -0
- metadata +13 -10
data/History.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 1.0.0
|
2
|
+
============
|
3
|
+
* Added .request() convenience method to Resourceful module.
|
4
|
+
* Added .get(), .post(), .put(), .delete() and .head() convenience method to Resourceful module
|
5
|
+
|
1
6
|
Version 0.7.0
|
2
7
|
=============
|
3
8
|
* Multiple values in a single header field are treated the same as repeated header fields. (Peter Williams)
|
data/Manifest
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
History.txt
|
2
|
+
MIT-LICENSE
|
3
|
+
Manifest
|
4
|
+
README.markdown
|
5
|
+
Rakefile
|
6
|
+
lib/resourceful.rb
|
2
7
|
lib/resourceful/abstract_form_data.rb
|
3
8
|
lib/resourceful/authentication_manager.rb
|
4
9
|
lib/resourceful/cache_manager.rb
|
@@ -11,14 +16,10 @@ lib/resourceful/net_http_adapter.rb
|
|
11
16
|
lib/resourceful/request.rb
|
12
17
|
lib/resourceful/resource.rb
|
13
18
|
lib/resourceful/response.rb
|
19
|
+
lib/resourceful/simple.rb
|
14
20
|
lib/resourceful/stubbed_resource_proxy.rb
|
15
21
|
lib/resourceful/urlencoded_form_data.rb
|
16
22
|
lib/resourceful/util.rb
|
17
|
-
lib/resourceful.rb
|
18
|
-
Manifest
|
19
|
-
MIT-LICENSE
|
20
|
-
Rakefile
|
21
|
-
README.markdown
|
22
23
|
resourceful.gemspec
|
23
24
|
spec/acceptance/authorization_spec.rb
|
24
25
|
spec/acceptance/caching_spec.rb
|
@@ -34,6 +35,7 @@ spec/resourceful/multipart_form_data_spec.rb
|
|
34
35
|
spec/resourceful/resource_spec.rb
|
35
36
|
spec/resourceful/response_spec.rb
|
36
37
|
spec/resourceful/urlencoded_form_data_spec.rb
|
38
|
+
spec/resourceful_spec.rb
|
37
39
|
spec/simple_sinatra_server.rb
|
38
40
|
spec/simple_sinatra_server_spec.rb
|
39
41
|
spec/spec.opts
|
data/README.markdown
CHANGED
@@ -12,7 +12,7 @@ Features:
|
|
12
12
|
|
13
13
|
More Info
|
14
14
|
=========
|
15
|
-
|
15
|
+
|
16
16
|
* Source: [Github](http://github.com/paul/resourceful/tree/master)
|
17
17
|
* Bug Tracking: [Lighthouse](http://resourceful.lighthouseapp.com)
|
18
18
|
* Project Page: [Rubyforge](http://rubyforge.org/projects/resourceful/)
|
@@ -30,8 +30,7 @@ Simplest example
|
|
30
30
|
---------------
|
31
31
|
|
32
32
|
require 'resourceful'
|
33
|
-
|
34
|
-
resp = http.resource('http://rubyforge.org').get
|
33
|
+
resp = Resourceful.get('http://rubyforge.org')
|
35
34
|
puts resp.body
|
36
35
|
|
37
36
|
Get a page requiring HTTP Authentication
|
@@ -45,7 +44,7 @@ Get a page requiring HTTP Authentication
|
|
45
44
|
Redirection based on callback results
|
46
45
|
-------------------------------------
|
47
46
|
|
48
|
-
Resourceful will by default follow redirects on read requests (GET and HEAD), but not for
|
47
|
+
Resourceful will by default follow redirects on read requests (GET and HEAD), but not for
|
49
48
|
POST, etc. If you want to follow a redirect after a post, you will need to set the resource#on_redirect
|
50
49
|
callback. If the callback evaluates to true, it will follow the redirect.
|
51
50
|
|
@@ -58,7 +57,7 @@ Post a URL encoded form
|
|
58
57
|
|
59
58
|
require 'resourceful'
|
60
59
|
http = Resourceful::HttpAccessor.new
|
61
|
-
resp = http.resource('http://mysite.example/service').
|
60
|
+
resp = http.resource('http://mysite.example/service').
|
62
61
|
post(Resourceful::UrlencodedFormData.new(:hostname => 'test', :level => 'super'))
|
63
62
|
|
64
63
|
Post a Mulitpart form with a file
|
@@ -77,7 +76,7 @@ Put an XML document
|
|
77
76
|
http = Resourceful::HttpAccessor.new
|
78
77
|
resp = http.resource('http://mysite.example/service').
|
79
78
|
put('<?xml version="1.0"?><test/>', :content_type => 'application/xml')
|
80
|
-
|
79
|
+
|
81
80
|
Delete a resource
|
82
81
|
-----------------
|
83
82
|
|
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ begin
|
|
12
12
|
p.email = "psadauskas@gmail.com"
|
13
13
|
|
14
14
|
p.ignore_pattern = ["pkg/*", "tmp/*"]
|
15
|
-
p.dependencies = [['addressable', '>= 2.1.0'], 'httpauth', ['options', '>= 2.1.
|
15
|
+
p.dependencies = [['addressable', '>= 2.1.0'], 'httpauth', ['options', '>= 2.1.1']]
|
16
16
|
p.development_dependencies = ['thin', 'yard', 'sinatra', 'rspec']
|
17
17
|
p.retain_gemspec = true
|
18
18
|
end
|
data/lib/resourceful.rb
CHANGED
@@ -9,15 +9,18 @@ require 'resourceful/util'
|
|
9
9
|
|
10
10
|
require 'resourceful/header'
|
11
11
|
require 'resourceful/http_accessor'
|
12
|
+
require 'resourceful/simple'
|
12
13
|
|
13
14
|
module Resourceful
|
14
15
|
autoload :MultipartFormData, 'resourceful/multipart_form_data'
|
15
16
|
autoload :UrlencodedFormData, 'resourceful/urlencoded_form_data'
|
16
17
|
autoload :StubbedResourceProxy, 'resourceful/stubbed_resource_proxy'
|
18
|
+
|
19
|
+
extend Simple
|
17
20
|
end
|
18
21
|
|
19
22
|
# Resourceful is a library that provides a high level HTTP interface.
|
20
23
|
module Resourceful
|
21
|
-
VERSION = "0.
|
24
|
+
VERSION = "1.0.0"
|
22
25
|
RESOURCEFUL_USER_AGENT_TOKEN = "Resourceful/#{VERSION}(Ruby/#{RUBY_VERSION})"
|
23
26
|
end
|
@@ -150,7 +150,7 @@ module Resourceful
|
|
150
150
|
@entries.each(&block)
|
151
151
|
end
|
152
152
|
|
153
|
-
# Looks
|
153
|
+
# Looks for an Entry that could fullfil the request. Returns nil if none
|
154
154
|
# was found.
|
155
155
|
#
|
156
156
|
# @param [Resourceful::Request] request
|
@@ -215,7 +215,9 @@ module Resourceful
|
|
215
215
|
# The request to do the lookup on.
|
216
216
|
def valid_for?(request)
|
217
217
|
request.uri == @request_uri and
|
218
|
-
@request_vary_headers.all? {|key, value|
|
218
|
+
@request_vary_headers.all? {|key, value|
|
219
|
+
request.header[key] == value
|
220
|
+
}
|
219
221
|
end
|
220
222
|
|
221
223
|
# Selects the headers from the request named by the response's Vary header
|
@@ -229,7 +231,7 @@ module Resourceful
|
|
229
231
|
header = Resourceful::Header.new
|
230
232
|
|
231
233
|
response.header['Vary'].each do |name|
|
232
|
-
header[name] = request.header[name]
|
234
|
+
header[name] = request.header[name] if request.header[name]
|
233
235
|
end if response.header['Vary']
|
234
236
|
|
235
237
|
header
|
data/lib/resourceful/header.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'options'
|
2
2
|
require 'set'
|
3
|
-
require 'facets/memoize'
|
4
3
|
|
5
4
|
# Represents the header fields of an HTTP message. To access a field
|
6
5
|
# you can use `#[]` and `#[]=`. For example, to get the content type
|
@@ -51,6 +50,10 @@ module Resourceful
|
|
51
50
|
field_def(k).set_to(v, @raw_fields)
|
52
51
|
end
|
53
52
|
|
53
|
+
def delete(k)
|
54
|
+
field_def(k).delete(@raw_fields)
|
55
|
+
end
|
56
|
+
|
54
57
|
def has_key?(k)
|
55
58
|
field_def(k).exists_in?(@raw_fields)
|
56
59
|
end
|
@@ -160,6 +163,10 @@ module Resourceful
|
|
160
163
|
end
|
161
164
|
end
|
162
165
|
|
166
|
+
def delete(raw_fields_hash)
|
167
|
+
raw_fields_hash.delete(name)
|
168
|
+
end
|
169
|
+
|
163
170
|
def exists_in?(raw_fields_hash)
|
164
171
|
raw_fields_hash.has_key?(name)
|
165
172
|
end
|
@@ -182,7 +189,7 @@ module Resourceful
|
|
182
189
|
end
|
183
190
|
|
184
191
|
def name_pattern
|
185
|
-
@name_pattern
|
192
|
+
@name_pattern ||= Regexp.new('^' + name.gsub('-', '[_-]') + '$', Regexp::IGNORECASE)
|
186
193
|
end
|
187
194
|
|
188
195
|
def methodized_name
|
data/lib/resourceful/resource.rb
CHANGED
@@ -8,9 +8,9 @@ module Resourceful
|
|
8
8
|
|
9
9
|
# Build a new resource for a uri
|
10
10
|
#
|
11
|
-
# @param accessor<HttpAccessor>
|
11
|
+
# @param accessor<HttpAccessor>
|
12
12
|
# The parent http accessor
|
13
|
-
# @param uri<String, Addressable::URI>
|
13
|
+
# @param uri<String, Addressable::URI>
|
14
14
|
# The uri for the location of the resource
|
15
15
|
def initialize(accessor, uri, default_header = {})
|
16
16
|
@accessor, @uris = accessor, [uri]
|
@@ -22,7 +22,7 @@ module Resourceful
|
|
22
22
|
# used to create the resource, but in the case of a permanent redirect, this
|
23
23
|
# will always reflect the lastest uri.
|
24
24
|
#
|
25
|
-
# @return Addressable::URI
|
25
|
+
# @return Addressable::URI
|
26
26
|
# The current uri of the resource
|
27
27
|
def effective_uri
|
28
28
|
@uris.first
|
@@ -55,10 +55,10 @@ module Resourceful
|
|
55
55
|
# end
|
56
56
|
#
|
57
57
|
# @yieldparam callback<request, response>
|
58
|
-
# The action to be executed when a request results in a redirect. Yields the
|
58
|
+
# The action to be executed when a request results in a redirect. Yields the
|
59
59
|
# current request and result objects to the callback.
|
60
60
|
#
|
61
|
-
# @raise ArgumentError if called without a block
|
61
|
+
# @raise ArgumentError if called without a block
|
62
62
|
def on_redirect(&callback)
|
63
63
|
if block_given?
|
64
64
|
@on_redirect = callback
|
@@ -84,7 +84,7 @@ module Resourceful
|
|
84
84
|
# :call-seq:
|
85
85
|
# post(data = "", :content_type => mime_type)
|
86
86
|
#
|
87
|
-
# Performs a POST with the given data to the resource, following redirects as
|
87
|
+
# Performs a POST with the given data to the resource, following redirects as
|
88
88
|
# neccessary.
|
89
89
|
#
|
90
90
|
# @param [String] data
|
@@ -104,7 +104,7 @@ module Resourceful
|
|
104
104
|
# :call-seq:
|
105
105
|
# put(data = "", :content_type => mime_type)
|
106
106
|
#
|
107
|
-
# Performs a PUT with the given data to the resource, following redirects as
|
107
|
+
# Performs a PUT with the given data to the resource, following redirects as
|
108
108
|
# neccessary.
|
109
109
|
#
|
110
110
|
# @param [String] data
|
@@ -139,14 +139,14 @@ module Resourceful
|
|
139
139
|
|
140
140
|
# Ensures that the request has a content type header
|
141
141
|
def ensure_content_type(body, header)
|
142
|
-
return if header.has_key?('Content-Type')
|
143
|
-
|
142
|
+
return if header.has_key?('Content-Type')
|
143
|
+
|
144
144
|
if body.respond_to?(:content_type)
|
145
145
|
header['Content-Type'] = body.content_type
|
146
146
|
return
|
147
147
|
end
|
148
|
-
|
149
|
-
return if default_header.has_key?('Content-Type')
|
148
|
+
|
149
|
+
return if default_header.has_key?('Content-Type')
|
150
150
|
|
151
151
|
# could not figure it out
|
152
152
|
raise MissingContentType
|
@@ -159,10 +159,7 @@ module Resourceful
|
|
159
159
|
|
160
160
|
data = StringIO.new(data) if data.kind_of?(String)
|
161
161
|
|
162
|
-
|
163
|
-
logger.debug { data = StringIO.new(data.read); data.string } if data
|
164
|
-
|
165
|
-
log_request_with_time "#{method.to_s.upcase} [#{uri}]" do
|
162
|
+
log_request_with_time "#{method.to_s.upcase} [#{uri}]" do
|
166
163
|
request = Request.new(method, self, data, header)
|
167
164
|
request.fetch_response
|
168
165
|
end
|
data/lib/resourceful/response.rb
CHANGED
@@ -82,7 +82,9 @@ module Resourceful
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def body
|
85
|
+
raise(NotImplementedError, 'Chained encodings are not supported') if header['Content-Encoding'] && header['Content-Encoding'].length > 1
|
85
86
|
encoding = header['Content-Encoding'] && header['Content-Encoding'].first
|
87
|
+
|
86
88
|
case encoding
|
87
89
|
when nil
|
88
90
|
# body is identity encoded; just return it
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Resourceful
|
2
|
+
module Simple
|
3
|
+
def request(method, uri, header = {}, data =nil)
|
4
|
+
default_accessor.resource(uri).request(method, data, header)
|
5
|
+
end
|
6
|
+
|
7
|
+
def default_accessor
|
8
|
+
@default_accessor ||= Resourceful::HttpAccessor.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_authenticator(an_authenticator)
|
12
|
+
default_accessor.add_authenticator(an_authenticator)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(uri, header = {})
|
16
|
+
request(:get, uri, header)
|
17
|
+
end
|
18
|
+
|
19
|
+
def head(uri, header = {})
|
20
|
+
request(:head, uri, header)
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete(uri, header = {})
|
24
|
+
request(:delete, uri, header)
|
25
|
+
end
|
26
|
+
|
27
|
+
def post(uri, data = nil, header = {})
|
28
|
+
request(:post, uri, header, data)
|
29
|
+
end
|
30
|
+
|
31
|
+
def put(uri, data = nil, header = {})
|
32
|
+
request(:put, uri, header, data)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
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
|
+
s.version = "1.0.0"
|
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{
|
9
|
+
s.date = %q{2010-01-26}
|
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 = ["lib/resourceful/abstract_form_data.rb", "lib/resourceful/authentication_manager.rb", "lib/resourceful/cache_manager.rb", "lib/resourceful/exceptions.rb", "lib/resourceful/header.rb", "lib/resourceful/http_accessor.rb", "lib/resourceful/memcache_cache_manager.rb", "lib/resourceful/multipart_form_data.rb", "lib/resourceful/net_http_adapter.rb", "lib/resourceful/request.rb", "lib/resourceful/resource.rb", "lib/resourceful/response.rb", "lib/resourceful/
|
13
|
-
s.files = ["History.txt", "lib/resourceful/abstract_form_data.rb", "lib/resourceful/authentication_manager.rb", "lib/resourceful/cache_manager.rb", "lib/resourceful/exceptions.rb", "lib/resourceful/header.rb", "lib/resourceful/http_accessor.rb", "lib/resourceful/memcache_cache_manager.rb", "lib/resourceful/multipart_form_data.rb", "lib/resourceful/net_http_adapter.rb", "lib/resourceful/request.rb", "lib/resourceful/resource.rb", "lib/resourceful/response.rb", "lib/resourceful/
|
12
|
+
s.extra_rdoc_files = ["README.markdown", "lib/resourceful.rb", "lib/resourceful/abstract_form_data.rb", "lib/resourceful/authentication_manager.rb", "lib/resourceful/cache_manager.rb", "lib/resourceful/exceptions.rb", "lib/resourceful/header.rb", "lib/resourceful/http_accessor.rb", "lib/resourceful/memcache_cache_manager.rb", "lib/resourceful/multipart_form_data.rb", "lib/resourceful/net_http_adapter.rb", "lib/resourceful/request.rb", "lib/resourceful/resource.rb", "lib/resourceful/response.rb", "lib/resourceful/simple.rb", "lib/resourceful/stubbed_resource_proxy.rb", "lib/resourceful/urlencoded_form_data.rb", "lib/resourceful/util.rb"]
|
13
|
+
s.files = ["History.txt", "MIT-LICENSE", "Manifest", "README.markdown", "Rakefile", "lib/resourceful.rb", "lib/resourceful/abstract_form_data.rb", "lib/resourceful/authentication_manager.rb", "lib/resourceful/cache_manager.rb", "lib/resourceful/exceptions.rb", "lib/resourceful/header.rb", "lib/resourceful/http_accessor.rb", "lib/resourceful/memcache_cache_manager.rb", "lib/resourceful/multipart_form_data.rb", "lib/resourceful/net_http_adapter.rb", "lib/resourceful/request.rb", "lib/resourceful/resource.rb", "lib/resourceful/response.rb", "lib/resourceful/simple.rb", "lib/resourceful/stubbed_resource_proxy.rb", "lib/resourceful/urlencoded_form_data.rb", "lib/resourceful/util.rb", "resourceful.gemspec", "spec/acceptance/authorization_spec.rb", "spec/acceptance/caching_spec.rb", "spec/acceptance/header_spec.rb", "spec/acceptance/redirecting_spec.rb", "spec/acceptance/resource_spec.rb", "spec/acceptance_shared_specs.rb", "spec/caching_spec.rb", "spec/old_acceptance_specs.rb", "spec/resourceful/header_spec.rb", "spec/resourceful/http_accessor_spec.rb", "spec/resourceful/multipart_form_data_spec.rb", "spec/resourceful/resource_spec.rb", "spec/resourceful/response_spec.rb", "spec/resourceful/urlencoded_form_data_spec.rb", "spec/resourceful_spec.rb", "spec/simple_sinatra_server.rb", "spec/simple_sinatra_server_spec.rb", "spec/spec.opts", "spec/spec_helper.rb"]
|
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"]
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
26
|
s.add_runtime_dependency(%q<addressable>, [">= 2.1.0"])
|
27
27
|
s.add_runtime_dependency(%q<httpauth>, [">= 0"])
|
28
|
-
s.add_runtime_dependency(%q<options>, [">= 2.1.
|
28
|
+
s.add_runtime_dependency(%q<options>, [">= 2.1.1"])
|
29
29
|
s.add_development_dependency(%q<thin>, [">= 0"])
|
30
30
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
31
31
|
s.add_development_dependency(%q<sinatra>, [">= 0"])
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
else
|
34
34
|
s.add_dependency(%q<addressable>, [">= 2.1.0"])
|
35
35
|
s.add_dependency(%q<httpauth>, [">= 0"])
|
36
|
-
s.add_dependency(%q<options>, [">= 2.1.
|
36
|
+
s.add_dependency(%q<options>, [">= 2.1.1"])
|
37
37
|
s.add_dependency(%q<thin>, [">= 0"])
|
38
38
|
s.add_dependency(%q<yard>, [">= 0"])
|
39
39
|
s.add_dependency(%q<sinatra>, [">= 0"])
|
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
else
|
43
43
|
s.add_dependency(%q<addressable>, [">= 2.1.0"])
|
44
44
|
s.add_dependency(%q<httpauth>, [">= 0"])
|
45
|
-
s.add_dependency(%q<options>, [">= 2.1.
|
45
|
+
s.add_dependency(%q<options>, [">= 2.1.1"])
|
46
46
|
s.add_dependency(%q<thin>, [">= 0"])
|
47
47
|
s.add_dependency(%q<yard>, [">= 0"])
|
48
48
|
s.add_dependency(%q<sinatra>, [">= 0"])
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/spec_helper.rb"
|
2
|
+
|
3
|
+
|
4
|
+
describe Resourceful do
|
5
|
+
it "should have a default accessor" do
|
6
|
+
Resourceful.default_accessor.should be_kind_of Resourceful::HttpAccessor
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should delegate request making (minimal)" do
|
10
|
+
stub_resource = mock(:resource)
|
11
|
+
Resourceful.default_accessor.should_receive(:resource).with( 'http://foo.invalid/bar').and_return(stub_resource)
|
12
|
+
stub_resource.should_receive(:request).with(:get, nil, {})
|
13
|
+
|
14
|
+
Resourceful.request(:get, 'http://foo.invalid/bar')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should delegate request making (with header)" do
|
18
|
+
stub_resource = mock(:resource)
|
19
|
+
Resourceful.default_accessor.should_receive(:resource).with( 'http://foo.invalid/bar').and_return(stub_resource)
|
20
|
+
stub_resource.should_receive(:request).with(:get, nil, {:accept => :json})
|
21
|
+
|
22
|
+
Resourceful.request(:get, 'http://foo.invalid/bar', :accept => :json)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should delegate request making (with body)" do
|
26
|
+
stub_resource = mock(:resource)
|
27
|
+
Resourceful.default_accessor.should_receive(:resource).with( 'http://foo.invalid/bar').and_return(stub_resource)
|
28
|
+
stub_resource.should_receive(:request).with(:get, 'body', {})
|
29
|
+
|
30
|
+
Resourceful.request(:get, 'http://foo.invalid/bar', {}, 'body')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should allow convenient get requests" do
|
34
|
+
stub_resource = mock(:resource)
|
35
|
+
Resourceful.default_accessor.should_receive(:resource).with( 'http://foo.invalid/bar').and_return(stub_resource)
|
36
|
+
stub_resource.should_receive(:request).with(:get, nil, :header_marker)
|
37
|
+
|
38
|
+
Resourceful.get 'http://foo.invalid/bar', :header_marker
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should allow convenient head requests" do
|
42
|
+
stub_resource = mock(:resource)
|
43
|
+
Resourceful.default_accessor.should_receive(:resource).with( 'http://foo.invalid/bar').and_return(stub_resource)
|
44
|
+
stub_resource.should_receive(:request).with(:head, nil, :header_marker)
|
45
|
+
|
46
|
+
Resourceful.head 'http://foo.invalid/bar', :header_marker
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should allow convenient delete requests" do
|
50
|
+
stub_resource = mock(:resource)
|
51
|
+
Resourceful.default_accessor.should_receive(:resource).with( 'http://foo.invalid/bar').and_return(stub_resource)
|
52
|
+
stub_resource.should_receive(:request).with(:delete, nil, :header_marker)
|
53
|
+
|
54
|
+
Resourceful.delete 'http://foo.invalid/bar', :header_marker
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should allow convenient post requests" do
|
58
|
+
stub_resource = mock(:resource)
|
59
|
+
Resourceful.default_accessor.should_receive(:resource).with( 'http://foo.invalid/bar').and_return(stub_resource)
|
60
|
+
stub_resource.should_receive(:request).with(:post, :body_marker, :header_marker)
|
61
|
+
|
62
|
+
Resourceful.post 'http://foo.invalid/bar', :body_marker, :header_marker
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should allow convenient put requests" do
|
66
|
+
stub_resource = mock(:resource)
|
67
|
+
Resourceful.default_accessor.should_receive(:resource).with( 'http://foo.invalid/bar').and_return(stub_resource)
|
68
|
+
stub_resource.should_receive(:request).with(:put, :body_marker, :header_marker)
|
69
|
+
|
70
|
+
Resourceful.put 'http://foo.invalid/bar', :body_marker, :header_marker
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
it "should allow new authenticators to be added to default accessor" do
|
75
|
+
Resourceful.default_accessor.should_receive(:add_authenticator).with(:my_authentcator_marker)
|
76
|
+
|
77
|
+
Resourceful.add_authenticator(:my_authentcator_marker)
|
78
|
+
end
|
79
|
+
end
|
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.
|
4
|
+
version: 1.0.0
|
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:
|
12
|
+
date: 2010-01-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.1.
|
43
|
+
version: 2.1.1
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: thin
|
@@ -89,6 +89,8 @@ executables: []
|
|
89
89
|
extensions: []
|
90
90
|
|
91
91
|
extra_rdoc_files:
|
92
|
+
- README.markdown
|
93
|
+
- lib/resourceful.rb
|
92
94
|
- lib/resourceful/abstract_form_data.rb
|
93
95
|
- lib/resourceful/authentication_manager.rb
|
94
96
|
- lib/resourceful/cache_manager.rb
|
@@ -101,13 +103,17 @@ extra_rdoc_files:
|
|
101
103
|
- lib/resourceful/request.rb
|
102
104
|
- lib/resourceful/resource.rb
|
103
105
|
- lib/resourceful/response.rb
|
106
|
+
- lib/resourceful/simple.rb
|
104
107
|
- lib/resourceful/stubbed_resource_proxy.rb
|
105
108
|
- lib/resourceful/urlencoded_form_data.rb
|
106
109
|
- lib/resourceful/util.rb
|
107
|
-
- lib/resourceful.rb
|
108
|
-
- README.markdown
|
109
110
|
files:
|
110
111
|
- History.txt
|
112
|
+
- MIT-LICENSE
|
113
|
+
- Manifest
|
114
|
+
- README.markdown
|
115
|
+
- Rakefile
|
116
|
+
- lib/resourceful.rb
|
111
117
|
- lib/resourceful/abstract_form_data.rb
|
112
118
|
- lib/resourceful/authentication_manager.rb
|
113
119
|
- lib/resourceful/cache_manager.rb
|
@@ -120,14 +126,10 @@ files:
|
|
120
126
|
- lib/resourceful/request.rb
|
121
127
|
- lib/resourceful/resource.rb
|
122
128
|
- lib/resourceful/response.rb
|
129
|
+
- lib/resourceful/simple.rb
|
123
130
|
- lib/resourceful/stubbed_resource_proxy.rb
|
124
131
|
- lib/resourceful/urlencoded_form_data.rb
|
125
132
|
- lib/resourceful/util.rb
|
126
|
-
- lib/resourceful.rb
|
127
|
-
- Manifest
|
128
|
-
- MIT-LICENSE
|
129
|
-
- Rakefile
|
130
|
-
- README.markdown
|
131
133
|
- resourceful.gemspec
|
132
134
|
- spec/acceptance/authorization_spec.rb
|
133
135
|
- spec/acceptance/caching_spec.rb
|
@@ -143,6 +145,7 @@ files:
|
|
143
145
|
- spec/resourceful/resource_spec.rb
|
144
146
|
- spec/resourceful/response_spec.rb
|
145
147
|
- spec/resourceful/urlencoded_form_data_spec.rb
|
148
|
+
- spec/resourceful_spec.rb
|
146
149
|
- spec/simple_sinatra_server.rb
|
147
150
|
- spec/simple_sinatra_server_spec.rb
|
148
151
|
- spec/spec.opts
|