wrest 1.2.1-universal-java-1.6 → 1.3.0-universal-java-1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/README.rdoc +12 -1
- data/lib/wrest/multipart.rb +29 -0
- data/lib/wrest/uri.rb +74 -0
- data/lib/wrest/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -2,6 +2,9 @@ Features under the section marked 'Current' are completed but pending release as
|
|
2
2
|
|
3
3
|
Features under a numbered section are complete and available in the Wrest gem.
|
4
4
|
|
5
|
+
=== 1.3.0
|
6
|
+
* GH#95 Asynchronous requests on Wrest::Uri.
|
7
|
+
|
5
8
|
== 1.2.1
|
6
9
|
* GH#91 Remove dependency on tzinfo
|
7
10
|
|
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Wrest 1.
|
1
|
+
= Wrest 1.3.0
|
2
2
|
|
3
3
|
(c) Copyright 2009-2011 {Sidu Ponnappa}[http://blog.sidu.in]. All Rights Reserved.
|
4
4
|
|
@@ -156,6 +156,17 @@ You can also define callbacks that are invoked based on the http code of the res
|
|
156
156
|
|
157
157
|
Please note that Wrest is a synchronous library. All requests are blocking, and will not return till the request is completed and appropriate callbacks executed.
|
158
158
|
|
159
|
+
=== Asynchronous requests
|
160
|
+
|
161
|
+
Asynchronous requests are non-blocking. They do not return a response and the request is executed on a separate thread. The only way to access the response
|
162
|
+
while using asynchronous request is through callbacks.
|
163
|
+
|
164
|
+
"http://www.google.com".to_uri.get_async do |callback|
|
165
|
+
callback.on_ok do |response|
|
166
|
+
Wrest.logger.info "Ok."
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
159
170
|
=== Other useful stuff
|
160
171
|
|
161
172
|
Allows any class to hold an attributes hash, somewhat like ActiveResource. It also supports several extensions to this base fuctionality such as support for typecasting attribute values. See examples/twitter.rb and examples/wow_realm_status.rb for more samples.
|
data/lib/wrest/multipart.rb
CHANGED
@@ -37,12 +37,41 @@ module Wrest
|
|
37
37
|
def post_multipart(parameters = {}, headers = {}, &block)
|
38
38
|
Http::PostMultipart.new(self, parameters, headers, block ? @options.merge(:callback_block => block) : @options).invoke
|
39
39
|
end
|
40
|
+
|
41
|
+
# Makes a multipart/form-data encoded POST request to this URI. This is a convenience API
|
42
|
+
# that mimics a multipart form being posted; some allegedly RESTful APIs like FCBK require
|
43
|
+
# this for file uploads.
|
44
|
+
#
|
45
|
+
# File.open('/path/to/image.jpg') do |file|
|
46
|
+
# 'http://localhost:3000/uploads'.to_uri.post_multipart_async('file' => UploadIO.new(file, "image/jpg", '/path/to/image.jpg'))
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# Note: post_multipart_async does not return a response and the response should be accessed through callbacks
|
50
|
+
# This implementation of asynchronous post_multipart is very naive and should not be used in production.
|
51
|
+
# Stable implementation of asynchronous requests involving thread pools would be out soon.
|
52
|
+
def post_multipart_async(parameters = {}, headers = {}, &block)
|
53
|
+
Thread.new do
|
54
|
+
post_multipart(parameters, headers, &block)
|
55
|
+
end
|
56
|
+
end
|
40
57
|
|
41
58
|
# Makes a multipart/form-data encoded PUT request to this URI. This is a convenience API
|
42
59
|
# that mimics a multipart form being put. I sincerely hope you never need to use this.
|
43
60
|
def put_multipart(parameters = {}, headers = {}, &block)
|
44
61
|
Http::PutMultipart.new(self, parameters, headers, block ? @options.merge(:callback_block => block) : @options).invoke
|
45
62
|
end
|
63
|
+
|
64
|
+
# Makes a multipart/form-data encoded PUT request to this URI. This is a convenience API
|
65
|
+
# that mimics a multipart form being put. I sincerely hope you never need to use this.
|
66
|
+
#
|
67
|
+
# Note: put_multipart_async does not return a response and the response should be accessed through callbacks
|
68
|
+
# This implementation of asynchronous put_multipart is very naive and should not be used in production.
|
69
|
+
# Stable implementation of asynchronous requests involving thread pools would be out soon.
|
70
|
+
def put_multipart_async(parameters = {}, headers = {}, &block)
|
71
|
+
Thread.new do
|
72
|
+
put_multipart(parameters, headers, &block)
|
73
|
+
end
|
74
|
+
end
|
46
75
|
end
|
47
76
|
|
48
77
|
class Uri
|
data/lib/wrest/uri.rb
CHANGED
@@ -95,6 +95,20 @@ module Wrest #:nodoc:
|
|
95
95
|
Http::Get.new(self, parameters, headers, block ? @options.merge(:callback_block => block) : @options).invoke
|
96
96
|
end
|
97
97
|
|
98
|
+
# Make a GET request to this URI. This is a convenience API
|
99
|
+
# that creates a Wrest::Native::Get.
|
100
|
+
#
|
101
|
+
# Remember to escape all parameter strings if necessary, using URI.escape
|
102
|
+
#
|
103
|
+
# Note: get_async does not return a response and the response should be accessed through callbacks.
|
104
|
+
# This implementation of asynchronous get is very naive and should not be used in production.
|
105
|
+
# Stable implementation of asynchronous requests involving thread pools would be out soon.
|
106
|
+
def get_async(parameters = {}, headers = {}, &block)
|
107
|
+
Thread.new do
|
108
|
+
get(parameters, headers, &block)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
98
112
|
# Make a PUT request to this URI. This is a convenience API
|
99
113
|
# that creates a Wrest::Native::Put, executes it and returns a Wrest::Native::Response.
|
100
114
|
#
|
@@ -103,6 +117,20 @@ module Wrest #:nodoc:
|
|
103
117
|
Http::Put.new(self, body.to_s, headers, parameters, block ? @options.merge(:callback_block => block) : @options).invoke
|
104
118
|
end
|
105
119
|
|
120
|
+
# Make a PUT request to this URI. This is a convenience API
|
121
|
+
# that creates a Wrest::Native::Put.
|
122
|
+
#
|
123
|
+
# Remember to escape all parameter strings if necessary, using URI.escape
|
124
|
+
#
|
125
|
+
# Note: put_async does not return a response and the response should be accessed through callbacks.
|
126
|
+
# This implementation of asynchronous put is very naive and should not be used in production.
|
127
|
+
# Stable implementation of asynchronous requests involving thread pools would be out soon.
|
128
|
+
def put_async(body = '', headers = {}, parameters = {}, &block)
|
129
|
+
Thread.new do
|
130
|
+
put(body, headers, parameters, &block)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
106
134
|
# Makes a POST request to this URI. This is a convenience API
|
107
135
|
# that creates a Wrest::Native::Post, executes it and returns a Wrest::Native::Response.
|
108
136
|
# Note that sending an empty body will blow up if you're using libcurl.
|
@@ -111,6 +139,21 @@ module Wrest #:nodoc:
|
|
111
139
|
def post(body = '', headers = {}, parameters = {}, &block)
|
112
140
|
Http::Post.new(self, body.to_s, headers, parameters, block ? @options.merge(:callback_block => block) : @options).invoke
|
113
141
|
end
|
142
|
+
|
143
|
+
# Makes a POST request to this URI. This is a convenience API
|
144
|
+
# that creates a Wrest::Native::Post.
|
145
|
+
# Note that sending an empty body will blow up if you're using libcurl.
|
146
|
+
#
|
147
|
+
# Remember to escape all parameter strings if necessary, using URI.escape
|
148
|
+
#
|
149
|
+
# Note: post_async does not return a response and the response should be accessed through callbacks.
|
150
|
+
# This implementation of asynchronous post is very naive and should not be used in production.
|
151
|
+
# Stable implementation of asynchronous requests involving thread pools would be out soon.
|
152
|
+
def post_async(body = '', headers = {}, parameters = {}, &block)
|
153
|
+
Thread.new do
|
154
|
+
post(body, headers, parameters, &block)
|
155
|
+
end
|
156
|
+
end
|
114
157
|
|
115
158
|
# Makes a POST request to this URI. This is a convenience API
|
116
159
|
# that mimics a form being posted; some allegly RESTful APIs like FCBK require
|
@@ -125,6 +168,23 @@ module Wrest #:nodoc:
|
|
125
168
|
Http::Post.new(self, body, headers, {}, block ? @options.merge(:callback_block => block) : @options).invoke
|
126
169
|
end
|
127
170
|
|
171
|
+
# Makes a POST request to this URI. This is a convenience API
|
172
|
+
# that mimics a form being posted; some allegly RESTful APIs like FCBK require
|
173
|
+
# this.
|
174
|
+
#
|
175
|
+
# Form encoding involves munging the parameters into a string and placing them
|
176
|
+
# in the body, as well as setting the Content-Type header to
|
177
|
+
# application/x-www-form-urlencoded
|
178
|
+
#
|
179
|
+
# Note: post_form_async does not return a response and the response should be accessed through callbacks.
|
180
|
+
# This implementation of asynchronous post_form is very naive and should not be used in production.
|
181
|
+
# Stable implementation of asynchronous requests involving thread pools would be out soon.
|
182
|
+
def post_form_async(parameters = {}, headers = {}, &block)
|
183
|
+
Thread.new do
|
184
|
+
post_form(parameters, headers, &block)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
128
188
|
# Makes a DELETE request to this URI. This is a convenience API
|
129
189
|
# that creates a Wrest::Native::Delete, executes it and returns a Wrest::Native::Response.
|
130
190
|
#
|
@@ -133,6 +193,20 @@ module Wrest #:nodoc:
|
|
133
193
|
Http::Delete.new(self, parameters, headers, block ? @options.merge(:callback_block => block) : @options).invoke
|
134
194
|
end
|
135
195
|
|
196
|
+
# Makes a DELETE request to this URI. This is a convenience API
|
197
|
+
# that creates a Wrest::Native::Delete.
|
198
|
+
#
|
199
|
+
# Remember to escape all parameter strings if necessary, using URI.escape
|
200
|
+
#
|
201
|
+
# Note: delete_async does not return a response and the response should be accessed through callbacks.
|
202
|
+
# This implementation of asynchronous delete is very naive and should not be used in production.
|
203
|
+
# Stable implementation of asynchronous requests involving thread pools would be out soon.
|
204
|
+
def delete_async(parameters = {}, headers = {}, &block)
|
205
|
+
Thread.new do
|
206
|
+
delete(parameters, headers, &block)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
136
210
|
# Makes an OPTIONS request to this URI. This is a convenience API
|
137
211
|
# that creates a Wrest::Native::Options, executes it and returns the Wrest::Native::Response.
|
138
212
|
def options
|
data/lib/wrest/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: wrest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.3.0
|
6
6
|
platform: universal-java-1.6
|
7
7
|
authors:
|
8
8
|
- Sidu Ponnappa
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-02-
|
14
|
+
date: 2011-02-08 00:00:00 +05:30
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|