wrest 1.0.0.beta1 → 1.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/CHANGELOG +14 -2
  2. data/LICENCE +7 -0
  3. data/README.rdoc +15 -69
  4. data/lib/wrest/components/container/alias_accessors.rb +1 -1
  5. data/lib/wrest/components/container/alias_accessors.rbc +905 -0
  6. data/lib/wrest/components/container/typecaster.rb +5 -5
  7. data/lib/wrest/components/container/typecaster.rbc +1985 -0
  8. data/lib/wrest/components/container.rb +11 -12
  9. data/lib/wrest/components/container.rbc +2466 -0
  10. data/lib/wrest/components/mutators/base.rbc +702 -0
  11. data/lib/wrest/components/mutators/camel_to_snake_case.rbc +360 -0
  12. data/lib/wrest/components/mutators/xml_mini_type_caster.rbc +679 -0
  13. data/lib/wrest/components/mutators/xml_simple_type_caster.rbc +559 -0
  14. data/lib/wrest/components/mutators.rbc +650 -0
  15. data/lib/wrest/components/translators/content_types.rbc +339 -0
  16. data/lib/wrest/components/translators/json.rbc +462 -0
  17. data/lib/wrest/components/translators/xml.rbc +457 -0
  18. data/lib/wrest/components/translators.rbc +517 -0
  19. data/lib/wrest/components.rbc +217 -0
  20. data/lib/wrest/core_ext/hash/conversions.rbc +501 -0
  21. data/lib/wrest/core_ext/hash.rbc +182 -0
  22. data/lib/wrest/core_ext/string/conversions.rbc +471 -0
  23. data/lib/wrest/core_ext/string.rbc +182 -0
  24. data/lib/wrest/curl/response.rb +8 -0
  25. data/lib/wrest/curl.rbc +704 -0
  26. data/lib/wrest/exceptions.rbc +312 -0
  27. data/lib/wrest/http_shared/headers.rb +0 -7
  28. data/lib/wrest/http_shared/headers.rbc +353 -0
  29. data/lib/wrest/http_shared/standard_headers.rbc +336 -0
  30. data/lib/wrest/http_shared/standard_tokens.rbc +316 -0
  31. data/lib/wrest/http_shared.rbc +279 -0
  32. data/lib/wrest/native/connection_factory.rbc +445 -0
  33. data/lib/wrest/native/delete.rbc +371 -0
  34. data/lib/wrest/native/get.rb +26 -0
  35. data/lib/wrest/native/get.rbc +855 -0
  36. data/lib/wrest/native/options.rbc +347 -0
  37. data/lib/wrest/native/post.rbc +388 -0
  38. data/lib/wrest/native/put.rbc +388 -0
  39. data/lib/wrest/native/redirection.rbc +520 -0
  40. data/lib/wrest/native/request.rb +4 -2
  41. data/lib/wrest/native/request.rbc +1675 -0
  42. data/lib/wrest/native/response.rb +53 -2
  43. data/lib/wrest/native/response.rbc +2150 -0
  44. data/lib/wrest/native/session.rbc +1372 -0
  45. data/lib/wrest/native.rbc +513 -0
  46. data/lib/wrest/resource/base.rbc +2115 -0
  47. data/lib/wrest/resource.rbc +163 -0
  48. data/lib/wrest/uri.rbc +2599 -0
  49. data/lib/wrest/uri_template.rbc +505 -0
  50. data/lib/wrest/version.rb +1 -1
  51. data/lib/wrest/version.rbc +372 -0
  52. data/lib/wrest.rb +1 -1
  53. data/lib/wrest.rbc +1900 -0
  54. metadata +99 -102
  55. data/Rakefile +0 -495
  56. data/VERSION.yml +0 -5
  57. data/bin/jwrest +0 -3
  58. data/examples/delicious.rb +0 -72
  59. data/examples/facebook.rb +0 -101
  60. data/examples/imgur_multipart.rb +0 -24
  61. data/examples/keep_alive.rb +0 -37
  62. data/examples/redirection.rb +0 -27
  63. data/examples/twitter.rb +0 -78
  64. data/examples/twitter_public_timeline.rb +0 -32
  65. data/examples/wow_realm_status.rb +0 -67
  66. data/init.rb +0 -0
  67. data/spec/custom_matchers/custom_matchers.rb +0 -2
  68. data/spec/rcov.opts +0 -4
  69. data/spec/spec.opts.disable +0 -6
  70. data/spec/unit/spec_helper.rb +0 -35
  71. data/spec/unit/wrest/components/attributes_container/alias_accessors_spec.rb +0 -49
  72. data/spec/unit/wrest/components/attributes_container/typecaster_spec.rb +0 -83
  73. data/spec/unit/wrest/components/attributes_container_spec.rb +0 -254
  74. data/spec/unit/wrest/components/mutators/base_spec.rb +0 -42
  75. data/spec/unit/wrest/components/mutators/camel_to_snake_spec.rb +0 -22
  76. data/spec/unit/wrest/components/mutators/xml_mini_type_caster_spec.rb +0 -75
  77. data/spec/unit/wrest/components/mutators/xml_simple_type_caster_spec.rb +0 -47
  78. data/spec/unit/wrest/components/mutators_spec.rb +0 -21
  79. data/spec/unit/wrest/components/translators/xml_spec.rb +0 -16
  80. data/spec/unit/wrest/components/translators_spec.rb +0 -18
  81. data/spec/unit/wrest/core_ext/hash/conversions_spec.rb +0 -22
  82. data/spec/unit/wrest/core_ext/string/conversions_spec.rb +0 -39
  83. data/spec/unit/wrest/curl/request_spec.rb +0 -19
  84. data/spec/unit/wrest/curl/response_spec.rb +0 -16
  85. data/spec/unit/wrest/http/response_spec.rb +0 -24
  86. data/spec/unit/wrest/native/redirection_spec.rb +0 -42
  87. data/spec/unit/wrest/native/request_spec.rb +0 -71
  88. data/spec/unit/wrest/native/response_spec.rb +0 -72
  89. data/spec/unit/wrest/native/session_spec.rb +0 -74
  90. data/spec/unit/wrest/resource/base_spec.rb +0 -274
  91. data/spec/unit/wrest/uri_spec.rb +0 -273
  92. data/spec/unit/wrest/uri_template_spec.rb +0 -38
  93. data/wrest.gemspec +0 -168
data/CHANGELOG CHANGED
@@ -5,14 +5,26 @@ Features under the section marked 'Current' are completed but pending release as
5
5
  Features under a numbered section are complete and available in the Wrest gem.
6
6
 
7
7
  == Coming soon
8
- * Cookie support
9
8
  * Proxy support
10
9
  * Multi-part post support on curl
11
10
 
12
11
  == In progress
13
12
  * 304/ETag response caching
14
13
  * Keep-alive support for libcurl
15
-
14
+ * Explicit cookie helpers - #cookie=, #cookie?
15
+ * Response code checkers: ok?, redirect?, created? etc.
16
+ * Alias deserialise as deserialize
17
+ * Ensure Components::Container is ActiveModel compliant
18
+
19
+ == Current
20
+
21
+ == 1.0.0.beta2
22
+ * GH#2 Make Components::Containers hash store a HashWithIndifferentAccess
23
+ * GH#6 Net::HTTP based calls to Twitter public APIs fail
24
+ * GH#5 Patron (curl) support failing for responses where headers have multiple values
25
+ * GH#7 Build fails on Ruby 1.9
26
+ * GH#16 Remove jeweler and use .gemspec direcly
27
+
16
28
  == 1.0.0.beta1
17
29
  * If libxml-ruby isn't found but nokogiri, don't warn about libxml-ruby
18
30
 
data/LICENCE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2009 - 2010 Sidu Ponnappa
2
+ Licensed under the Apache License, Version 2.0 (the "License");
3
+ you may not use this file except in compliance with the License.
4
+ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
5
+ Unless required by applicable law or agreed to in writing, software distributed under the License
6
+ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7
+ See the License for the specific language governing permissions and limitations under the License.
data/README.rdoc CHANGED
@@ -1,23 +1,17 @@
1
- = Wrest 1.0.0.beta1
1
+ = Wrest 1.0.0.beta2
2
2
 
3
3
  (c) Copyright 2009-2010 {Sidu Ponnappa}[http://blog.sidu.in]. All Rights Reserved.
4
4
 
5
- Wrest is a ruby REST client library which
6
- * allows allows you to quickly build object oriented wrappers around any web service
7
- * 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
8
- * runs on Ruby 1.8 and JRuby with 1.9, Rubinius, MacRuby and IronRuby support on the way
9
-
10
- To receive notifications whenever new features are added to Wrest, please subscribe to my {twitter feed}[http://twitter.com/ponnappa].
11
-
12
- (If you were wondering why the words 'demon', 'chi' and 'fu-puppies' show up in nearly every example and spec, it's because they're all references to {Roger Zelazny's}[http://en.wikipedia.org/wiki/Roger_Zelazny] last book, 'Lord Demon.')
13
-
14
- == Wrest Core: Features
5
+ Wrest is a ruby REST/HTTP client library which
15
6
 
7
+ * Allows allows you to quickly build object oriented wrappers around any web service
8
+ * Designed to be used as a library, not just a command line REST client (fewer class/static methods, more object oriented)
9
+ * 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
10
+ * Runs on Ruby 1.8, Ruby 1.9.2 and JRuby with Rubinius, MacRuby and IronRuby support on the way
16
11
  * Provides convenient HTTP wrappers, redirect handling, serialisation and deserialisation with response caching in the works
17
12
  * Supports using either Net::HTTP or libcurl as the underlying HTTP library
18
- * Designed to be used as a library, not just a command line REST client (fewer class/static methods, more object oriented)
19
- * Isn't coupled to Rails (usable in a pure Ruby application to consume any HTTP/REST api)
20
- * Can be used both stand alone as well as to build object oriented abstractions around resources and web services (Wrest::Resource is an example of the latter)
13
+
14
+ To receive notifications whenever new features are added to Wrest, please subscribe to my {twitter feed}[http://twitter.com/ponnappa].
21
15
 
22
16
  == Examples
23
17
 
@@ -27,19 +21,17 @@ For Facebook, Twitter, Delicious, GitHub and other API examples, see http://gith
27
21
 
28
22
  The source is available at git://github.com/kaiwren/wrest.git
29
23
 
30
- To install as a Rails plugin, do <tt>script/plugin install git://github.com/kaiwren/wrest.git</tt>
31
-
32
24
  To install the Wrest gem, do <tt>(sudo) gem install wrest --pre</tt>.
33
25
 
34
- Wrest is also available as a gem for JRuby; you can install it by running <tt>(sudo) jruby -S gem install wrest --pre</tt>.
26
+ Wrest is currently available as a gem for for Ruby and JRuby.
35
27
 
36
- === Usage: Shell
28
+ === Shell
37
29
 
38
30
  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.
39
31
  $ wrest
40
32
  >> y 'http://twitter.com/statuses/public_timeline.json'.to_uri(:timeout => 5).get.deserialise
41
33
 
42
- === Usage: Library
34
+ === Library
43
35
 
44
36
  require 'rubygems'
45
37
  require 'wrest'
@@ -50,7 +42,7 @@ You can launch the interactive Wrest shell by running bin/wrest if you have the
50
42
  :results=> '3',
51
43
  :start => '1'
52
44
  )
53
- === Usage: Basic Http Calls
45
+ === Basic Http Calls
54
46
 
55
47
  ==== GET
56
48
 
@@ -94,7 +86,7 @@ To find out what actions are permitted on a URI:
94
86
  'http://www.yahoo.com'.to_uri.options.headers['allow']
95
87
 
96
88
 
97
- === Usage: Attributes Container
89
+ === Other useful stuff
98
90
 
99
91
  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.
100
92
 
@@ -117,65 +109,19 @@ Example:
117
109
  kai_wren.energy # => #<Chi:0x113af8c @count="1024">
118
110
  kai_wren.teacher # => 'Viss'
119
111
 
120
- === Usage: Logging
112
+ === Logging
121
113
 
122
114
  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 :
123
115
  Wrest.logger = ActiveRecord::Base.logger
124
116
 
125
117
  === Build
126
118
 
127
- Standard options are available and can be listed using <tt>rake -T</tt>. Use rake:rcov for coverage and rake:rdoc to generate documentation.
119
+ 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.
128
120
 
129
121
  == Documentation
130
122
 
131
123
  Wrest RDocs can be found at http://wrest.rubyforge.org
132
124
 
133
- == Wrest::Resource
134
-
135
- Wrest::Resource is an alternative to Rails' ActiveResource. It targets Rails REST (well, POX, since Rails isn't really RESTful) services and is currently under development. Since no single REST library can provide an object oriented wrapper suitable for _all_ available web services, it follows that Wrest should focus on providing you with the tools to help you roll your own. Wrest::Resource is an example of this - an object oriented wrapper for the kind of REST APIs exposed by Rails applications, that you would otherwise use ActiveResource to consume.
136
-
137
- If you're looking for help doing this on Rails on the server side, take a look at {resource_full}[http://github.com/bguthrie/resource_full], a Rails plugin that makes RESTful Rails a whole order of magnitude easier. resource_full is a stable project and is currently in use in production.
138
-
139
-
140
- * No more pretending that REST resources are the same as records in a database (yeah, no more freaking ActiveResource::Connection that pretends it's a DB connection)
141
- * Treat put as 'create or update,' not just 'update'
142
- * Response codes result in user defined state transitions; favours state transitions based on response code over arbitrary ones
143
- * Supports moving toward hypermedia links as opposed to client server collusion through URI templates
144
- * The header is now exposed as metadata, rather being than something you have no control over
145
- * Out of the box support for If-Unmodified-Since/If-Match+Etag
146
- * Out of the box support for collections
147
- * Out of the box support for collection pagination (including support for WillPaginate), both header based and xml attribute based
148
- * Out of the box support for operations on all the records on the collection
149
- * Out of the box support for nested resources
150
- * Out of the box support for cached resources
151
- * Out of the box support for type-casting data that comes in as parameter strings
152
- * More natural mapping of deserialised entities to existing classes
153
- * No communication via exceptions for http error status codes
154
- * Better extensibility - allows access to request/response objects, avoids class variables, favours symbols over strings etc.
155
- * Content Types in request headers
156
- * Consider support for OPTIONS and response codes 100/417
157
-
158
- == Dependencies
159
-
160
- === Source
161
-
162
- * gems
163
- * json (json-jruby on JRuby)
164
- * active_support
165
- * ruby-libxml or Nokogiri (Wrest tries ruby-libxml first, then nokogiri, and will finally fall back on REXML; be aware that Wrest uses ActiveSupport::XmlMini, so if you're using Wrest as a plugin in a Rails application, all xml parsing across the application will switch to using libxml if it's available. You're free to change this by hand by using the ActiveSupport::XmlMini.backend= method.)
166
- * multipart-post (needed only if multipart support is enabled)
167
-
168
- === Build
169
-
170
- * rspec
171
- * rcov (unsupported on JRuby)
172
- * jeweler
173
-
174
125
  == Roadmap
175
126
 
176
127
  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.
177
-
178
- == Licence
179
-
180
- Wrest is released under the Apache 2.0 licence
181
-
@@ -39,7 +39,7 @@ module Wrest
39
39
  # look somethig like this:
40
40
  #
41
41
  # class User
42
- # include Wrest::Components::AttributesContainer
42
+ # include Wrest::Components::Container
43
43
  #
44
44
  # alias_accessors :a => :age,
45
45
  # :s => :sex