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/Rakefile
DELETED
@@ -1,495 +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
|
-
# Note that some optional libraries/gems that the build (not Wrest itself) uses may not be available on all implementations of Ruby.
|
11
|
-
puts "Building on Ruby #{RUBY_VERSION}, #{RUBY_RELEASE_DATE}, #{RUBY_PLATFORM}"
|
12
|
-
|
13
|
-
if Object.const_defined?('RAILS_ROOT')
|
14
|
-
require File.dirname(__FILE__) + '/../../../config/environment'
|
15
|
-
else
|
16
|
-
require 'rubygems'
|
17
|
-
gem 'rspec'
|
18
|
-
require 'rake'
|
19
|
-
require 'rspec'
|
20
|
-
require 'rspec/core/rake_task'
|
21
|
-
|
22
|
-
begin
|
23
|
-
require 'metric_fu'
|
24
|
-
rescue LoadError
|
25
|
-
puts 'metric_fu is not available. Install it with: gem install jscruggs-metric_fu -s http://gems.github.com'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
desc 'Default: run spec tests.'
|
30
|
-
task :default => 'rspec:unit'
|
31
|
-
|
32
|
-
namespace :rspec do
|
33
|
-
desc "Run all unit specs"
|
34
|
-
RSpec::Core::RakeTask.new(:unit) do |task|
|
35
|
-
task.pattern = 'spec/unit/wrest/**/*_spec.rb'
|
36
|
-
end
|
37
|
-
|
38
|
-
desc "Run all live functional specs - requires sample_rails_app running at 3000 in test environment"
|
39
|
-
RSpec::Core::RakeTask.new(:functional) do |task|
|
40
|
-
task.pattern = 'spec/functional/wrest/**/*_spec.rb'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
begin
|
45
|
-
require 'hanna/rdoctask'
|
46
|
-
rescue LoadError
|
47
|
-
puts 'Hanna not available, using standard Rake rdoctask. Install it with: gem install mislav-hanna.'
|
48
|
-
require 'rake/rdoctask'
|
49
|
-
end
|
50
|
-
desc 'Generate documentation for Wrest'
|
51
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
52
|
-
rdoc.rdoc_dir = 'rdoc'
|
53
|
-
rdoc.title = 'Wrest Documentation'
|
54
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
55
|
-
rdoc.rdoc_files.include('README.rdoc')
|
56
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
-
end
|
58
|
-
|
59
|
-
begin
|
60
|
-
require 'rcov'
|
61
|
-
require 'rcov/rcovtask'
|
62
|
-
desc "Run all specs in spec directory with RCov"
|
63
|
-
RSpec::Core::RakeTask.new(:rcov) do |t|
|
64
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
65
|
-
t.pattern = "spec/unit/wrest/**/*_spec.rb"
|
66
|
-
t.rcov = true
|
67
|
-
t.rcov_opts = lambda do
|
68
|
-
IO.readlines("spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
69
|
-
end
|
70
|
-
# t.verbose = true
|
71
|
-
end
|
72
|
-
rescue LoadError
|
73
|
-
puts "Rcov not available."
|
74
|
-
end
|
75
|
-
|
76
|
-
begin
|
77
|
-
require 'jeweler'
|
78
|
-
Jeweler::Tasks.new do |gemspec|
|
79
|
-
# p Rake::FileList['spec/functional/**/*']
|
80
|
-
gemspec.name = "wrest"
|
81
|
-
gemspec.summary = "REST client library for Ruby."
|
82
|
-
gemspec.description = "Wrest is a HTTP and REST client library which allows you to quickly build well encapsulated, object oriented wrappers around any web service."
|
83
|
-
gemspec.authors = ["Sidu Ponnappa"]
|
84
|
-
gemspec.email = "ckponnappa@gmail.com"
|
85
|
-
gemspec.homepage = "http://github.com/kaiwren/wrest"
|
86
|
-
gemspec.has_rdoc = true
|
87
|
-
gemspec.rubyforge_project = 'wrest'
|
88
|
-
gemspec.executables = ['wrest', 'jwrest']
|
89
|
-
gemspec.require_path = "lib"
|
90
|
-
gemspec.files.exclude *['.gitignore', 'spec/functional']
|
91
|
-
gemspec.test_files.exclude *['.gitignore', 'spec/functional', 'examples']
|
92
|
-
gemspec.add_dependency('activesupport', '>= 3.0.0.rc')
|
93
|
-
case RUBY_PLATFORM
|
94
|
-
when /java/
|
95
|
-
gemspec.add_dependency('json-jruby', '>= 1.4.2')
|
96
|
-
gemspec.add_dependency('nokogiri', '>= 1.3.3')
|
97
|
-
gemspec.platform = 'java'
|
98
|
-
else
|
99
|
-
gemspec.add_dependency('json', '>= 1.4.2')
|
100
|
-
gemspec.platform = Gem::Platform::RUBY
|
101
|
-
end
|
102
|
-
end
|
103
|
-
rescue LoadError
|
104
|
-
puts "Jeweler not available. Install it with: gem install technicalpickles-jeweler -s http://gems.github.com"
|
105
|
-
puts "If you're using JRuby and are having trouble installing jeweler, try installing the git (gem install git) and rubyforge (gem install rubyforge) gems by hand. Also remember to update gems itself (jruby -S gem update --system)."
|
106
|
-
end
|
107
|
-
|
108
|
-
begin
|
109
|
-
require 'rake/contrib/sshpublisher'
|
110
|
-
namespace :rubyforge do
|
111
|
-
|
112
|
-
desc "Release gem and RDoc documentation to RubyForge"
|
113
|
-
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
114
|
-
|
115
|
-
namespace :release do
|
116
|
-
desc "Publish RDoc to RubyForge."
|
117
|
-
task :docs => [:rdoc] do
|
118
|
-
config = YAML.load(
|
119
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
120
|
-
)
|
121
|
-
|
122
|
-
host = "#{config['username']}@rubyforge.org"
|
123
|
-
remote_dir = "/var/www/gforge-projects/wrest/"
|
124
|
-
local_dir = 'rdoc'
|
125
|
-
|
126
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
rescue LoadError
|
131
|
-
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
132
|
-
end
|
133
|
-
|
134
|
-
|
135
|
-
namespace (:benchmark) do
|
136
|
-
desc "Create classes to be used in Wrest::Resource vs. ActiveResource"
|
137
|
-
task :setup_test_classes do
|
138
|
-
require 'active_resource'
|
139
|
-
require 'lib/wrest'
|
140
|
-
|
141
|
-
class Ooga < Wrest::Resource::Base
|
142
|
-
end
|
143
|
-
class Booga < ActiveResource::Base
|
144
|
-
self.site=''
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
desc "Benchmark when objects are created each time before getting data; i.e there are few queries per instantiation"
|
149
|
-
task :create_and_get => :setup_test_classes do |t|
|
150
|
-
|
151
|
-
n = 10000
|
152
|
-
puts "Running #{n} times per report"
|
153
|
-
Benchmark.bmbm(10) do |rpt|
|
154
|
-
rpt.report("Wrest::Resource") do
|
155
|
-
n.times {
|
156
|
-
ooga = Ooga.new(:id => 5, :profession => 'Natural Magician', :enhanced_by => 'Kai Wren')
|
157
|
-
ooga.profession
|
158
|
-
ooga.profession?
|
159
|
-
ooga.enhanced_by
|
160
|
-
ooga.enhanced_by?
|
161
|
-
}
|
162
|
-
end
|
163
|
-
|
164
|
-
rpt.report("ActiveResource") do
|
165
|
-
n.times {
|
166
|
-
booga = Booga.new(:id => 5, :profession => 'Natural Magician', :enhanced_by => 'Kai Wren')
|
167
|
-
booga.profession
|
168
|
-
booga.profession?
|
169
|
-
booga.enhanced_by
|
170
|
-
booga.enhanced_by?
|
171
|
-
}
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
desc "Benchmark when objects are created beforehand; i.e there are many queries per instantiation"
|
177
|
-
task :create_once_and_get => :setup_test_classes do |t|
|
178
|
-
|
179
|
-
n = 10000
|
180
|
-
puts "Running #{n} times per report"
|
181
|
-
|
182
|
-
Benchmark.bmbm(10) do |rpt|
|
183
|
-
rpt.report("Wrest::Resource") do
|
184
|
-
ooga = Ooga.new(:id => 5, :profession => 'Natural Magician', :enhanced_by => 'Kai Wren')
|
185
|
-
|
186
|
-
n.times {
|
187
|
-
ooga.profession
|
188
|
-
ooga.profession?
|
189
|
-
ooga.enhanced_by
|
190
|
-
ooga.enhanced_by?
|
191
|
-
}
|
192
|
-
end
|
193
|
-
|
194
|
-
rpt.report("ActiveResource") do
|
195
|
-
booga = Booga.new(:id => 5, :profession => 'Natural Magician', :enhanced_by => 'Kai Wren')
|
196
|
-
|
197
|
-
n.times {
|
198
|
-
booga.profession
|
199
|
-
booga.profession?
|
200
|
-
booga.enhanced_by
|
201
|
-
booga.enhanced_by?
|
202
|
-
}
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
desc "Benchmark objects respond_to? performance without invocation"
|
208
|
-
task :responds_to_before => :setup_test_classes do |t|
|
209
|
-
|
210
|
-
n = 10000
|
211
|
-
puts "Running #{n} times per report"
|
212
|
-
|
213
|
-
Benchmark.bmbm(10) do |rpt|
|
214
|
-
rpt.report("Wrest::Resource") do
|
215
|
-
ooga = Ooga.new(:id => 5, :profession => 'Natural Magician', :enhanced_by => 'Kai Wren')
|
216
|
-
|
217
|
-
n.times {
|
218
|
-
ooga.respond_to?(:profession)
|
219
|
-
ooga.respond_to?(:profession?)
|
220
|
-
ooga.respond_to?(:profession=)
|
221
|
-
}
|
222
|
-
end
|
223
|
-
|
224
|
-
rpt.report("ActiveResource") do
|
225
|
-
booga = Booga.new(:id => 5, :profession => 'Natural Magician', :enhanced_by => 'Kai Wren')
|
226
|
-
|
227
|
-
n.times {
|
228
|
-
booga.respond_to?(:profession)
|
229
|
-
booga.respond_to?(:profession?)
|
230
|
-
booga.respond_to?(:profession=)
|
231
|
-
}
|
232
|
-
end
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
desc "Benchmark objects respond_to? performance after invocation"
|
237
|
-
task :responds_to_after => :setup_test_classes do |t|
|
238
|
-
|
239
|
-
n = 10000
|
240
|
-
puts "Running #{n} times per report"
|
241
|
-
|
242
|
-
Benchmark.bmbm(10) do |rpt|
|
243
|
-
rpt.report("Wrest::Resource") do
|
244
|
-
ooga = Ooga.new(:id => 5, :profession => 'Natural Magician', :enhanced_by => 'Kai Wren')
|
245
|
-
ooga.profession
|
246
|
-
ooga.profession?
|
247
|
-
ooga.profession = ''
|
248
|
-
|
249
|
-
n.times {
|
250
|
-
ooga.respond_to?(:profession)
|
251
|
-
ooga.respond_to?(:profession?)
|
252
|
-
ooga.respond_to?(:profession=)
|
253
|
-
}
|
254
|
-
end
|
255
|
-
|
256
|
-
rpt.report("ActiveResource") do
|
257
|
-
booga = Booga.new(:id => 5, :profession => 'Natural Magician', :enhanced_by => 'Kai Wren')
|
258
|
-
booga.profession
|
259
|
-
booga.profession?
|
260
|
-
booga.profession = ''
|
261
|
-
|
262
|
-
n.times {
|
263
|
-
booga.respond_to?(:profession)
|
264
|
-
booga.respond_to?(:profession?)
|
265
|
-
booga.respond_to?(:profession=)
|
266
|
-
}
|
267
|
-
end
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
desc "Benchmark keepalive connections (needs functional/sample_rails_app running with class-caching on and keep-alive enabled)"
|
272
|
-
task :keep_alive => :setup_test_classes do
|
273
|
-
n = 20
|
274
|
-
Wrest.logger = Logger.new(File.open("log/benchmark.log", 'a'))
|
275
|
-
Benchmark.bmbm(10) do |rpt|
|
276
|
-
rpt.report("Fresh connections (Connection: Close)") do
|
277
|
-
n.times {
|
278
|
-
'http://localhost:3000/headers'.to_uri.get
|
279
|
-
'http://localhost:3000/lead_bottles.xml?owner=Kai&type=bottle'.to_uri.get
|
280
|
-
}
|
281
|
-
end
|
282
|
-
|
283
|
-
rpt.report("Keep-alive connection (Connection: Keep-Alive)") do
|
284
|
-
Wrest::Native::Session.new('http://localhost:3000'.to_uri) do |session|
|
285
|
-
n.times {
|
286
|
-
session.get '/headers'
|
287
|
-
session.get '/lead_bottles.xml'
|
288
|
-
}
|
289
|
-
end
|
290
|
-
end
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
desc "Benchmark xml deserialisation"
|
295
|
-
task :deserialise_xml => :setup_test_classes do |t|
|
296
|
-
n = 100
|
297
|
-
puts "Deserialising using #{ActiveSupport::XmlMini.backend}"
|
298
|
-
|
299
|
-
Benchmark.bmbm(10) do |rpt|
|
300
|
-
rpt.report("Hash.from_xml") do
|
301
|
-
n.times {
|
302
|
-
Hash.from_xml(serialised_data)
|
303
|
-
}
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
def serialised_data
|
309
|
-
<<-EOXML
|
310
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
311
|
-
<business-units type="array">
|
312
|
-
<business-unit>
|
313
|
-
<company>OogaInc</company>
|
314
|
-
<created-at type="datetime">2008-08-27T16:21:33Z</created-at>
|
315
|
-
<department>FooMeh</department>
|
316
|
-
<id type="integer">1</id>
|
317
|
-
<client-number>0001</client-number>
|
318
|
-
<updated-at type="datetime">2008-08-27T16:21:33Z</updated-at>
|
319
|
-
<accounts type="array">
|
320
|
-
<account>
|
321
|
-
<account-number>1</account-number>
|
322
|
-
<created-at type="datetime">2008-08-27T16:21:33Z</created-at>
|
323
|
-
<id type="integer">1</id>
|
324
|
-
<client-id type="integer">1</client-id>
|
325
|
-
<updated-at type="datetime">2008-08-27T16:21:33Z</updated-at>
|
326
|
-
<client-number>0001</client-number>
|
327
|
-
</account>
|
328
|
-
</accounts>
|
329
|
-
</business-unit>
|
330
|
-
<business-unit>
|
331
|
-
<company>OogaInc</company>
|
332
|
-
<created-at type="datetime">2008-08-27T18:35:22Z</created-at>
|
333
|
-
<department>BoogaBooga</department>
|
334
|
-
<id type="integer">32479</id>
|
335
|
-
<client-number>0002</client-number>
|
336
|
-
<updated-at type="datetime">2008-08-27T18:35:37Z</updated-at>
|
337
|
-
<accounts type="array">
|
338
|
-
<account>
|
339
|
-
<account-number>0</account-number>
|
340
|
-
<created-at type="datetime">2008-08-27T18:36:07Z</created-at>
|
341
|
-
<id type="integer">32479</id>
|
342
|
-
<client-id type="integer">32479</client-id>
|
343
|
-
<updated-at type="datetime">2008-08-27T18:36:12Z</updated-at>
|
344
|
-
<client-number>0002</client-number>
|
345
|
-
</account>
|
346
|
-
</accounts>
|
347
|
-
</business-unit>
|
348
|
-
<business-unit>
|
349
|
-
<company>OogaInc</company>
|
350
|
-
<created-at type="datetime">2008-08-27T16:21:33Z</created-at>
|
351
|
-
<department>Engineering</department>
|
352
|
-
<id type="integer">2</id>
|
353
|
-
<client-number>000101</client-number>
|
354
|
-
<updated-at type="datetime">2008-08-27T16:21:33Z</updated-at>
|
355
|
-
<accounts type="array">
|
356
|
-
<account>
|
357
|
-
<account-number>101</account-number>
|
358
|
-
<created-at type="datetime">2008-08-27T16:21:33Z</created-at>
|
359
|
-
<id type="integer">2</id>
|
360
|
-
<client-id type="integer">2</client-id>
|
361
|
-
<updated-at type="datetime">2008-08-27T16:21:33Z</updated-at>
|
362
|
-
<client-number>000101</client-number>
|
363
|
-
</account>
|
364
|
-
</accounts>
|
365
|
-
</business-unit>
|
366
|
-
<business-unit>
|
367
|
-
<company>OogaInc</company>
|
368
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
369
|
-
<department></department>
|
370
|
-
<id type="integer">3</id>
|
371
|
-
<client-number>0001000</client-number>
|
372
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
373
|
-
<accounts type="array">
|
374
|
-
<account>
|
375
|
-
<account-number>31974</account-number>
|
376
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
377
|
-
<id type="integer">3</id>
|
378
|
-
<client-id type="integer">3</client-id>
|
379
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
380
|
-
<client-number>0001000</client-number>
|
381
|
-
</account>
|
382
|
-
</accounts>
|
383
|
-
</business-unit>
|
384
|
-
<business-unit>
|
385
|
-
<company>OogaInc</company>
|
386
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
387
|
-
<department></department>
|
388
|
-
<id type="integer">4</id>
|
389
|
-
<client-number>0001001</client-number>
|
390
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
391
|
-
<accounts type="array">
|
392
|
-
<account>
|
393
|
-
<account-number>656064</account-number>
|
394
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
395
|
-
<id type="integer">4</id>
|
396
|
-
<client-id type="integer">4</client-id>
|
397
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
398
|
-
<client-number>0001001</client-number>
|
399
|
-
</account>
|
400
|
-
</accounts>
|
401
|
-
</business-unit>
|
402
|
-
<business-unit>
|
403
|
-
<company>OogaInc</company>
|
404
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
405
|
-
<department></department>
|
406
|
-
<id type="integer">5</id>
|
407
|
-
<client-number>0001002</client-number>
|
408
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
409
|
-
<accounts type="array">
|
410
|
-
<account>
|
411
|
-
<account-number>619842</account-number>
|
412
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
413
|
-
<id type="integer">5</id>
|
414
|
-
<client-id type="integer">5</client-id>
|
415
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
416
|
-
<client-number>0001002</client-number>
|
417
|
-
</account>
|
418
|
-
</accounts>
|
419
|
-
</business-unit>
|
420
|
-
<business-unit>
|
421
|
-
<company>OogaInc</company>
|
422
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
423
|
-
<department></department>
|
424
|
-
<id type="integer">6</id>
|
425
|
-
<client-number>0001003</client-number>
|
426
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
427
|
-
<accounts type="array">
|
428
|
-
<account>
|
429
|
-
<account-number>694370</account-number>
|
430
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
431
|
-
<id type="integer">6</id>
|
432
|
-
<client-id type="integer">6</client-id>
|
433
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
434
|
-
<client-number>0001003</client-number>
|
435
|
-
</account>
|
436
|
-
</accounts>
|
437
|
-
</business-unit>
|
438
|
-
<business-unit>
|
439
|
-
<company>OogaInc</company>
|
440
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
441
|
-
<department></department>
|
442
|
-
<id type="integer">7</id>
|
443
|
-
<client-number>0001004</client-number>
|
444
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
445
|
-
<accounts type="array">
|
446
|
-
<account>
|
447
|
-
<account-number>29284</account-number>
|
448
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
449
|
-
<id type="integer">7</id>
|
450
|
-
<client-id type="integer">7</client-id>
|
451
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
452
|
-
<client-number>0001004</client-number>
|
453
|
-
</account>
|
454
|
-
</accounts>
|
455
|
-
</business-unit>
|
456
|
-
<business-unit>
|
457
|
-
<company>OogaInc</company>
|
458
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
459
|
-
<department></department>
|
460
|
-
<id type="integer">8</id>
|
461
|
-
<client-number>0001005</client-number>
|
462
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
463
|
-
<accounts type="array">
|
464
|
-
<account>
|
465
|
-
<account-number>21285</account-number>
|
466
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
467
|
-
<id type="integer">8</id>
|
468
|
-
<client-id type="integer">8</client-id>
|
469
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
470
|
-
<client-number>0001005</client-number>
|
471
|
-
</account>
|
472
|
-
</accounts>
|
473
|
-
</business-unit>
|
474
|
-
<business-unit>
|
475
|
-
<company>OogaInc</company>
|
476
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
477
|
-
<department></department>
|
478
|
-
<id type="integer">9</id>
|
479
|
-
<client-number>0001006</client-number>
|
480
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
481
|
-
<accounts type="array">
|
482
|
-
<account>
|
483
|
-
<account-number>638772</account-number>
|
484
|
-
<created-at type="datetime">2008-08-27T16:21:34Z</created-at>
|
485
|
-
<id type="integer">9</id>
|
486
|
-
<client-id type="integer">9</client-id>
|
487
|
-
<updated-at type="datetime">2008-08-27T16:21:34Z</updated-at>
|
488
|
-
<client-number>0001006</client-number>
|
489
|
-
</account>
|
490
|
-
</accounts>
|
491
|
-
</business-unit>
|
492
|
-
</business-units>
|
493
|
-
EOXML
|
494
|
-
end
|
495
|
-
end
|
data/VERSION.yml
DELETED
data/bin/jwrest
DELETED
data/examples/delicious.rb
DELETED
@@ -1,72 +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.expand_path(File.dirname(__FILE__) + "/../lib/wrest")
|
11
|
-
require 'pp'
|
12
|
-
|
13
|
-
Wrest.logger = Logger.new(STDOUT)
|
14
|
-
Wrest.logger.level = Logger::DEBUG # Set this to Logger::INFO or higher to disable request logging
|
15
|
-
# Wrest.use_curl
|
16
|
-
|
17
|
-
# This example demonstrates the usage of GET, POST, PUT and
|
18
|
-
# DELETE over HTTPS. Its also shows how Wrest::Uris can have
|
19
|
-
# paths extended making accessing an API easy as pie.
|
20
|
-
#
|
21
|
-
# Do remember to change the username and password on line 47
|
22
|
-
# before running this example.
|
23
|
-
#
|
24
|
-
# API reference: http://delicious.com/help/api
|
25
|
-
class Delicious
|
26
|
-
def initialize(options)
|
27
|
-
@uri = "https://api.del.icio.us/v1/posts".to_uri(options)
|
28
|
-
end
|
29
|
-
|
30
|
-
def bookmarks(parameters = {})
|
31
|
-
@uri['/get'].get(parameters)
|
32
|
-
end
|
33
|
-
|
34
|
-
def recent(parameters = {})
|
35
|
-
@uri['/recent'].get(parameters)
|
36
|
-
end
|
37
|
-
|
38
|
-
def bookmark(parameters)
|
39
|
-
@uri['/add'].post_form(parameters)
|
40
|
-
end
|
41
|
-
|
42
|
-
def delete(parameters)
|
43
|
-
@uri['/delete'].delete(parameters)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
account = Delicious.new :username => 'kaiwren', :password => 'fupupp1es'
|
48
|
-
|
49
|
-
puts '*'*20 + "Creating bookmark tagged Rails" + '*'*20
|
50
|
-
|
51
|
-
pp account.bookmark(
|
52
|
-
:url => 'http://blog.sidu.in/search/label/ruby',
|
53
|
-
:description => 'The Ruby related posts on my blog!',
|
54
|
-
:extended => "All posts tagged with 'ruby'",
|
55
|
-
:tags => 'ruby hacking'
|
56
|
-
).deserialise
|
57
|
-
|
58
|
-
puts '*'*20 + "Listing bookmarks tagged Rails on a certain date" + '*'*20
|
59
|
-
|
60
|
-
pp account.bookmarks(:tag => 'rails', :dt => '20090712').deserialise
|
61
|
-
|
62
|
-
puts '*'*20 + "Listing recent bookmarks" + '*'*20
|
63
|
-
|
64
|
-
pp account.recent(:tag => 'ruby').deserialise["posts"]["post"].collect{|bookmark| bookmark['href']}
|
65
|
-
|
66
|
-
puts '*'*20 + "Deleting the bookmark we just created" + '*'*20
|
67
|
-
|
68
|
-
pp account.delete(:url => 'http://blog.sidu.in/search/label/ruby').deserialise
|
69
|
-
|
70
|
-
puts '*'*20 + "Listing recent bookmarks" + '*'*20
|
71
|
-
|
72
|
-
pp account.recent(:tag => 'ruby').deserialise["posts"]["post"].collect{|bookmark| bookmark['href']}
|
data/examples/facebook.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
|
-
require File.expand_path(File.dirname(__FILE__) + "/../lib/wrest")
|
11
|
-
require 'digest/md5'
|
12
|
-
|
13
|
-
Wrest.logger = Logger.new(STDOUT)
|
14
|
-
Wrest.logger.level = Logger::DEBUG # Set this to Logger::INFO or higher to disable request logging
|
15
|
-
# Wrest.use_curl
|
16
|
-
|
17
|
-
include Wrest
|
18
|
-
|
19
|
-
# This example demonstrates fetching a Facebook user's public profile
|
20
|
-
# given his or her Facebook UID. It also shows how strings in the
|
21
|
-
# deserialised response can be easily converted into other objects
|
22
|
-
# using Wrest's typecast feature.
|
23
|
-
|
24
|
-
module Facebook
|
25
|
-
# This key and secret are both fake. To get your own key and secret, create a
|
26
|
-
# Facebook application at http://www.facebook.com/developers/apps.php
|
27
|
-
Config ={
|
28
|
-
:key => '8be7dc2e480d8bf21a58915bad8c362e',
|
29
|
-
:secret => '1a4638b19c393b540fda796f936a25d4',
|
30
|
-
:restserver => 'http://api.facebook.com/restserver.php'
|
31
|
-
}
|
32
|
-
|
33
|
-
module API
|
34
|
-
Defaults = {
|
35
|
-
'v' => '1.0',
|
36
|
-
'format' => 'XML',
|
37
|
-
'api_key' => Config[:key]
|
38
|
-
}
|
39
|
-
|
40
|
-
def self.signature_for(params)
|
41
|
-
# http://wiki.developers.facebook.com/index.php/How_Facebook_Authenticates_Your_Application
|
42
|
-
request_str = params.keys.sort.map{|k| "#{k}=#{params[k]}" }.join
|
43
|
-
Digest::MD5.hexdigest(request_str + Config[:secret])
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.invoke(args)
|
47
|
-
args = API::Defaults.merge(args)
|
48
|
-
Config[:restserver].to_uri.post_form(args.merge('sig' => Facebook::API.signature_for(args))).deserialise
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class Profile
|
53
|
-
include Components::Container
|
54
|
-
typecast :uid => as_integer,
|
55
|
-
:pic_square => lambda{|pic_square| pic_square.to_uri}
|
56
|
-
|
57
|
-
Fields = %w(
|
58
|
-
uid
|
59
|
-
first_name
|
60
|
-
last_name
|
61
|
-
name
|
62
|
-
pic_square
|
63
|
-
).join(', ')
|
64
|
-
|
65
|
-
def self.find(fcbk_uid)
|
66
|
-
hash = Facebook::API.invoke({
|
67
|
-
'method' => 'facebook.users.getInfo',
|
68
|
-
'fields' => Profile::Fields,
|
69
|
-
'uids' => fcbk_uid
|
70
|
-
})
|
71
|
-
|
72
|
-
if hash['error_response']
|
73
|
-
Facebook::Error.new hash['error_response']
|
74
|
-
else
|
75
|
-
self.new hash["users_getInfo_response"]["user"]
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
class Error
|
81
|
-
include Components::Container
|
82
|
-
typecast :error_code => as_integer
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
puts 'Fetching public profile for Facebook user 699497090.'
|
87
|
-
puts 'Note that we use Wrest\'s typecast feature to convert the uid and pic_square fields in the case of a valid result, and the error_msg and error_code fields in the case of an Error to appropriate types from simple strings.'
|
88
|
-
puts
|
89
|
-
|
90
|
-
profile = Facebook::Profile.find('699497090')
|
91
|
-
|
92
|
-
puts "Field\t\t\tData\t\t\tClass"
|
93
|
-
|
94
|
-
if profile.is_a? Facebook::Error
|
95
|
-
puts "Error\t\t\t#{profile.error_msg}\t\t\t#{profile.error_msg.class}"
|
96
|
-
puts "Code\t\t\t#{profile.error_code}\t\t\t#{profile.error_code.class}"
|
97
|
-
else
|
98
|
-
puts "UID\t\t\t#{profile.uid}\t\t\t#{profile.uid.class}"
|
99
|
-
puts "Name\t\t\t#{profile.first_name}\t\t\t#{profile.first_name.class}"
|
100
|
-
puts "Pic Url\t\t\t#{profile.pic_square}\t\t\t#{profile.pic_square.class}"
|
101
|
-
end
|