resourceful 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +1 -0
- data/lib/resourceful.rb +1 -1
- data/lib/resourceful/resource.rb +13 -13
- data/lib/resourceful/simple.rb +1 -1
- data/resourceful.gemspec +2 -2
- data/spec/acceptance/resourceful_spec.rb +56 -0
- metadata +2 -1
data/Manifest
CHANGED
@@ -26,6 +26,7 @@ spec/acceptance/caching_spec.rb
|
|
26
26
|
spec/acceptance/header_spec.rb
|
27
27
|
spec/acceptance/redirecting_spec.rb
|
28
28
|
spec/acceptance/resource_spec.rb
|
29
|
+
spec/acceptance/resourceful_spec.rb
|
29
30
|
spec/acceptance_shared_specs.rb
|
30
31
|
spec/caching_spec.rb
|
31
32
|
spec/old_acceptance_specs.rb
|
data/lib/resourceful.rb
CHANGED
data/lib/resourceful/resource.rb
CHANGED
@@ -135,6 +135,19 @@ module Resourceful
|
|
135
135
|
accessor.logger
|
136
136
|
end
|
137
137
|
|
138
|
+
# Actually make the request
|
139
|
+
def request(method, data, header)
|
140
|
+
header = default_header.merge(header)
|
141
|
+
ensure_content_type(data, header) if data
|
142
|
+
|
143
|
+
data = StringIO.new(data) if data.kind_of?(String)
|
144
|
+
|
145
|
+
log_request_with_time "#{method.to_s.upcase} [#{uri}]" do
|
146
|
+
request = Request.new(method, self, data, header)
|
147
|
+
request.fetch_response
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
138
151
|
private
|
139
152
|
|
140
153
|
# Ensures that the request has a content type header
|
@@ -152,19 +165,6 @@ module Resourceful
|
|
152
165
|
raise MissingContentType
|
153
166
|
end
|
154
167
|
|
155
|
-
# Actually make the request
|
156
|
-
def request(method, data, header)
|
157
|
-
header = default_header.merge(header)
|
158
|
-
ensure_content_type(data, header) if data
|
159
|
-
|
160
|
-
data = StringIO.new(data) if data.kind_of?(String)
|
161
|
-
|
162
|
-
log_request_with_time "#{method.to_s.upcase} [#{uri}]" do
|
163
|
-
request = Request.new(method, self, data, header)
|
164
|
-
request.fetch_response
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
168
|
# Log it took the time to make the request
|
169
169
|
def log_request_with_time(msg, indent = 2)
|
170
170
|
logger.info(" " * indent + msg)
|
data/lib/resourceful/simple.rb
CHANGED
data/resourceful.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{resourceful}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.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"]
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
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
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"]
|
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/resourceful_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"]
|
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
3
|
+
require 'resourceful'
|
4
|
+
|
5
|
+
describe Resourceful do
|
6
|
+
|
7
|
+
describe ".get()" do
|
8
|
+
it "should be performable on a resource and return a response" do
|
9
|
+
response = Resourceful.get('http://localhost:42682/')
|
10
|
+
response.should be_kind_of(Resourceful::Response)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".post()" do
|
15
|
+
it "should be performable on a resource and return a response" do
|
16
|
+
response = Resourceful.post('http://localhost:42682/')
|
17
|
+
response.should be_kind_of(Resourceful::Response)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should require Content-Type be set if a body is provided" do
|
21
|
+
lambda {
|
22
|
+
Resourceful.post('http://localhost:42682/', {}, 'body')
|
23
|
+
}.should raise_error(Resourceful::MissingContentType)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".put()" do
|
29
|
+
|
30
|
+
it "should be performable on a resource and return a response" do
|
31
|
+
response = Resourceful.put('http://localhost:42682/')
|
32
|
+
response.should be_kind_of(Resourceful::Response)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should require Content-Type be set if a body is provided" do
|
36
|
+
lambda {
|
37
|
+
Resourceful.put('http://localhost:42682/', "some text", {})
|
38
|
+
}.should raise_error(Resourceful::MissingContentType)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should allow the entity-body to be nil" do
|
42
|
+
lambda {
|
43
|
+
Resourceful.put('http://localhost:42682/', nil, {})
|
44
|
+
}.should_not raise_error(ArgumentError)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe ".delete()" do
|
49
|
+
|
50
|
+
it "should be performable on a resource and return a response" do
|
51
|
+
response = Resourceful.delete('http://localhost:42682/')
|
52
|
+
response.should be_kind_of(Resourceful::Response)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Sadauskas
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- spec/acceptance/header_spec.rb
|
137
137
|
- spec/acceptance/redirecting_spec.rb
|
138
138
|
- spec/acceptance/resource_spec.rb
|
139
|
+
- spec/acceptance/resourceful_spec.rb
|
139
140
|
- spec/acceptance_shared_specs.rb
|
140
141
|
- spec/caching_spec.rb
|
141
142
|
- spec/old_acceptance_specs.rb
|