wrest 1.0.0.beta1 → 1.0.0.beta2
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.
- 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/spec/unit/wrest/uri_spec.rb
DELETED
|
@@ -1,273 +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
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
11
|
-
|
|
12
|
-
module Wrest
|
|
13
|
-
describe Wrest::Uri do
|
|
14
|
-
it "should respond to the four http actions" do
|
|
15
|
-
uri = Uri.new('http://localhost')
|
|
16
|
-
uri.should respond_to(:get)
|
|
17
|
-
uri.should respond_to(:post)
|
|
18
|
-
uri.should respond_to(:put)
|
|
19
|
-
uri.should respond_to(:delete)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should know when it is https" do
|
|
23
|
-
Uri.new('https://localhost:3000').should be_https
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should know when it is not https" do
|
|
27
|
-
Uri.new('http://localhost:3000').should_not be_https
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "should know how to build a new uri from an existing one by appending a path" do
|
|
31
|
-
Uri.new('http://localhost:3000')['/ooga/booga'].should == Uri.new('http://localhost:3000/ooga/booga')
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should know its full path" do
|
|
35
|
-
Uri.new('http://localhost:3000/ooga').full_path.should == '/ooga'
|
|
36
|
-
Uri.new('http://localhost:3000/ooga?foo=meh&bar=1').full_path.should == '/ooga?foo=meh&bar=1'
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "should know its host" do
|
|
40
|
-
Uri.new('http://localhost:3000/ooga').host.should == 'localhost'
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "should know its port" do
|
|
44
|
-
Uri.new('http://localhost:3000/ooga').port.should == 3000
|
|
45
|
-
Uri.new('http://localhost/ooga').port.should == 80
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "should include the username and password while building a new uri if no options are provided" do
|
|
49
|
-
Uri.new(
|
|
50
|
-
'http://localhost:3000',
|
|
51
|
-
:username => 'foo',
|
|
52
|
-
:password => 'bar')['/ooga/booga'].should == Uri.new(
|
|
53
|
-
'http://localhost:3000/ooga/booga',
|
|
54
|
-
:username => 'foo',
|
|
55
|
-
:password => 'bar')
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "should use the username and password provided while building a new uri if present" do
|
|
59
|
-
uri = Uri.new('http://localhost:3000', :username => 'foo', :password => 'bar')
|
|
60
|
-
uri.username.should == 'foo'
|
|
61
|
-
uri.password.should == 'bar'
|
|
62
|
-
|
|
63
|
-
extended_uri = uri['/ooga/booga', {:username => 'meh', :password => 'baz'}]
|
|
64
|
-
extended_uri.username.should == 'meh'
|
|
65
|
-
extended_uri.password.should == 'baz'
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "should know how to produce its uri as a string" do
|
|
69
|
-
Uri.new('http://localhost:3000').uri_string.should == 'http://localhost:3000'
|
|
70
|
-
Uri.new('http://localhost:3000').to_s.should == 'http://localhost:3000'
|
|
71
|
-
Uri.new('http://localhost:3000', :username => 'foo', :password => 'bar').to_s.should == 'http://localhost:3000'
|
|
72
|
-
Uri.new('http://foo:bar@localhost:3000').to_s.should == 'http://foo:bar@localhost:3000'
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
describe 'Equals' do
|
|
76
|
-
it "should understand equality" do
|
|
77
|
-
Uri.new('https://localhost:3000/ooga').should_not == nil
|
|
78
|
-
Uri.new('https://localhost:3000/ooga').should_not == 'https://localhost:3000/ooga'
|
|
79
|
-
Uri.new('https://localhost:3000/ooga').should_not == Uri.new('https://localhost:3000/booga')
|
|
80
|
-
|
|
81
|
-
Uri.new('https://ooga:booga@localhost:3000/ooga').should_not == Uri.new('https://foo:bar@localhost:3000/booga')
|
|
82
|
-
Uri.new('http://ooga:booga@localhost:3000/ooga').should_not == Uri.new('http://foo:bar@localhost:3000/booga')
|
|
83
|
-
Uri.new('http://localhost:3000/ooga').should_not == Uri.new('http://foo:bar@localhost:3000/booga')
|
|
84
|
-
|
|
85
|
-
Uri.new('https://localhost:3000').should_not == Uri.new('https://localhost:3500')
|
|
86
|
-
Uri.new('https://localhost:3000').should_not == Uri.new('http://localhost:3000')
|
|
87
|
-
Uri.new('http://localhost:3000', :username => 'ooga', :password => 'booga').should_not == Uri.new('http://ooga:booga@localhost:3000')
|
|
88
|
-
|
|
89
|
-
Uri.new('http://localhost:3000').should == Uri.new('http://localhost:3000')
|
|
90
|
-
Uri.new('http://localhost:3000', :username => 'ooga', :password => 'booga').should == Uri.new('http://localhost:3000', :username => 'ooga', :password => 'booga')
|
|
91
|
-
Uri.new('http://ooga:booga@localhost:3000').should == Uri.new('http://ooga:booga@localhost:3000')
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
it "should have the same hash code if it is the same uri" do
|
|
96
|
-
Uri.new('https://localhost:3000').hash.should == Uri.new('https://localhost:3000').hash
|
|
97
|
-
Uri.new('http://ooga:booga@localhost:3000').hash.should == Uri.new('http://ooga:booga@localhost:3000').hash
|
|
98
|
-
Uri.new('http://localhost:3000', :username => 'ooga', :password => 'booga').hash.should == Uri.new('http://localhost:3000', :username => 'ooga', :password => 'booga').hash
|
|
99
|
-
|
|
100
|
-
Uri.new('https://localhost:3001').hash.should_not == Uri.new('https://localhost:3000').hash
|
|
101
|
-
Uri.new('https://ooga:booga@localhost:3000').hash.should_not == Uri.new('https://localhost:3000').hash
|
|
102
|
-
Uri.new('https://localhost:3000', :username => 'ooga', :password => 'booga').hash.should_not == Uri.new('https://localhost:3000').hash
|
|
103
|
-
Uri.new('https://localhost:3000', :username => 'ooga', :password => 'booga').hash.should_not == Uri.new('http://localhost:3000', :username => 'foo', :password => 'bar').hash
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
describe 'Cloning' do
|
|
108
|
-
before :each do
|
|
109
|
-
@original = Uri.new('http://localhost:3000/ooga')
|
|
110
|
-
@clone = @original.clone
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
it "should be equal to its clone" do
|
|
114
|
-
@original.should == @clone
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it "should not be the same object as the clone" do
|
|
118
|
-
@original.should_not be_equal(@clone)
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
it "should allow options to be changed when building the clone" do
|
|
122
|
-
clone = @original.clone(:username => 'kaiwren', :password => 'bottle')
|
|
123
|
-
@original.should_not == clone
|
|
124
|
-
clone.username.should == 'kaiwren'
|
|
125
|
-
clone.password.should == 'bottle'
|
|
126
|
-
@original.username.should be_nil
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
describe 'HTTP actions' do
|
|
131
|
-
def setup_http
|
|
132
|
-
http = mock(Net::HTTP)
|
|
133
|
-
Net::HTTP.should_receive(:new).with('localhost', 3000).and_return(http)
|
|
134
|
-
http.should_receive(:read_timeout=).with(60)
|
|
135
|
-
http
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
it "should know how to get" do
|
|
139
|
-
uri = "http://localhost:3000/glassware".to_uri
|
|
140
|
-
uri.should_not be_https
|
|
141
|
-
|
|
142
|
-
http = setup_http
|
|
143
|
-
|
|
144
|
-
request = Net::HTTP::Get.new('/glassware', {})
|
|
145
|
-
Net::HTTP::Get.should_receive(:new).with('/glassware', {}).and_return(request)
|
|
146
|
-
|
|
147
|
-
http.should_receive(:request).with(request, nil).and_return(build_ok_response)
|
|
148
|
-
|
|
149
|
-
uri.get
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
it "should know how to get with parameters" do
|
|
153
|
-
uri = "http://localhost:3000/glassware".to_uri
|
|
154
|
-
uri.should_not be_https
|
|
155
|
-
|
|
156
|
-
http = setup_http
|
|
157
|
-
|
|
158
|
-
request = Net::HTTP::Get.new('/glassware?owner=Kai&type=bottle', {'page' => '2', 'per_page' => '5'})
|
|
159
|
-
Net::HTTP::Get.should_receive(:new).with('/glassware?owner=Kai&type=bottle', {'page' => '2', 'per_page' => '5'}).and_return(request)
|
|
160
|
-
|
|
161
|
-
http.should_receive(:request).with(request, nil).and_return(build_ok_response)
|
|
162
|
-
|
|
163
|
-
uri.get(ActiveSupport::OrderedHash.new.merge!([[:owner, 'Kai'],[:type, 'bottle']]), :page => '2', :per_page => '5')
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
it "should know how to get with parameters but without any headers" do
|
|
167
|
-
uri = "http://localhost:3000/glassware".to_uri
|
|
168
|
-
uri.should_not be_https
|
|
169
|
-
|
|
170
|
-
http = setup_http
|
|
171
|
-
|
|
172
|
-
request = Net::HTTP::Get.new('/glassware?owner=Kai&type=bottle', {})
|
|
173
|
-
Net::HTTP::Get.should_receive(:new).with('/glassware?owner=Kai&type=bottle', {}).and_return(request)
|
|
174
|
-
|
|
175
|
-
http.should_receive(:request).with(request, nil).and_return(build_ok_response)
|
|
176
|
-
|
|
177
|
-
uri.get(ActiveSupport::OrderedHash.new.merge!([[:owner, 'Kai'],[:type, 'bottle']]))
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
it "should know how to post" do
|
|
181
|
-
uri = "http://localhost:3000/glassware".to_uri
|
|
182
|
-
uri.should_not be_https
|
|
183
|
-
|
|
184
|
-
http = setup_http
|
|
185
|
-
|
|
186
|
-
request = Net::HTTP::Post.new('/glassware', {'page' => '2', 'per_page' => '5'})
|
|
187
|
-
Net::HTTP::Post.should_receive(:new).with('/glassware', {'page' => '2', 'per_page' => '5'}).and_return(request)
|
|
188
|
-
|
|
189
|
-
http.should_receive(:request).with(request, '<ooga>Booga</ooga>').and_return(build_ok_response)
|
|
190
|
-
|
|
191
|
-
uri.post '<ooga>Booga</ooga>', :page => '2', :per_page => '5'
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
it "should know how to post form-encoded parameters using Uri#post_form" do
|
|
195
|
-
uri = "http://localhost:3000/glassware".to_uri
|
|
196
|
-
uri.should_not be_https
|
|
197
|
-
|
|
198
|
-
http = setup_http
|
|
199
|
-
|
|
200
|
-
request = Net::HTTP::Post.new('/glassware', {'page' => '2', 'per_page' => '5'})
|
|
201
|
-
Net::HTTP::Post.should_receive(:new).with('/glassware',
|
|
202
|
-
'page' => '2', 'per_page' => '5', H::ContentType=>T::FormEncoded
|
|
203
|
-
).and_return(request)
|
|
204
|
-
|
|
205
|
-
http.should_receive(:request).with(request, "foo=bar&ooga=booga").and_return(build_ok_response)
|
|
206
|
-
uri.post_form(ActiveSupport::OrderedHash.new.merge!([[:foo, 'bar'],[:ooga, 'booga']]), :page => '2', :per_page => '5')
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
it "should know how to put" do
|
|
210
|
-
uri = "http://localhost:3000/glassware".to_uri
|
|
211
|
-
uri.should_not be_https
|
|
212
|
-
|
|
213
|
-
http = setup_http
|
|
214
|
-
|
|
215
|
-
request = Net::HTTP::Put.new('/glassware', {'page' => '2', 'per_page' => '5'})
|
|
216
|
-
Net::HTTP::Put.should_receive(:new).with('/glassware', {'page' => '2', 'per_page' => '5'}).and_return(request)
|
|
217
|
-
|
|
218
|
-
http.should_receive(:request).with(request, '<ooga>Booga</ooga>').and_return(build_ok_response)
|
|
219
|
-
|
|
220
|
-
uri.put '<ooga>Booga</ooga>', :page => '2', :per_page => '5'
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
it "should know how to delete" do
|
|
224
|
-
uri = "http://localhost:3000/glassware".to_uri
|
|
225
|
-
uri.should_not be_https
|
|
226
|
-
|
|
227
|
-
http = setup_http
|
|
228
|
-
|
|
229
|
-
request = Net::HTTP::Delete.new('/glassware?owner=Kai&type=bottle', {'page' => '2', 'per_page' => '5'})
|
|
230
|
-
Net::HTTP::Delete.should_receive(:new).with('/glassware?owner=Kai&type=bottle', {'page' => '2', 'per_page' => '5'}).and_return(request)
|
|
231
|
-
|
|
232
|
-
http.should_receive(:request).with(request, nil).and_return(build_ok_response(nil))
|
|
233
|
-
|
|
234
|
-
uri.delete(ActiveSupport::OrderedHash.new.merge!([[:owner, 'Kai'],[:type, 'bottle']]), :page => '2', :per_page => '5')
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
it "should know how to ask for options on a URI" do
|
|
238
|
-
uri = "http://localhost:3000/glassware".to_uri
|
|
239
|
-
uri.should_not be_https
|
|
240
|
-
|
|
241
|
-
http = setup_http
|
|
242
|
-
|
|
243
|
-
request = Net::HTTP::Options.new('/glassware')
|
|
244
|
-
Net::HTTP::Options.should_receive(:new).with('/glassware', {}).and_return(request)
|
|
245
|
-
|
|
246
|
-
http.should_receive(:request).with(request, nil).and_return(build_ok_response(nil))
|
|
247
|
-
|
|
248
|
-
uri.options
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
it "should not mutate state of the uri across requests" do
|
|
252
|
-
uri = "http://localhost:3000/glassware".to_uri
|
|
253
|
-
uri.should_not be_https
|
|
254
|
-
|
|
255
|
-
http = mock(Net::HTTP)
|
|
256
|
-
Net::HTTP.should_receive(:new).with('localhost', 3000).any_number_of_times.and_return(http)
|
|
257
|
-
http.should_receive(:read_timeout=).any_number_of_times.with(60)
|
|
258
|
-
|
|
259
|
-
request_get = Net::HTTP::Get.new('/glassware?owner=Kai&type=bottle', {'page' => '2', 'per_page' => '5'})
|
|
260
|
-
Net::HTTP::Get.should_receive(:new).with('/glassware?owner=Kai&type=bottle', {'page' => '2', 'per_page' => '5'}).and_return(request_get)
|
|
261
|
-
|
|
262
|
-
request_post = Net::HTTP::Post.new('/glassware', {'page' => '2', 'per_page' => '5'})
|
|
263
|
-
Net::HTTP::Post.should_receive(:new).with('/glassware', {'page' => '2', 'per_page' => '5'}).and_return(request_post)
|
|
264
|
-
|
|
265
|
-
http.should_receive(:request).with(request_get, nil).and_return(build_ok_response)
|
|
266
|
-
http.should_receive(:request).with(request_post, '<ooga>Booga</ooga>').and_return(build_ok_response)
|
|
267
|
-
|
|
268
|
-
uri.get(ActiveSupport::OrderedHash.new.merge!([[:owner, 'Kai'],[:type, 'bottle']]), :page => '2', :per_page => '5')
|
|
269
|
-
uri.post '<ooga>Booga</ooga>', :page => '2', :per_page => '5'
|
|
270
|
-
end
|
|
271
|
-
end
|
|
272
|
-
end
|
|
273
|
-
end
|
|
@@ -1,38 +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
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
11
|
-
|
|
12
|
-
module Wrest
|
|
13
|
-
describe Wrest::UriTemplate do
|
|
14
|
-
it "should not maintain a reference to the string it is initialized with" do
|
|
15
|
-
url_pattern = "http://localhost:3000/:resource/:id.:format"
|
|
16
|
-
template = UriTemplate.new(url_pattern)
|
|
17
|
-
url_pattern.gsub!(':', '!')
|
|
18
|
-
template.uri_pattern.should == "http://localhost:3000/:resource/:id.:format"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "should know how to build a Wrest::Uri from the pattern given a set of replacement options" do
|
|
22
|
-
template = UriTemplate.new("http://localhost:3000/:resource/:id.:format")
|
|
23
|
-
template.to_uri(
|
|
24
|
-
:resource => 'shen_coins', :id => 5, :format => :json
|
|
25
|
-
).should == "http://localhost:3000/shen_coins/5.json".to_uri
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "should also handle username and password" do
|
|
29
|
-
template = UriTemplate.new("http://:user::password@coathangers.com/:resource/:id")
|
|
30
|
-
template.to_uri(
|
|
31
|
-
:user => 'kaiwren',
|
|
32
|
-
:password => 'fupuppies',
|
|
33
|
-
:resource => 'portal',
|
|
34
|
-
:id => '1'
|
|
35
|
-
).should == "http://kaiwren:fupuppies@coathangers.com/portal/1".to_uri
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
data/wrest.gemspec
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
# Generated by jeweler
|
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
4
|
-
# -*- encoding: utf-8 -*-
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |s|
|
|
7
|
-
s.name = %q{wrest}
|
|
8
|
-
s.version = "1.0.0.beta1"
|
|
9
|
-
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
|
11
|
-
s.authors = ["Sidu Ponnappa"]
|
|
12
|
-
s.date = %q{2010-07-28}
|
|
13
|
-
s.description = %q{Wrest is a HTTP and REST client library which allows you to quickly build well encapsulated, object oriented wrappers around any web service.}
|
|
14
|
-
s.email = %q{ckponnappa@gmail.com}
|
|
15
|
-
s.executables = ["wrest", "jwrest"]
|
|
16
|
-
s.extra_rdoc_files = [
|
|
17
|
-
"README.rdoc"
|
|
18
|
-
]
|
|
19
|
-
s.files = [
|
|
20
|
-
"CHANGELOG",
|
|
21
|
-
"README.rdoc",
|
|
22
|
-
"Rakefile",
|
|
23
|
-
"VERSION.yml",
|
|
24
|
-
"bin/jwrest",
|
|
25
|
-
"bin/wrest",
|
|
26
|
-
"bin/wrest_shell.rb",
|
|
27
|
-
"examples/delicious.rb",
|
|
28
|
-
"examples/facebook.rb",
|
|
29
|
-
"examples/imgur_multipart.rb",
|
|
30
|
-
"examples/keep_alive.rb",
|
|
31
|
-
"examples/redirection.rb",
|
|
32
|
-
"examples/twitter.rb",
|
|
33
|
-
"examples/twitter_public_timeline.rb",
|
|
34
|
-
"examples/wow_realm_status.rb",
|
|
35
|
-
"init.rb",
|
|
36
|
-
"lib/wrest.rb",
|
|
37
|
-
"lib/wrest/components.rb",
|
|
38
|
-
"lib/wrest/components/container.rb",
|
|
39
|
-
"lib/wrest/components/container/alias_accessors.rb",
|
|
40
|
-
"lib/wrest/components/container/typecaster.rb",
|
|
41
|
-
"lib/wrest/components/mutators.rb",
|
|
42
|
-
"lib/wrest/components/mutators/base.rb",
|
|
43
|
-
"lib/wrest/components/mutators/camel_to_snake_case.rb",
|
|
44
|
-
"lib/wrest/components/mutators/xml_mini_type_caster.rb",
|
|
45
|
-
"lib/wrest/components/mutators/xml_simple_type_caster.rb",
|
|
46
|
-
"lib/wrest/components/translators.rb",
|
|
47
|
-
"lib/wrest/components/translators/content_types.rb",
|
|
48
|
-
"lib/wrest/components/translators/json.rb",
|
|
49
|
-
"lib/wrest/components/translators/xml.rb",
|
|
50
|
-
"lib/wrest/core_ext/hash.rb",
|
|
51
|
-
"lib/wrest/core_ext/hash/conversions.rb",
|
|
52
|
-
"lib/wrest/core_ext/string.rb",
|
|
53
|
-
"lib/wrest/core_ext/string/conversions.rb",
|
|
54
|
-
"lib/wrest/curl.rb",
|
|
55
|
-
"lib/wrest/curl/delete.rb",
|
|
56
|
-
"lib/wrest/curl/get.rb",
|
|
57
|
-
"lib/wrest/curl/options.rb",
|
|
58
|
-
"lib/wrest/curl/post.rb",
|
|
59
|
-
"lib/wrest/curl/put.rb",
|
|
60
|
-
"lib/wrest/curl/request.rb",
|
|
61
|
-
"lib/wrest/curl/response.rb",
|
|
62
|
-
"lib/wrest/curl/session.rb",
|
|
63
|
-
"lib/wrest/exceptions.rb",
|
|
64
|
-
"lib/wrest/http_shared.rb",
|
|
65
|
-
"lib/wrest/http_shared/headers.rb",
|
|
66
|
-
"lib/wrest/http_shared/standard_headers.rb",
|
|
67
|
-
"lib/wrest/http_shared/standard_tokens.rb",
|
|
68
|
-
"lib/wrest/multipart.rb",
|
|
69
|
-
"lib/wrest/native.rb",
|
|
70
|
-
"lib/wrest/native/connection_factory.rb",
|
|
71
|
-
"lib/wrest/native/delete.rb",
|
|
72
|
-
"lib/wrest/native/get.rb",
|
|
73
|
-
"lib/wrest/native/options.rb",
|
|
74
|
-
"lib/wrest/native/post.rb",
|
|
75
|
-
"lib/wrest/native/post_multipart.rb",
|
|
76
|
-
"lib/wrest/native/put.rb",
|
|
77
|
-
"lib/wrest/native/put_multipart.rb",
|
|
78
|
-
"lib/wrest/native/redirection.rb",
|
|
79
|
-
"lib/wrest/native/request.rb",
|
|
80
|
-
"lib/wrest/native/response.rb",
|
|
81
|
-
"lib/wrest/native/session.rb",
|
|
82
|
-
"lib/wrest/resource.rb",
|
|
83
|
-
"lib/wrest/resource/base.rb",
|
|
84
|
-
"lib/wrest/resource/collection.rb",
|
|
85
|
-
"lib/wrest/resource/state.rb",
|
|
86
|
-
"lib/wrest/test.rb",
|
|
87
|
-
"lib/wrest/test/request_patches.rb",
|
|
88
|
-
"lib/wrest/uri.rb",
|
|
89
|
-
"lib/wrest/uri_template.rb",
|
|
90
|
-
"lib/wrest/version.rb",
|
|
91
|
-
"spec/custom_matchers/custom_matchers.rb",
|
|
92
|
-
"spec/rcov.opts",
|
|
93
|
-
"spec/spec.opts.disable",
|
|
94
|
-
"spec/unit/spec_helper.rb",
|
|
95
|
-
"spec/unit/wrest/components/attributes_container/alias_accessors_spec.rb",
|
|
96
|
-
"spec/unit/wrest/components/attributes_container/typecaster_spec.rb",
|
|
97
|
-
"spec/unit/wrest/components/attributes_container_spec.rb",
|
|
98
|
-
"spec/unit/wrest/components/mutators/base_spec.rb",
|
|
99
|
-
"spec/unit/wrest/components/mutators/camel_to_snake_spec.rb",
|
|
100
|
-
"spec/unit/wrest/components/mutators/xml_mini_type_caster_spec.rb",
|
|
101
|
-
"spec/unit/wrest/components/mutators/xml_simple_type_caster_spec.rb",
|
|
102
|
-
"spec/unit/wrest/components/mutators_spec.rb",
|
|
103
|
-
"spec/unit/wrest/components/translators/xml_spec.rb",
|
|
104
|
-
"spec/unit/wrest/components/translators_spec.rb",
|
|
105
|
-
"spec/unit/wrest/core_ext/hash/conversions_spec.rb",
|
|
106
|
-
"spec/unit/wrest/core_ext/string/conversions_spec.rb",
|
|
107
|
-
"spec/unit/wrest/curl/request_spec.rb",
|
|
108
|
-
"spec/unit/wrest/curl/response_spec.rb",
|
|
109
|
-
"spec/unit/wrest/http/response_spec.rb",
|
|
110
|
-
"spec/unit/wrest/native/redirection_spec.rb",
|
|
111
|
-
"spec/unit/wrest/native/request_spec.rb",
|
|
112
|
-
"spec/unit/wrest/native/response_spec.rb",
|
|
113
|
-
"spec/unit/wrest/native/session_spec.rb",
|
|
114
|
-
"spec/unit/wrest/resource/base_spec.rb",
|
|
115
|
-
"spec/unit/wrest/uri_spec.rb",
|
|
116
|
-
"spec/unit/wrest/uri_template_spec.rb",
|
|
117
|
-
"wrest.gemspec"
|
|
118
|
-
]
|
|
119
|
-
s.homepage = %q{http://github.com/kaiwren/wrest}
|
|
120
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
|
121
|
-
s.require_paths = ["lib"]
|
|
122
|
-
s.rubyforge_project = %q{wrest}
|
|
123
|
-
s.rubygems_version = %q{1.3.7}
|
|
124
|
-
s.summary = %q{REST client library for Ruby.}
|
|
125
|
-
s.test_files = [
|
|
126
|
-
"spec/custom_matchers/custom_matchers.rb",
|
|
127
|
-
"spec/unit/spec_helper.rb",
|
|
128
|
-
"spec/unit/wrest/components/attributes_container/alias_accessors_spec.rb",
|
|
129
|
-
"spec/unit/wrest/components/attributes_container/typecaster_spec.rb",
|
|
130
|
-
"spec/unit/wrest/components/attributes_container_spec.rb",
|
|
131
|
-
"spec/unit/wrest/components/mutators/base_spec.rb",
|
|
132
|
-
"spec/unit/wrest/components/mutators/camel_to_snake_spec.rb",
|
|
133
|
-
"spec/unit/wrest/components/mutators/xml_mini_type_caster_spec.rb",
|
|
134
|
-
"spec/unit/wrest/components/mutators/xml_simple_type_caster_spec.rb",
|
|
135
|
-
"spec/unit/wrest/components/mutators_spec.rb",
|
|
136
|
-
"spec/unit/wrest/components/translators/xml_spec.rb",
|
|
137
|
-
"spec/unit/wrest/components/translators_spec.rb",
|
|
138
|
-
"spec/unit/wrest/core_ext/hash/conversions_spec.rb",
|
|
139
|
-
"spec/unit/wrest/core_ext/string/conversions_spec.rb",
|
|
140
|
-
"spec/unit/wrest/curl/request_spec.rb",
|
|
141
|
-
"spec/unit/wrest/curl/response_spec.rb",
|
|
142
|
-
"spec/unit/wrest/http/response_spec.rb",
|
|
143
|
-
"spec/unit/wrest/native/redirection_spec.rb",
|
|
144
|
-
"spec/unit/wrest/native/request_spec.rb",
|
|
145
|
-
"spec/unit/wrest/native/response_spec.rb",
|
|
146
|
-
"spec/unit/wrest/native/session_spec.rb",
|
|
147
|
-
"spec/unit/wrest/resource/base_spec.rb",
|
|
148
|
-
"spec/unit/wrest/uri_spec.rb",
|
|
149
|
-
"spec/unit/wrest/uri_template_spec.rb"
|
|
150
|
-
]
|
|
151
|
-
|
|
152
|
-
if s.respond_to? :specification_version then
|
|
153
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
154
|
-
s.specification_version = 3
|
|
155
|
-
|
|
156
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
157
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0.rc"])
|
|
158
|
-
s.add_runtime_dependency(%q<json>, [">= 1.4.2"])
|
|
159
|
-
else
|
|
160
|
-
s.add_dependency(%q<activesupport>, [">= 3.0.0.rc"])
|
|
161
|
-
s.add_dependency(%q<json>, [">= 1.4.2"])
|
|
162
|
-
end
|
|
163
|
-
else
|
|
164
|
-
s.add_dependency(%q<activesupport>, [">= 3.0.0.rc"])
|
|
165
|
-
s.add_dependency(%q<json>, [">= 1.4.2"])
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|