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.
- data/CHANGELOG +14 -2
- data/LICENCE +7 -0
- data/README.rdoc +15 -69
- data/lib/wrest/components/container/alias_accessors.rb +1 -1
- data/lib/wrest/components/container/alias_accessors.rbc +905 -0
- data/lib/wrest/components/container/typecaster.rb +5 -5
- data/lib/wrest/components/container/typecaster.rbc +1985 -0
- data/lib/wrest/components/container.rb +11 -12
- data/lib/wrest/components/container.rbc +2466 -0
- data/lib/wrest/components/mutators/base.rbc +702 -0
- data/lib/wrest/components/mutators/camel_to_snake_case.rbc +360 -0
- data/lib/wrest/components/mutators/xml_mini_type_caster.rbc +679 -0
- data/lib/wrest/components/mutators/xml_simple_type_caster.rbc +559 -0
- data/lib/wrest/components/mutators.rbc +650 -0
- data/lib/wrest/components/translators/content_types.rbc +339 -0
- data/lib/wrest/components/translators/json.rbc +462 -0
- data/lib/wrest/components/translators/xml.rbc +457 -0
- data/lib/wrest/components/translators.rbc +517 -0
- data/lib/wrest/components.rbc +217 -0
- data/lib/wrest/core_ext/hash/conversions.rbc +501 -0
- data/lib/wrest/core_ext/hash.rbc +182 -0
- data/lib/wrest/core_ext/string/conversions.rbc +471 -0
- data/lib/wrest/core_ext/string.rbc +182 -0
- data/lib/wrest/curl/response.rb +8 -0
- data/lib/wrest/curl.rbc +704 -0
- data/lib/wrest/exceptions.rbc +312 -0
- data/lib/wrest/http_shared/headers.rb +0 -7
- data/lib/wrest/http_shared/headers.rbc +353 -0
- data/lib/wrest/http_shared/standard_headers.rbc +336 -0
- data/lib/wrest/http_shared/standard_tokens.rbc +316 -0
- data/lib/wrest/http_shared.rbc +279 -0
- data/lib/wrest/native/connection_factory.rbc +445 -0
- data/lib/wrest/native/delete.rbc +371 -0
- data/lib/wrest/native/get.rb +26 -0
- data/lib/wrest/native/get.rbc +855 -0
- data/lib/wrest/native/options.rbc +347 -0
- data/lib/wrest/native/post.rbc +388 -0
- data/lib/wrest/native/put.rbc +388 -0
- data/lib/wrest/native/redirection.rbc +520 -0
- data/lib/wrest/native/request.rb +4 -2
- data/lib/wrest/native/request.rbc +1675 -0
- data/lib/wrest/native/response.rb +53 -2
- data/lib/wrest/native/response.rbc +2150 -0
- data/lib/wrest/native/session.rbc +1372 -0
- data/lib/wrest/native.rbc +513 -0
- data/lib/wrest/resource/base.rbc +2115 -0
- data/lib/wrest/resource.rbc +163 -0
- data/lib/wrest/uri.rbc +2599 -0
- data/lib/wrest/uri_template.rbc +505 -0
- data/lib/wrest/version.rb +1 -1
- data/lib/wrest/version.rbc +372 -0
- data/lib/wrest.rb +1 -1
- data/lib/wrest.rbc +1900 -0
- metadata +99 -102
- data/Rakefile +0 -495
- data/VERSION.yml +0 -5
- data/bin/jwrest +0 -3
- data/examples/delicious.rb +0 -72
- data/examples/facebook.rb +0 -101
- data/examples/imgur_multipart.rb +0 -24
- data/examples/keep_alive.rb +0 -37
- data/examples/redirection.rb +0 -27
- data/examples/twitter.rb +0 -78
- data/examples/twitter_public_timeline.rb +0 -32
- data/examples/wow_realm_status.rb +0 -67
- data/init.rb +0 -0
- data/spec/custom_matchers/custom_matchers.rb +0 -2
- data/spec/rcov.opts +0 -4
- data/spec/spec.opts.disable +0 -6
- data/spec/unit/spec_helper.rb +0 -35
- data/spec/unit/wrest/components/attributes_container/alias_accessors_spec.rb +0 -49
- data/spec/unit/wrest/components/attributes_container/typecaster_spec.rb +0 -83
- data/spec/unit/wrest/components/attributes_container_spec.rb +0 -254
- data/spec/unit/wrest/components/mutators/base_spec.rb +0 -42
- data/spec/unit/wrest/components/mutators/camel_to_snake_spec.rb +0 -22
- data/spec/unit/wrest/components/mutators/xml_mini_type_caster_spec.rb +0 -75
- data/spec/unit/wrest/components/mutators/xml_simple_type_caster_spec.rb +0 -47
- data/spec/unit/wrest/components/mutators_spec.rb +0 -21
- data/spec/unit/wrest/components/translators/xml_spec.rb +0 -16
- data/spec/unit/wrest/components/translators_spec.rb +0 -18
- data/spec/unit/wrest/core_ext/hash/conversions_spec.rb +0 -22
- data/spec/unit/wrest/core_ext/string/conversions_spec.rb +0 -39
- data/spec/unit/wrest/curl/request_spec.rb +0 -19
- data/spec/unit/wrest/curl/response_spec.rb +0 -16
- data/spec/unit/wrest/http/response_spec.rb +0 -24
- data/spec/unit/wrest/native/redirection_spec.rb +0 -42
- data/spec/unit/wrest/native/request_spec.rb +0 -71
- data/spec/unit/wrest/native/response_spec.rb +0 -72
- data/spec/unit/wrest/native/session_spec.rb +0 -74
- data/spec/unit/wrest/resource/base_spec.rb +0 -274
- data/spec/unit/wrest/uri_spec.rb +0 -273
- data/spec/unit/wrest/uri_template_spec.rb +0 -38
- 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.
|
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
|
-
|
19
|
-
|
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
|
26
|
+
Wrest is currently available as a gem for for Ruby and JRuby.
|
35
27
|
|
36
|
-
===
|
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
|
-
===
|
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
|
-
===
|
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
|
-
===
|
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
|
-
===
|
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
|
-
|