wrest 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb64013e477c67348f9d540e039f2b473bdcd74b
4
- data.tar.gz: fc87882ddf3f179b67b8cb1a29857c766f946f44
3
+ metadata.gz: 387bf7a48ff0337789fb3efefc9d7ba43d5e3610
4
+ data.tar.gz: cc9eafb4f54b2269975be55e5ed2e00c05319ffe
5
5
  SHA512:
6
- metadata.gz: bb7689e3c04a4bd87a743d8f8e613bf4256af9137c6dc27b757930958ff838c54603292c393fcf16d6034b48c254af74076ce08c8fc9ab11e8c6fcc3b6f57b02
7
- data.tar.gz: 8b967f2f73f24ad24453a6cfec637c413c4df064ee5952e39ac84d4baa6a3df175e63d77d7faf3462bfb42577405625209aa54ea2473d05307fc300e9e194624
6
+ metadata.gz: 6c91d9d500c5173755a2714d6db85d1b0e6fb02bba70031d39dd019869e11fc8a19210de1ddadd00d43e402b3e684f734d69d7ad09668aa70cecc68e4e2c3748
7
+ data.tar.gz: ae1f2a1df23dfd81a3432d04dc1dea3a2f82c945ef04fb93b1d04a0567fb26bf8262edc45bc44041b9089449ab19a8fcbf372a658be8b2eb1148fa96dfcf1c5f
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.5.2
6
+ * Updated dependencies - ActiveSupport, MultipartPost, Dalli and JRuby OpenSSL
7
+
5
8
  == 1.5.1
6
9
  * Supports Ruby 2.x.x, JRuby 1.7.6 (and higher), JRuby 9.0.0.0.pre2
7
10
 
@@ -1,58 +1,70 @@
1
- = Wrest 1.5.1
1
+ [![Build Status](https://travis-ci.org/c42/wrest.svg?branch=master)](https://travis-ci.org/c42/wrest)
2
2
 
3
- (c) Copyright 2009-2011 {Sidu Ponnappa}[http://blog.sidu.in]. All Rights Reserved.
3
+ # Wrest 1.5.1
4
4
 
5
- {CI Status:}[http://ci.c42.in/projects/wrest] http://ci.c42.in/projects/wrest.png
5
+ (c) Copyright 2009-2011 [Sidu Ponnappa](http://blog.sidu.in). All Rights Reserved.
6
6
 
7
7
  Wrest is a ruby REST/HTTP client library which
8
8
 
9
9
  * Allows you to use Net::HTTP or libCurl
10
- * Allows you to pick your Ruby: use 2.x.x, JRuby 1.7.6 (and higher), JRuby 9.0.0.0.pre2 ({Continuous Integration server}[http://ci.c42.in])
11
- * Supports RFC 2616 based {caching}[https://github.com/kaiwren/wrest/blob/caching/Caching.markdown]
12
- * [Alpha] Allows you to go async: use Threads or EventMachine
10
+ * Allows you to pick your Ruby: use 2.x.x, JRuby 1.7.6 (and higher), JRuby 9.0.0.0.pre2 ([Continuous Integration server](http://ci.c42.in))
11
+ * Supports RFC 2616 based [caching](https://github.com/kaiwren/wrest/blob/caching/Caching.markdown)
12
+ * **_Alpha_**
13
+
14
+ Allows you to go async: use Threads or EventMachine
15
+
13
16
  * Allows you to quickly build object oriented wrappers around any web service
14
17
  * Is designed to be used as a library, not just a command line REST client (fewer class/static methods, more object oriented)
15
18
  * Is spec driven, strongly favours immutable objects and avoids class methods and setters making it better suited for use as a library, especially in multi-threaded environments
16
19
  * Provides convenient HTTP wrappers, redirect handling, serialisation, deserialisation and xpath based lookup
17
20
 
18
- To receive notifications whenever new features are added to Wrest, please subscribe to my {twitter feed}[http://twitter.com/ponnappa].
21
+ To receive notifications whenever new features are added to Wrest, please subscribe to my [twitter feed](http://twitter.com/ponnappa).
19
22
 
20
- == Examples
23
+ ##Examples
21
24
 
22
25
  For Facebook, Twitter, Delicious, GitHub and other API examples, see http://github.com/kaiwren/wrest/tree/master/examples
23
26
 
24
- === Basic Http Calls
27
+ ### Basic Http Calls
25
28
 
26
- ==== GET
29
+ #### GET
27
30
 
28
31
  * Basic API calls
29
32
 
33
+ ```
30
34
  'http://twitter.com/statuses/public_timeline.json'.to_uri.get.deserialise # works with json and xml out of the box
31
35
 
32
36
  'http://twitter.com/statuses/public_timeline.xml'.to_uri.get.deserialise # see lib/wrest/components/translators to add other formats
37
+ ```
33
38
 
34
39
  * Timeout support
35
40
 
41
+ ```
36
42
  'http://twitter.com/statuses/public_timeline.json'.to_uri.get(:timeout => 5).body
43
+ ```
37
44
 
38
45
  * Redirect support
39
46
 
47
+ ```
40
48
  'http://google.com'.to_uri(:follow_redirects => false).get
41
49
 
42
50
  'http://google.com'.to_uri(:follow_redirects_limit => 1).get
51
+ ```
43
52
 
44
53
  :follow_redirects_limit defaults to 5 if not specified.
45
54
 
46
55
  * Deserialise with XPath filtering
47
56
 
57
+ ```
48
58
  ActiveSupport::XmlMini.backend = 'REXML'
49
59
 
50
60
  'http://twitter.com/statuses/public_timeline.xml'.to_uri.get.deserialise(
51
61
  :xpath => '//user/name/text()'
52
62
  )
63
+ ```
53
64
 
54
65
  * More complex request with parameters and a custom deserialiser
55
66
 
67
+ ```
56
68
  'http://search.yahooapis.com/NewsSearchService/V1/newsSearch'.to_uri.get(
57
69
  :appid => 'YahooDemo',
58
70
  :output => 'xml',
@@ -62,18 +74,26 @@ For Facebook, Twitter, Delicious, GitHub and other API examples, see http://gith
62
74
  ).deserialise_using(
63
75
  Wrest::Components::Translators::Xml
64
76
  )
77
+ ```
78
+
65
79
  * Basic HTTP auth and URI extensions using Wrest::Uri#[]
66
80
 
81
+ ```
67
82
  base_uri = 'https://api.del.icio.us/v1'.to_uri(:username => 'kaiwren', :password => 'fupupp1es')
68
83
  bookmarks = base_uri['/posts/get'].get.deserialise
84
+ ```
69
85
 
70
- ==== POST
86
+ #### POST
71
87
 
72
88
  * Regular, vanilla Post with a body and headers
73
89
 
90
+ ```
74
91
  'http://my.api.com'.to_uri.post('YAML encoded body', 'Content-Type' => 'text/x-yaml')
92
+ ```
93
+
75
94
  * Form encoded post
76
95
 
96
+ ```
77
97
  'https://api.del.icio.us/v1/posts/add'.to_uri(
78
98
  :username => 'kaiwren', :password => 'fupupp1es'
79
99
  ).post_form(
@@ -82,69 +102,86 @@ For Facebook, Twitter, Delicious, GitHub and other API examples, see http://gith
82
102
  :extended => "All posts tagged with 'ruby'",
83
103
  :tags => 'ruby hacking'
84
104
  )
105
+ ```
106
+
85
107
  * Multipart posts
86
108
 
109
+ ```
87
110
  'http://imgur.com/api/upload.xml'.to_uri.post_multipart(
88
111
  :image => UploadIO.new(File.open(file_path), "image/png", file_path),
89
112
  :key => imgur_key
90
113
  ).deserialise
114
+ ```
91
115
 
92
116
  Note: To enable Multipart support, you'll have to explicitly require 'wrest/multipart', which depends on the multipart-post gem.
93
117
 
94
- ==== DELETE
118
+ # DELETE
95
119
 
96
120
  To delete a resource:
97
121
 
122
+ ```
98
123
  'https://api.del.icio.us/v1/posts/delete'.to_uri(
99
124
  :username => 'kaiwren',
100
125
  :password => 'fupupp1es'
101
126
  ).delete(
102
127
  :url => 'http://c2.com'
103
128
  )
129
+ ```
104
130
 
105
- === Caching
131
+ ### Caching
106
132
 
107
133
  Wrest supports caching with pluggable back-ends.
108
134
 
135
+ ```
109
136
  Wrest::Caching.default_to_hash! # Hash should NEVER be used in a production environment. It is unbounded and will keep increasing in size.
110
137
  c42 = "http://c42.in".to_uri.get
138
+ ```
111
139
 
112
- A Memcached based caching back-end is available in Wrest. You can get instructions on how to install Memcached on your system {here}[http://code.google.com/p/memcached/wiki/NewInstallFromPackage].
140
+ A Memcached based caching back-end is available in Wrest. You can get instructions on how to install Memcached on your system [here](http://code.google.com/p/memcached/wiki/NewInstallFromPackage).
113
141
  The Dalli gem is used by Wrest to interface with Memcached. Install dalli using 'gem install dalli'.
114
142
 
115
143
  Use the following method to enable caching for all requests, and set Memcached as the default back-end.
116
144
 
145
+ ```
117
146
  Wrest::Caching.default_to_memcached!
147
+ ```
118
148
 
119
149
  For fine-grained control over the cache store (or to use multiple cache stores in the same codebase), you can use this API:
120
150
 
151
+ ```
121
152
  r1 = "http://c42.in".to_uri.using_memcached.get
122
153
  r2 = "http://c42.in".to_uri.using_hash.get
154
+ ```
123
155
 
124
- A detailed writeup regarding caching as defined by RFC 2616, and how Wrest implements caching is at {Wrest Caching Doc}[https://github.com/kaiwren/wrest/blob/master/Caching.markdown]
156
+ A detailed writeup regarding caching as defined by RFC 2616, and how Wrest implements caching is at [Wrest Caching Doc](https://github.com/kaiwren/wrest/blob/master/Caching.markdown)
125
157
 
126
158
  You can create your own back-ends for Wrest caching by implementing the interface implemented in https://github.com/kaiwren/wrest/blob/master/lib/wrest/components/cache_store/memcached.rb
127
159
 
128
160
  To explicitly disable caching for specific requests:
129
161
 
162
+ ```
130
163
  "http://c42.in".to_uri.disable_cache.get
164
+ ```
131
165
 
132
- === Callbacks
166
+ ### Callbacks
133
167
 
134
- ==== Uri level callbacks
168
+ #### Uri level callbacks
135
169
 
136
170
  You can define a set of callbacks that are invoked based on the http codes of the responses to any requests on a given uri.
137
171
 
172
+ ```
138
173
  "http://google.com".to_uri(:callback => {
139
174
  200 => lambda {|response| Wrest.logger.info "Ok." },
140
175
  400..499 => lambda {|response| Wrest.logger.error "Invalid. #{response.body}"},
141
176
  300..302 => lambda {|response| Wrest.logger.debug "Redirected. #{response.message}" }
142
177
  }).get
178
+ ```
143
179
 
144
- ==== Per request callbacks
180
+ #### Per request callbacks
145
181
 
146
182
  You can also define callbacks that are invoked based on the http code of the response to a particular request.
147
183
 
184
+ ```
148
185
  "http://google.com".to_uri.get do |callback|
149
186
  callback.on_ok do |response|
150
187
  Wrest.logger.info "Ok."
@@ -158,16 +195,18 @@ You can also define callbacks that are invoked based on the http code of the res
158
195
  Wrest.logger.info "Successful."
159
196
  end
160
197
  end
198
+ ```
161
199
 
162
200
  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.
163
201
 
164
- === Asynchronous requests
202
+ ### Asynchronous requests
165
203
 
166
204
  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
167
205
  while using asynchronous request is through callbacks.
168
206
 
169
207
  Asynchronous requests support pluggable backends. The default backend used for asynchronous requests is ruby threads.
170
208
 
209
+ ```
171
210
  "http://c42.in".to_uri.get_async do |callback|
172
211
  callback.on_ok do |response|
173
212
  Wrest.logger.info "Ok."
@@ -175,29 +214,35 @@ Asynchronous requests support pluggable backends. The default backend used for a
175
214
  end
176
215
 
177
216
  sleep 1 # Causes thread created by get_async to execute
217
+ ```
178
218
 
179
219
  You can change the default to eventmachine.
180
220
 
221
+ ```
181
222
  Wrest::AsyncRequest.default_to_em!
223
+ ```
182
224
 
183
225
  You can also override the default on Uri objects.
184
226
 
227
+ ```
185
228
  "http://c42.in".to_uri.using_em.get_async do |callback|
186
229
  callback.on_ok do |response|
187
230
  Wrest.logger.info "Ok."
188
231
  end
189
232
  end
233
+ ```
190
234
 
191
235
  Note: The current implementation of asynchronous requests is currently in alpha and should not be used in production.
192
236
 
193
- === Other useful stuff
237
+ ### Other useful stuff
194
238
 
195
- ==== Hash container with ActiveResource-like semantics
239
+ #### Hash container with ActiveResource-like semantics
196
240
 
197
241
  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.
198
242
 
199
243
  Example:
200
244
 
245
+ ```
201
246
  class Demon
202
247
  include Wrest::Components::Container
203
248
 
@@ -214,75 +259,97 @@ Example:
214
259
  kai_wren.chi # => #<Chi:0x113af8c @count="1024">
215
260
  kai_wren.energy # => #<Chi:0x113af8c @count="1024">
216
261
  kai_wren.teacher # => 'Viss'
262
+ ```
263
+
264
+ #### Opt-out of core extensions
217
265
 
218
- ==== Opt-out of core extensions
266
+ Uncomfortable with extending `String` to add `to_uri`? Simply do
219
267
 
220
- Uncomfortable with extending <tt>String</tt> to add <tt>to_uri</tt>? Simply do
268
+ ```
221
269
  gem "wrest", :require => "wrest_no_ext"
222
- in your Gemfile. You can now do <tt>Uri.new('http://localhost')</tt> to build Uris.
270
+ ```
271
+
272
+ in your Gemfile. You can now do `Uri.new('http://localhost')` to build Uris.
223
273
 
224
- === Logging
274
+ ### Logging
225
275
 
226
276
  The Wrest logger can be set and accessed through Wrest.logger and is configured by default to log to STDOUT. If you're using Wrest in a Rails application, you can configure logging by adding a config/initializers/wrest.rb file with the following contents :
277
+
278
+ ```
227
279
  Wrest.logger = Rails.logger
280
+ ```
228
281
 
229
- === Json Backend
282
+ ### Json Backend
230
283
 
231
284
  Wrest uses the multi_json gem to manage Json backends, allowing it to play nice with Rails 3.1. To change the backend used, you can do the following:
285
+
286
+ ```
232
287
  MultiJson.engine = :json_gem
288
+ ```
233
289
 
234
- For more information, look up the {multi_json}[http://github.com/intridea/multi_json] documentation.
290
+ For more information, look up the [multi_json](http://github.com/intridea/multi_json) documentation.
235
291
 
236
- === Build
292
+ ### Build
237
293
 
238
- Standard options are available and can be listed using <tt>rake -T</tt>. Use rake:rcov for coverage and rake:rdoc to generate documentation. The link to the continuous integration build is over at the C42 Engineering {open source}[http://c42.in/open_source] page.
294
+ Standard options are available and can be listed using `rake -T`. Use rake:rcov for coverage and rake:rdoc to generate documentation. The link to the continuous integration build is over at the C42 Engineering [open source](http://c42.in/open_source) page.
239
295
 
240
- == Documentation
296
+ ## Documentation
241
297
 
242
298
  Wrest RDocs can be found at http://wrest.rubyforge.org
243
299
 
244
- == Roadmap
300
+ ## Roadmap
245
301
 
246
- Features that are planned, in progress or already implemented are documented in the {CHANGELOG}[http://github.com/kaiwren/wrest/tree/master/CHANGELOG] starting from version 0.0.8.
302
+ Features that are planned, in progress or already implemented are documented in the [CHANGELOG](http://github.com/kaiwren/wrest/tree/master/CHANGELOG) starting from version 0.0.8.
247
303
 
248
- == Installation
304
+ ## Installation
249
305
 
250
306
  The source is available at git://github.com/kaiwren/wrest.git
251
307
 
252
- To install the Wrest gem, do <tt>(sudo) gem install wrest</tt>.
308
+ To install the Wrest gem, do `(sudo) gem install wrest`.
253
309
 
254
310
  Wrest is currently available as a gem for for Ruby and JRuby.
255
311
 
256
- === Shell
312
+ ### Shell
313
+
314
+ You can launch the interactive Wrest shell by running bin/wrest if you have the source or invoking `wrest` from your prompt if you've installed the gem.
257
315
 
258
- You can launch the interactive Wrest shell by running bin/wrest if you have the source or invoking <tt>wrest</tt> from your prompt if you've installed the gem.
316
+ ```
259
317
  $ wrest
260
318
  >> y 'http://twitter.com/statuses/public_timeline.json'.to_uri(:timeout => 5).get.deserialise
319
+ ```
261
320
 
262
- === Testing
321
+ ### Testing
263
322
 
264
323
  Start the Sinatra test server for functional test. The dependencies for the test app are managed separately by a Gemfile under spec/sample_app.
324
+
325
+ ```
265
326
  rake -f spec/sample_app/Rakefile # runs on port 3000
327
+ ```
266
328
 
267
329
  Start a memcached daemon/process on port 11211
330
+
331
+ ```
268
332
  /usr/local/bin/memcached
333
+ ```
269
334
 
270
335
  Run the tests in a different terminal:
271
336
 
337
+ ```
272
338
  # Run the normal test suite.
273
339
  rake
274
340
 
275
341
  # Runs the functional test suite.
276
342
  rake rspec:functional
277
-
278
- == Contributors
279
-
280
- * Sidu Ponnappa : {kaiwren}[http://github.com/kaiwren]
281
- * Niranjan Paranjape : {achamian}[http://github.com/achamian]
282
- * Aakash Dharmadhkari : {aakashd}[http://github.com/aakashd]
283
- * Srushti : {srushti}[http://github.com/srushti]
284
- * Preethi Ramdev : {preethiramdev}[http://github.com/preethiramdev]
285
- * Nikhil Vallishayee : {nikhilvallishayee}[http://github.com/nikhilvallishayee]
286
- * Jacques Crocker : {railsjedi}[http://github.com/railsjedi]
287
- * Jasim A Basheer: {jasim}[http://github.com/jasim]
288
- * Arvind Laxminarayan: {ardsrk}[http://github.com/ardsrk]
343
+ ```
344
+
345
+ ## Contributors
346
+
347
+ * Sidu Ponnappa : [kaiwren](http://github.com/kaiwren)
348
+ * Niranjan Paranjape : [achamian](http://github.com/achamian)
349
+ * Aakash Dharmadhkari : [aakashd](http://github.com/aakashd)
350
+ * Srushti : [srushti](http://github.com/srushti)
351
+ * Preethi Ramdev : [preethiramdev](http://github.com/preethiramdev)
352
+ * Nikhil Vallishayee : [nikhilvallishayee](http://github.com/nikhilvallishayee)
353
+ * Jacques Crocker : [railsjedi](http://github.com/railsjedi)
354
+ * Jasim A Basheer: [jasim](http://github.com/jasim)
355
+ * Arvind Laxminarayan: [ardsrk](http://github.com/ardsrk)
data/lib/wrest.rb CHANGED
@@ -23,9 +23,9 @@ require 'active_support/core_ext/object'
23
23
 
24
24
  module Wrest
25
25
  Root = File.dirname(__FILE__)
26
-
26
+
27
27
  $:.unshift Root
28
-
28
+
29
29
  def self.logger=(logger)
30
30
  @logger = logger
31
31
  end
@@ -50,7 +50,7 @@ module Wrest
50
50
  end
51
51
  end
52
52
 
53
- Wrest.logger = ActiveSupport::BufferedLogger.new(STDOUT)
53
+ Wrest.logger = ActiveSupport::Logger.new(STDOUT)
54
54
  Wrest.logger.level = Logger::DEBUG
55
55
 
56
56
  require "wrest/core_ext/string"
@@ -1,7 +1,7 @@
1
1
  begin
2
- gem 'dalli', '~> 1.0.1'
2
+ gem 'dalli', '~> 2'
3
3
  rescue Gem::LoadError => e
4
- Wrest.logger.debug "Dalli ~> 1.0.1 not found. Dalli is necessary to use the memcached caching back-end. To install dalli run `(sudo) gem install dalli`."
4
+ Wrest.logger.debug "Dalli ~> 2 not found. Dalli is necessary to use the memcached caching back-end. To install dalli run `(sudo) gem install dalli`."
5
5
  raise e
6
6
  end
7
7
 
@@ -8,9 +8,9 @@
8
8
  # See the License for the specific language governing permissions and limitations under the License.
9
9
 
10
10
  begin
11
- gem 'multipart-post', '~> 1.0'
11
+ gem 'multipart-post', '~> 2.0'
12
12
  rescue Gem::LoadError => e
13
- Wrest.logger.debug "Multipart Post ~> 1.0 not found. Multipart Post is necessary to be able to post multipart. To install Multipart Post run 'sudo gem install multipart-post'"
13
+ Wrest.logger.debug "Multipart Post ~> 2.0 not found. Multipart Post is necessary to be able to post multipart. To install Multipart Post run 'sudo gem install multipart-post'"
14
14
  raise e
15
15
  end
16
16
 
data/lib/wrest/version.rb CHANGED
@@ -8,5 +8,5 @@
8
8
  # See the License for the specific language governing permissions and limitations under the License.
9
9
 
10
10
  module Wrest
11
- VERSION = "1.5.1"
11
+ VERSION = "1.5.2"
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sidu Ponnappa
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-23 00:00:00.000000000 Z
12
+ date: 2015-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubyforge
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '3'
76
+ version: '4'
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '3'
83
+ version: '4'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: builder
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -118,11 +118,11 @@ executables:
118
118
  - wrest
119
119
  extensions: []
120
120
  extra_rdoc_files:
121
- - README.rdoc
121
+ - README.md
122
122
  files:
123
123
  - CHANGELOG
124
124
  - LICENCE
125
- - README.rdoc
125
+ - README.md
126
126
  - bin/wrest
127
127
  - bin/wrest_shell.rb
128
128
  - lib/wrest.rb
@@ -230,3 +230,4 @@ specification_version: 4
230
230
  summary: Wrest is a fluent, object oriented HTTP client library for 2.x.x, JRuby 1.7.6
231
231
  (and higher), JRuby 9.0.0.0.pre2.
232
232
  test_files: []
233
+ has_rdoc: