wrest 1.0.0.beta2-universal-java-1.6

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.
Files changed (101) hide show
  1. data/CHANGELOG +59 -0
  2. data/LICENCE +7 -0
  3. data/README.rdoc +127 -0
  4. data/bin/wrest +3 -0
  5. data/bin/wrest_shell.rb +21 -0
  6. data/lib/wrest.rb +101 -0
  7. data/lib/wrest.rbc +1900 -0
  8. data/lib/wrest/components.rb +20 -0
  9. data/lib/wrest/components.rbc +217 -0
  10. data/lib/wrest/components/container.rb +185 -0
  11. data/lib/wrest/components/container.rbc +2466 -0
  12. data/lib/wrest/components/container/alias_accessors.rb +66 -0
  13. data/lib/wrest/components/container/alias_accessors.rbc +905 -0
  14. data/lib/wrest/components/container/typecaster.rb +127 -0
  15. data/lib/wrest/components/container/typecaster.rbc +1985 -0
  16. data/lib/wrest/components/mutators.rb +39 -0
  17. data/lib/wrest/components/mutators.rbc +650 -0
  18. data/lib/wrest/components/mutators/base.rb +56 -0
  19. data/lib/wrest/components/mutators/base.rbc +702 -0
  20. data/lib/wrest/components/mutators/camel_to_snake_case.rb +22 -0
  21. data/lib/wrest/components/mutators/camel_to_snake_case.rbc +360 -0
  22. data/lib/wrest/components/mutators/xml_mini_type_caster.rb +43 -0
  23. data/lib/wrest/components/mutators/xml_mini_type_caster.rbc +679 -0
  24. data/lib/wrest/components/mutators/xml_simple_type_caster.rb +37 -0
  25. data/lib/wrest/components/mutators/xml_simple_type_caster.rbc +559 -0
  26. data/lib/wrest/components/translators.rb +28 -0
  27. data/lib/wrest/components/translators.rbc +517 -0
  28. data/lib/wrest/components/translators/content_types.rb +20 -0
  29. data/lib/wrest/components/translators/content_types.rbc +339 -0
  30. data/lib/wrest/components/translators/json.rb +25 -0
  31. data/lib/wrest/components/translators/json.rbc +462 -0
  32. data/lib/wrest/components/translators/xml.rb +24 -0
  33. data/lib/wrest/components/translators/xml.rbc +457 -0
  34. data/lib/wrest/core_ext/hash.rb +5 -0
  35. data/lib/wrest/core_ext/hash.rbc +182 -0
  36. data/lib/wrest/core_ext/hash/conversions.rb +44 -0
  37. data/lib/wrest/core_ext/hash/conversions.rbc +501 -0
  38. data/lib/wrest/core_ext/string.rb +5 -0
  39. data/lib/wrest/core_ext/string.rbc +182 -0
  40. data/lib/wrest/core_ext/string/conversions.rb +23 -0
  41. data/lib/wrest/core_ext/string/conversions.rbc +471 -0
  42. data/lib/wrest/curl.rb +49 -0
  43. data/lib/wrest/curl.rbc +704 -0
  44. data/lib/wrest/curl/delete.rb +23 -0
  45. data/lib/wrest/curl/get.rb +23 -0
  46. data/lib/wrest/curl/options.rb +16 -0
  47. data/lib/wrest/curl/post.rb +23 -0
  48. data/lib/wrest/curl/put.rb +23 -0
  49. data/lib/wrest/curl/request.rb +97 -0
  50. data/lib/wrest/curl/response.rb +71 -0
  51. data/lib/wrest/curl/session.rb +57 -0
  52. data/lib/wrest/exceptions.rb +33 -0
  53. data/lib/wrest/exceptions.rbc +312 -0
  54. data/lib/wrest/http_shared.rb +23 -0
  55. data/lib/wrest/http_shared.rbc +279 -0
  56. data/lib/wrest/http_shared/headers.rb +343 -0
  57. data/lib/wrest/http_shared/headers.rbc +353 -0
  58. data/lib/wrest/http_shared/standard_headers.rb +21 -0
  59. data/lib/wrest/http_shared/standard_headers.rbc +336 -0
  60. data/lib/wrest/http_shared/standard_tokens.rb +18 -0
  61. data/lib/wrest/http_shared/standard_tokens.rbc +316 -0
  62. data/lib/wrest/multipart.rb +52 -0
  63. data/lib/wrest/native.rb +33 -0
  64. data/lib/wrest/native.rbc +513 -0
  65. data/lib/wrest/native/connection_factory.rb +23 -0
  66. data/lib/wrest/native/connection_factory.rbc +445 -0
  67. data/lib/wrest/native/delete.rb +23 -0
  68. data/lib/wrest/native/delete.rbc +371 -0
  69. data/lib/wrest/native/get.rb +51 -0
  70. data/lib/wrest/native/get.rbc +855 -0
  71. data/lib/wrest/native/options.rb +23 -0
  72. data/lib/wrest/native/options.rbc +347 -0
  73. data/lib/wrest/native/post.rb +23 -0
  74. data/lib/wrest/native/post.rbc +388 -0
  75. data/lib/wrest/native/post_multipart.rb +32 -0
  76. data/lib/wrest/native/put.rb +23 -0
  77. data/lib/wrest/native/put.rbc +388 -0
  78. data/lib/wrest/native/put_multipart.rb +32 -0
  79. data/lib/wrest/native/redirection.rb +38 -0
  80. data/lib/wrest/native/redirection.rbc +520 -0
  81. data/lib/wrest/native/request.rb +94 -0
  82. data/lib/wrest/native/request.rbc +1675 -0
  83. data/lib/wrest/native/response.rb +120 -0
  84. data/lib/wrest/native/response.rbc +2150 -0
  85. data/lib/wrest/native/session.rb +57 -0
  86. data/lib/wrest/native/session.rbc +1372 -0
  87. data/lib/wrest/resource.rb +18 -0
  88. data/lib/wrest/resource.rbc +163 -0
  89. data/lib/wrest/resource/base.rb +99 -0
  90. data/lib/wrest/resource/base.rbc +2115 -0
  91. data/lib/wrest/resource/collection.rb +12 -0
  92. data/lib/wrest/resource/state.rb +6 -0
  93. data/lib/wrest/test.rb +1 -0
  94. data/lib/wrest/test/request_patches.rb +5 -0
  95. data/lib/wrest/uri.rb +160 -0
  96. data/lib/wrest/uri.rbc +2599 -0
  97. data/lib/wrest/uri_template.rb +49 -0
  98. data/lib/wrest/uri_template.rbc +505 -0
  99. data/lib/wrest/version.rb +23 -0
  100. data/lib/wrest/version.rbc +372 -0
  101. metadata +231 -0
@@ -0,0 +1,49 @@
1
+ # Copyright 2009 Sidu Ponnappa
2
+
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ # Unless required by applicable law or agreed to in writing, software distributed under the License
7
+ # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8
+ # See the License for the specific language governing permissions and limitations under the License.
9
+
10
+ module Wrest
11
+ class UriTemplate
12
+ attr_reader :uri_pattern
13
+ def initialize(uri_pattern)
14
+ @uri_pattern = uri_pattern.clone
15
+ end
16
+
17
+ # Builds a new Wrest::Uri from this uri template
18
+ # by replacing the keys in the options that match with
19
+ # the corressponding values.
20
+ #
21
+ # Example:
22
+ # template = UriTemplate.new("http://coathangers.com/:resource/:id.:format")
23
+ # template.to_uri(:resource => 'shen_coins', :id => 5, :format => :json)
24
+ # => #<Wrest::Uri:0x1225514 @uri=#<URI::HTTP:0x9127d8 URL:http://localhost:3000/shen_coins/5.json>>
25
+ #
26
+ # This feature can also be used to handle HTTP authentication where the username
27
+ # and password needs changing at runtime. However, this approach _will_ fail if
28
+ # the password contains characters like ^ and @.
29
+ #
30
+ # Note that beacuse because both HTTP Auth and UriTemplate
31
+ # use ':' as a delimiter, the pattern does look slightly weird, but it still works.
32
+ #
33
+ # Example:
34
+ # template = UriTemplate.new("http://:username::password@coathangers.com/:resource/:id.:format")
35
+ # template.to_uri(
36
+ # :user => 'kaiwren',
37
+ # :password => 'fupuppies',
38
+ # :resource => 'portal',
39
+ # :id => '1'
40
+ # )
41
+ # => #<Wrest::Uri:0x18e0bec @uri=#<URI::HTTP:0x18e09a8 URL:http://kaiwren:fupuppies@coathangers.com/portal/1>>
42
+ def to_uri(options = {})
43
+ options.inject(uri_pattern.clone) do |uri_string, tuple|
44
+ key, value = tuple
45
+ uri_string.gsub(":#{key.to_s}", value.to_s)
46
+ end.to_uri
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,505 @@
1
+ !RBIX
2
+ 0
3
+ x
4
+ M
5
+ 1
6
+ n
7
+ n
8
+ x
9
+ 10
10
+ __script__
11
+ i
12
+ 28
13
+ 99
14
+ 7
15
+ 0
16
+ 65
17
+ 49
18
+ 1
19
+ 2
20
+ 13
21
+ 99
22
+ 12
23
+ 7
24
+ 2
25
+ 12
26
+ 7
27
+ 3
28
+ 12
29
+ 65
30
+ 12
31
+ 49
32
+ 4
33
+ 4
34
+ 15
35
+ 49
36
+ 2
37
+ 0
38
+ 15
39
+ 2
40
+ 11
41
+ I
42
+ 6
43
+ I
44
+ 0
45
+ I
46
+ 0
47
+ I
48
+ 0
49
+ n
50
+ p
51
+ 5
52
+ x
53
+ 5
54
+ Wrest
55
+ x
56
+ 11
57
+ open_module
58
+ x
59
+ 15
60
+ __module_init__
61
+ M
62
+ 1
63
+ n
64
+ n
65
+ x
66
+ 5
67
+ Wrest
68
+ i
69
+ 29
70
+ 5
71
+ 66
72
+ 99
73
+ 7
74
+ 0
75
+ 1
76
+ 65
77
+ 49
78
+ 1
79
+ 3
80
+ 13
81
+ 99
82
+ 12
83
+ 7
84
+ 2
85
+ 12
86
+ 7
87
+ 3
88
+ 12
89
+ 65
90
+ 12
91
+ 49
92
+ 4
93
+ 4
94
+ 15
95
+ 49
96
+ 2
97
+ 0
98
+ 11
99
+ I
100
+ 6
101
+ I
102
+ 0
103
+ I
104
+ 0
105
+ I
106
+ 0
107
+ n
108
+ p
109
+ 5
110
+ x
111
+ 11
112
+ UriTemplate
113
+ x
114
+ 10
115
+ open_class
116
+ x
117
+ 14
118
+ __class_init__
119
+ M
120
+ 1
121
+ n
122
+ n
123
+ x
124
+ 11
125
+ UriTemplate
126
+ i
127
+ 38
128
+ 5
129
+ 66
130
+ 5
131
+ 7
132
+ 0
133
+ 47
134
+ 49
135
+ 1
136
+ 1
137
+ 15
138
+ 99
139
+ 7
140
+ 2
141
+ 7
142
+ 3
143
+ 65
144
+ 67
145
+ 49
146
+ 4
147
+ 0
148
+ 49
149
+ 5
150
+ 4
151
+ 15
152
+ 99
153
+ 7
154
+ 6
155
+ 7
156
+ 7
157
+ 65
158
+ 67
159
+ 49
160
+ 4
161
+ 0
162
+ 49
163
+ 5
164
+ 4
165
+ 11
166
+ I
167
+ 5
168
+ I
169
+ 0
170
+ I
171
+ 0
172
+ I
173
+ 0
174
+ n
175
+ p
176
+ 8
177
+ x
178
+ 11
179
+ uri_pattern
180
+ x
181
+ 11
182
+ attr_reader
183
+ x
184
+ 10
185
+ initialize
186
+ M
187
+ 1
188
+ n
189
+ n
190
+ x
191
+ 10
192
+ initialize
193
+ i
194
+ 8
195
+ 20
196
+ 0
197
+ 49
198
+ 0
199
+ 0
200
+ 38
201
+ 1
202
+ 11
203
+ I
204
+ 2
205
+ I
206
+ 1
207
+ I
208
+ 1
209
+ I
210
+ 1
211
+ n
212
+ p
213
+ 2
214
+ x
215
+ 5
216
+ clone
217
+ x
218
+ 12
219
+ @uri_pattern
220
+ p
221
+ 5
222
+ I
223
+ 0
224
+ I
225
+ d
226
+ I
227
+ 0
228
+ I
229
+ e
230
+ I
231
+ 8
232
+ x
233
+ 48
234
+ /Users/sidu/Work/wrest/lib/wrest/uri_template.rb
235
+ p
236
+ 1
237
+ x
238
+ 11
239
+ uri_pattern
240
+ x
241
+ 17
242
+ method_visibility
243
+ x
244
+ 15
245
+ add_defn_method
246
+ x
247
+ 6
248
+ to_uri
249
+ M
250
+ 1
251
+ n
252
+ n
253
+ x
254
+ 6
255
+ to_uri
256
+ i
257
+ 31
258
+ 23
259
+ 0
260
+ 10
261
+ 14
262
+ 44
263
+ 43
264
+ 0
265
+ 78
266
+ 49
267
+ 1
268
+ 1
269
+ 19
270
+ 0
271
+ 15
272
+ 20
273
+ 0
274
+ 5
275
+ 48
276
+ 2
277
+ 49
278
+ 3
279
+ 0
280
+ 56
281
+ 4
282
+ 50
283
+ 5
284
+ 1
285
+ 49
286
+ 6
287
+ 0
288
+ 11
289
+ I
290
+ 4
291
+ I
292
+ 1
293
+ I
294
+ 0
295
+ I
296
+ 1
297
+ n
298
+ p
299
+ 7
300
+ x
301
+ 4
302
+ Hash
303
+ x
304
+ 16
305
+ new_from_literal
306
+ x
307
+ 11
308
+ uri_pattern
309
+ x
310
+ 5
311
+ clone
312
+ M
313
+ 1
314
+ p
315
+ 2
316
+ x
317
+ 9
318
+ for_block
319
+ t
320
+ n
321
+ x
322
+ 6
323
+ to_uri
324
+ i
325
+ 48
326
+ 58
327
+ 37
328
+ 19
329
+ 0
330
+ 15
331
+ 37
332
+ 19
333
+ 1
334
+ 15
335
+ 15
336
+ 20
337
+ 1
338
+ 97
339
+ 37
340
+ 19
341
+ 2
342
+ 15
343
+ 37
344
+ 19
345
+ 3
346
+ 15
347
+ 15
348
+ 2
349
+ 15
350
+ 20
351
+ 0
352
+ 7
353
+ 0
354
+ 20
355
+ 2
356
+ 49
357
+ 1
358
+ 0
359
+ 47
360
+ 49
361
+ 1
362
+ 0
363
+ 63
364
+ 2
365
+ 20
366
+ 3
367
+ 49
368
+ 1
369
+ 0
370
+ 49
371
+ 2
372
+ 2
373
+ 11
374
+ I
375
+ 8
376
+ I
377
+ 4
378
+ I
379
+ 2
380
+ I
381
+ 2
382
+ n
383
+ p
384
+ 3
385
+ s
386
+ 1
387
+ :
388
+ x
389
+ 4
390
+ to_s
391
+ x
392
+ 4
393
+ gsub
394
+ p
395
+ 7
396
+ I
397
+ 0
398
+ I
399
+ 2b
400
+ I
401
+ a
402
+ I
403
+ 2c
404
+ I
405
+ 18
406
+ I
407
+ 2d
408
+ I
409
+ 30
410
+ x
411
+ 48
412
+ /Users/sidu/Work/wrest/lib/wrest/uri_template.rb
413
+ p
414
+ 4
415
+ x
416
+ 10
417
+ uri_string
418
+ x
419
+ 5
420
+ tuple
421
+ x
422
+ 3
423
+ key
424
+ x
425
+ 5
426
+ value
427
+ x
428
+ 6
429
+ inject
430
+ x
431
+ 6
432
+ to_uri
433
+ p
434
+ 5
435
+ I
436
+ 0
437
+ I
438
+ 2a
439
+ I
440
+ e
441
+ I
442
+ 2b
443
+ I
444
+ 1f
445
+ x
446
+ 48
447
+ /Users/sidu/Work/wrest/lib/wrest/uri_template.rb
448
+ p
449
+ 1
450
+ x
451
+ 7
452
+ options
453
+ p
454
+ 7
455
+ I
456
+ 2
457
+ I
458
+ c
459
+ I
460
+ a
461
+ I
462
+ d
463
+ I
464
+ 18
465
+ I
466
+ 2a
467
+ I
468
+ 26
469
+ x
470
+ 48
471
+ /Users/sidu/Work/wrest/lib/wrest/uri_template.rb
472
+ p
473
+ 0
474
+ x
475
+ 13
476
+ attach_method
477
+ p
478
+ 3
479
+ I
480
+ 2
481
+ I
482
+ b
483
+ I
484
+ 1d
485
+ x
486
+ 48
487
+ /Users/sidu/Work/wrest/lib/wrest/uri_template.rb
488
+ p
489
+ 0
490
+ x
491
+ 13
492
+ attach_method
493
+ p
494
+ 3
495
+ I
496
+ 0
497
+ I
498
+ a
499
+ I
500
+ 1c
501
+ x
502
+ 48
503
+ /Users/sidu/Work/wrest/lib/wrest/uri_template.rb
504
+ p
505
+ 0