wrest 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -1
- data/README.rdoc +30 -5
- data/bin/wrest.compiled.rbc +78 -0
- data/bin/wrest_shell.rb +1 -1
- data/bin/wrest_shell.rbc +659 -0
- data/lib/wrest.rb +36 -2
- data/lib/wrest/cache_proxy.rb +111 -0
- data/lib/wrest/components/cache_store/memcached.rb +34 -0
- data/lib/wrest/curl.rb +2 -2
- data/lib/wrest/curl/request.rb +2 -2
- data/lib/wrest/hash_with_case_insensitive_access.rb +52 -0
- data/lib/wrest/native/get.rb +33 -3
- data/lib/wrest/native/redirection.rb +1 -1
- data/lib/wrest/native/request.rb +6 -6
- data/lib/wrest/native/response.rb +168 -34
- data/lib/wrest/version.rb +1 -12
- metadata +109 -19
- data/lib/wrest/resource.rb +0 -18
- data/lib/wrest/resource/base.rb +0 -101
- data/lib/wrest/resource/collection.rb +0 -12
- data/lib/wrest/resource/state.rb +0 -6
data/lib/wrest/version.rb
CHANGED
@@ -8,16 +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
|
-
|
12
|
-
unless defined? MAJOR
|
13
|
-
MAJOR = 1
|
14
|
-
MINOR = 0
|
15
|
-
TINY = 2
|
16
|
-
BUILD = nil
|
17
|
-
|
18
|
-
STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
|
19
|
-
|
20
|
-
SUMMARY = "wrest version #{STRING}"
|
21
|
-
end
|
22
|
-
end
|
11
|
+
VERSION = "1.1.0"
|
23
12
|
end
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.2
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sidu Ponnappa
|
@@ -16,31 +16,87 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-01-
|
19
|
+
date: 2011-01-28 00:00:00 +05:30
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
|
-
name:
|
23
|
+
name: rubyforge
|
24
24
|
prerelease: false
|
25
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: hanna
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rspec
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
26
54
|
none: false
|
27
55
|
requirements:
|
28
56
|
- - ~>
|
29
57
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
58
|
+
hash: 31
|
31
59
|
segments:
|
32
60
|
- 2
|
61
|
+
- 4
|
62
|
+
- 0
|
63
|
+
version: 2.4.0
|
64
|
+
type: :development
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: sinatra
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 23
|
75
|
+
segments:
|
76
|
+
- 1
|
33
77
|
- 0
|
34
78
|
- 0
|
35
|
-
|
36
|
-
- 22
|
37
|
-
version: 2.0.0.beta.22
|
79
|
+
version: 1.0.0
|
38
80
|
type: :development
|
39
|
-
version_requirements: *
|
81
|
+
version_requirements: *id004
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: metric_fu
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
94
|
+
type: :development
|
95
|
+
version_requirements: *id005
|
40
96
|
- !ruby/object:Gem::Dependency
|
41
97
|
name: activesupport
|
42
98
|
prerelease: false
|
43
|
-
requirement: &
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
44
100
|
none: false
|
45
101
|
requirements:
|
46
102
|
- - ~>
|
@@ -52,11 +108,11 @@ dependencies:
|
|
52
108
|
- 0
|
53
109
|
version: 3.0.0
|
54
110
|
type: :runtime
|
55
|
-
version_requirements: *
|
111
|
+
version_requirements: *id006
|
56
112
|
- !ruby/object:Gem::Dependency
|
57
113
|
name: builder
|
58
114
|
prerelease: false
|
59
|
-
requirement: &
|
115
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
60
116
|
none: false
|
61
117
|
requirements:
|
62
118
|
- - ~>
|
@@ -68,11 +124,43 @@ dependencies:
|
|
68
124
|
- 2
|
69
125
|
version: 2.1.2
|
70
126
|
type: :runtime
|
71
|
-
version_requirements: *
|
127
|
+
version_requirements: *id007
|
128
|
+
- !ruby/object:Gem::Dependency
|
129
|
+
name: i18n
|
130
|
+
prerelease: false
|
131
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
hash: 13
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
- 4
|
140
|
+
- 1
|
141
|
+
version: 0.4.1
|
142
|
+
type: :runtime
|
143
|
+
version_requirements: *id008
|
144
|
+
- !ruby/object:Gem::Dependency
|
145
|
+
name: tzinfo
|
146
|
+
prerelease: false
|
147
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
hash: 61
|
153
|
+
segments:
|
154
|
+
- 0
|
155
|
+
- 3
|
156
|
+
- 23
|
157
|
+
version: 0.3.23
|
158
|
+
type: :runtime
|
159
|
+
version_requirements: *id009
|
72
160
|
- !ruby/object:Gem::Dependency
|
73
161
|
name: json
|
74
162
|
prerelease: false
|
75
|
-
requirement: &
|
163
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
76
164
|
none: false
|
77
165
|
requirements:
|
78
166
|
- - ~>
|
@@ -84,7 +172,7 @@ dependencies:
|
|
84
172
|
- 6
|
85
173
|
version: 1.4.6
|
86
174
|
type: :runtime
|
87
|
-
version_requirements: *
|
175
|
+
version_requirements: *id010
|
88
176
|
description: Wrest is a HTTP and REST client library which allows you to quickly build well encapsulated, object oriented wrappers around any web service.
|
89
177
|
email:
|
90
178
|
- sidu@c42.in
|
@@ -95,12 +183,15 @@ extensions: []
|
|
95
183
|
extra_rdoc_files:
|
96
184
|
- README.rdoc
|
97
185
|
files:
|
186
|
+
- bin/wrest.compiled.rbc
|
98
187
|
- bin/wrest_shell.rb
|
188
|
+
- bin/wrest_shell.rbc
|
99
189
|
- bin/wrest
|
100
190
|
- lib/wrest_no_ext.rb
|
101
191
|
- lib/wrest.rb
|
102
192
|
- lib/wrest/http_shared.rb
|
103
193
|
- lib/wrest/components/translators.rb
|
194
|
+
- lib/wrest/components/cache_store/memcached.rb
|
104
195
|
- lib/wrest/components/container.rb
|
105
196
|
- lib/wrest/components/mutators/xml_mini_type_caster.rb
|
106
197
|
- lib/wrest/components/mutators/base.rb
|
@@ -112,6 +203,7 @@ files:
|
|
112
203
|
- lib/wrest/components/mutators.rb
|
113
204
|
- lib/wrest/components/container/typecaster.rb
|
114
205
|
- lib/wrest/components/container/alias_accessors.rb
|
206
|
+
- lib/wrest/cache_proxy.rb
|
115
207
|
- lib/wrest/native/request.rb
|
116
208
|
- lib/wrest/native/connection_factory.rb
|
117
209
|
- lib/wrest/native/put_multipart.rb
|
@@ -139,14 +231,11 @@ files:
|
|
139
231
|
- lib/wrest/curl/options.rb
|
140
232
|
- lib/wrest/curl/session.rb
|
141
233
|
- lib/wrest/curl/post.rb
|
142
|
-
- lib/wrest/resource/base.rb
|
143
|
-
- lib/wrest/resource/collection.rb
|
144
|
-
- lib/wrest/resource/state.rb
|
145
234
|
- lib/wrest/multipart.rb
|
146
235
|
- lib/wrest/xml_mini.rb
|
147
236
|
- lib/wrest/exceptions.rb
|
237
|
+
- lib/wrest/hash_with_case_insensitive_access.rb
|
148
238
|
- lib/wrest/curl.rb
|
149
|
-
- lib/wrest/resource.rb
|
150
239
|
- lib/wrest/test.rb
|
151
240
|
- lib/wrest/uri_template.rb
|
152
241
|
- lib/wrest/xml_mini/rexml/xpath_filter.rb
|
@@ -198,6 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
287
|
- 7
|
199
288
|
version: 1.3.7
|
200
289
|
requirements:
|
290
|
+
- To use Memcached as caching back-end, install the 'dalli' gem.
|
201
291
|
- To use multipart post, install the 'multipart-post' gem.
|
202
292
|
- To use curl as the http engine, install the 'patron' gem. This feature is not available (and should be unneccessary) on jruby.
|
203
293
|
rubyforge_project: wrest
|
data/lib/wrest/resource.rb
DELETED
@@ -1,18 +0,0 @@
|
|
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
|
-
# Wrest::Resource is a re-implementation
|
12
|
-
# of ActiveResource using Wrest::Components
|
13
|
-
# and with some of the rough edges removed
|
14
|
-
module Resource
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
require "#{Wrest::Root}/wrest/resource/base"
|
data/lib/wrest/resource/base.rb
DELETED
@@ -1,101 +0,0 @@
|
|
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::Resource #:nodoc:
|
11
|
-
# Resource::Base is the equivalent of ActiveResource::Base.
|
12
|
-
# It is a REST client targetted at Rails REST apps.
|
13
|
-
#
|
14
|
-
# Note that it is currently incomplete.
|
15
|
-
class Base
|
16
|
-
include Wrest::Components::Container
|
17
|
-
|
18
|
-
always_has :id
|
19
|
-
typecast :id => as_integer
|
20
|
-
attr_reader :attributes
|
21
|
-
|
22
|
-
def ==(other)
|
23
|
-
return true if self.equal?(other)
|
24
|
-
return false unless other.class == self.class
|
25
|
-
return self.attributes == other.attributes
|
26
|
-
end
|
27
|
-
|
28
|
-
def hash
|
29
|
-
id.hash
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_xml(options={})
|
33
|
-
attributes.to_xml({:root => self.class.resource_name.gsub('_', '-')}.merge(options))
|
34
|
-
end
|
35
|
-
|
36
|
-
class << self
|
37
|
-
def inherited(klass)
|
38
|
-
klass.set_resource_name klass.name
|
39
|
-
end
|
40
|
-
|
41
|
-
# Allows the resource name to be configured and creates
|
42
|
-
# a getter method for it.
|
43
|
-
# This is a useful feature when using anonymous classes like
|
44
|
-
# we often do while writing tests.
|
45
|
-
# By default, the resource name is set to the name of the class.
|
46
|
-
def set_resource_name(resource_name)
|
47
|
-
self.class_eval "def self.resource_name; '#{resource_name.to_s.underscore}';end"
|
48
|
-
end
|
49
|
-
|
50
|
-
# Allows the host url at which the resource is found to be configured
|
51
|
-
# and creates a getter method for it.
|
52
|
-
# For example in the url
|
53
|
-
# http://localhost:3000/users/1/settings
|
54
|
-
# you would set
|
55
|
-
# http://localhost:3000
|
56
|
-
# as the host url.
|
57
|
-
def set_host(host)
|
58
|
-
self.class_eval "def self.host; '#{host}';end"
|
59
|
-
end
|
60
|
-
|
61
|
-
def set_default_format(format)
|
62
|
-
self.class_eval "def self.default_format; '#{format.to_s}';end"
|
63
|
-
end
|
64
|
-
|
65
|
-
def set_redirect_handler(method_object)
|
66
|
-
end
|
67
|
-
|
68
|
-
def resource_collection_name
|
69
|
-
@resource_collection_name ||= "#{resource_name.underscore.pluralize}"
|
70
|
-
end
|
71
|
-
|
72
|
-
def find_one_uri_template
|
73
|
-
@find_one_template ||= Wrest::UriTemplate.new(':host/:resource_collection_name/:id.:format')
|
74
|
-
end
|
75
|
-
|
76
|
-
def find(id)
|
77
|
-
response = find_one_uri_template.to_uri(
|
78
|
-
:host => host,
|
79
|
-
:resource_collection_name => resource_collection_name,
|
80
|
-
:id => id,
|
81
|
-
:format => default_format
|
82
|
-
).get
|
83
|
-
self.new(response.deserialise.mutate_using(
|
84
|
-
Wrest::Components::Mutators.chain(:xml_mini_type_caster, :camel_to_snake_case)
|
85
|
-
).shift.last)
|
86
|
-
end
|
87
|
-
|
88
|
-
def create(attributes = {})
|
89
|
-
response = Wrest::UriTemplate.new(':host/:resource_collection_name.:format').to_uri(
|
90
|
-
:host => host,
|
91
|
-
:resource_collection_name => resource_collection_name,
|
92
|
-
:format => default_format
|
93
|
-
).post(self.new(attributes).to_xml, 'Content-Type' => "application/#{default_format}")
|
94
|
-
|
95
|
-
self.new(response.deserialise.mutate_using(
|
96
|
-
Wrest::Components::Mutators.chain(:xml_mini_type_caster, :camel_to_snake_case)
|
97
|
-
).shift.last)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,12 +0,0 @@
|
|
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
|
-
# Understands how to contain a collection of Wrest::Resources
|
11
|
-
class Wrest::Resource::Collection
|
12
|
-
end
|