pelle-actionwebservice 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +320 -0
- data/MIT-LICENSE +21 -0
- data/README +381 -0
- data/Rakefile +173 -0
- data/TODO +32 -0
- data/examples/googlesearch/README +143 -0
- data/examples/googlesearch/autoloading/google_search_api.rb +50 -0
- data/examples/googlesearch/autoloading/google_search_controller.rb +57 -0
- data/examples/googlesearch/delegated/google_search_service.rb +108 -0
- data/examples/googlesearch/delegated/search_controller.rb +7 -0
- data/examples/googlesearch/direct/google_search_api.rb +50 -0
- data/examples/googlesearch/direct/search_controller.rb +58 -0
- data/examples/metaWeblog/README +17 -0
- data/examples/metaWeblog/apis/blogger_api.rb +60 -0
- data/examples/metaWeblog/apis/blogger_service.rb +34 -0
- data/examples/metaWeblog/apis/meta_weblog_api.rb +67 -0
- data/examples/metaWeblog/apis/meta_weblog_service.rb +48 -0
- data/examples/metaWeblog/controllers/xmlrpc_controller.rb +16 -0
- data/generators/web_service/USAGE +28 -0
- data/generators/web_service/templates/api_definition.rb +5 -0
- data/generators/web_service/templates/controller.rb +8 -0
- data/generators/web_service/templates/functional_test.rb +19 -0
- data/generators/web_service/web_service_generator.rb +29 -0
- data/lib/action_web_service/api.rb +297 -0
- data/lib/action_web_service/base.rb +38 -0
- data/lib/action_web_service/casting.rb +149 -0
- data/lib/action_web_service/client/base.rb +28 -0
- data/lib/action_web_service/client/soap_client.rb +113 -0
- data/lib/action_web_service/client/xmlrpc_client.rb +58 -0
- data/lib/action_web_service/client.rb +3 -0
- data/lib/action_web_service/container/action_controller_container.rb +93 -0
- data/lib/action_web_service/container/delegated_container.rb +86 -0
- data/lib/action_web_service/container/direct_container.rb +69 -0
- data/lib/action_web_service/container.rb +3 -0
- data/lib/action_web_service/dispatcher/abstract.rb +207 -0
- data/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +379 -0
- data/lib/action_web_service/dispatcher.rb +2 -0
- data/lib/action_web_service/invocation.rb +202 -0
- data/lib/action_web_service/protocol/abstract.rb +112 -0
- data/lib/action_web_service/protocol/discovery.rb +37 -0
- data/lib/action_web_service/protocol/soap_protocol/marshaler.rb +242 -0
- data/lib/action_web_service/protocol/soap_protocol.rb +176 -0
- data/lib/action_web_service/protocol/xmlrpc_protocol.rb +122 -0
- data/lib/action_web_service/protocol.rb +4 -0
- data/lib/action_web_service/scaffolding.rb +281 -0
- data/lib/action_web_service/struct.rb +64 -0
- data/lib/action_web_service/support/class_inheritable_options.rb +26 -0
- data/lib/action_web_service/support/signature_types.rb +226 -0
- data/lib/action_web_service/templates/scaffolds/layout.html.erb +65 -0
- data/lib/action_web_service/templates/scaffolds/methods.html.erb +6 -0
- data/lib/action_web_service/templates/scaffolds/parameters.html.erb +29 -0
- data/lib/action_web_service/templates/scaffolds/result.html.erb +30 -0
- data/lib/action_web_service/test_invoke.rb +110 -0
- data/lib/action_web_service/version.rb +9 -0
- data/lib/action_web_service.rb +66 -0
- data/lib/actionwebservice.rb +1 -0
- data/setup.rb +1379 -0
- data/test/abstract_client.rb +183 -0
- data/test/abstract_dispatcher.rb +548 -0
- data/test/abstract_unit.rb +39 -0
- data/test/api_test.rb +102 -0
- data/test/apis/auto_load_api.rb +3 -0
- data/test/apis/broken_auto_load_api.rb +2 -0
- data/test/base_test.rb +42 -0
- data/test/casting_test.rb +94 -0
- data/test/client_soap_test.rb +155 -0
- data/test/client_xmlrpc_test.rb +153 -0
- data/test/container_test.rb +73 -0
- data/test/dispatcher_action_controller_soap_test.rb +138 -0
- data/test/dispatcher_action_controller_xmlrpc_test.rb +59 -0
- data/test/fixtures/db_definitions/mysql.sql +8 -0
- data/test/fixtures/users.yml +12 -0
- data/test/gencov +3 -0
- data/test/invocation_test.rb +185 -0
- data/test/run +6 -0
- data/test/scaffolded_controller_test.rb +146 -0
- data/test/struct_test.rb +52 -0
- data/test/test_invoke_test.rb +112 -0
- metadata +171 -0
data/README
ADDED
@@ -0,0 +1,381 @@
|
|
1
|
+
= Action Web Service -- Serving APIs on rails
|
2
|
+
|
3
|
+
Action Web Service provides a way to publish interoperable web service APIs with
|
4
|
+
Rails without spending a lot of time delving into protocol details.
|
5
|
+
|
6
|
+
|
7
|
+
== Features
|
8
|
+
|
9
|
+
* SOAP RPC protocol support
|
10
|
+
* Dynamic WSDL generation for APIs
|
11
|
+
* XML-RPC protocol support
|
12
|
+
* Clients that use the same API definitions as the server for
|
13
|
+
easy interoperability with other Action Web Service based applications
|
14
|
+
* Type signature hints to improve interoperability with static languages
|
15
|
+
* Active Record model class support in signatures
|
16
|
+
|
17
|
+
|
18
|
+
== Defining your APIs
|
19
|
+
|
20
|
+
You specify the methods you want to make available as API methods in an
|
21
|
+
ActionWebService::API::Base derivative, and then specify this API
|
22
|
+
definition class wherever you want to use that API.
|
23
|
+
|
24
|
+
The implementation of the methods is done separately from the API
|
25
|
+
specification.
|
26
|
+
|
27
|
+
|
28
|
+
==== Method name inflection
|
29
|
+
|
30
|
+
Action Web Service will camelcase the method names according to Rails Inflector
|
31
|
+
rules for the API visible to public callers. What this means, for example,
|
32
|
+
is that the method names in generated WSDL will be camelcased, and callers will
|
33
|
+
have to supply the camelcased name in their requests for the request to
|
34
|
+
succeed.
|
35
|
+
|
36
|
+
If you do not desire this behaviour, you can turn it off with the
|
37
|
+
ActionWebService::API::Base +inflect_names+ option.
|
38
|
+
|
39
|
+
|
40
|
+
==== Inflection examples
|
41
|
+
|
42
|
+
:add => Add
|
43
|
+
:find_all => FindAll
|
44
|
+
|
45
|
+
|
46
|
+
==== Disabling inflection
|
47
|
+
|
48
|
+
class PersonAPI < ActionWebService::API::Base
|
49
|
+
inflect_names false
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
==== API definition example
|
54
|
+
|
55
|
+
class PersonAPI < ActionWebService::API::Base
|
56
|
+
api_method :add, :expects => [:string, :string, :bool], :returns => [:int]
|
57
|
+
api_method :remove, :expects => [:int], :returns => [:bool]
|
58
|
+
end
|
59
|
+
|
60
|
+
==== API usage example
|
61
|
+
|
62
|
+
class PersonController < ActionController::Base
|
63
|
+
web_service_api PersonAPI
|
64
|
+
|
65
|
+
def add
|
66
|
+
end
|
67
|
+
|
68
|
+
def remove
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
== Publishing your APIs
|
74
|
+
|
75
|
+
Action Web Service uses Action Pack to process protocol requests. There are two
|
76
|
+
modes of dispatching protocol requests, _Direct_, and _Delegated_.
|
77
|
+
|
78
|
+
|
79
|
+
=== Direct dispatching
|
80
|
+
|
81
|
+
This is the default mode. In this mode, public controller instance methods
|
82
|
+
implement the API methods, and parameters are passed through to the methods in
|
83
|
+
accordance with the API specification.
|
84
|
+
|
85
|
+
The return value of the method is sent back as the return value to the
|
86
|
+
caller.
|
87
|
+
|
88
|
+
In this mode, a special <tt>api</tt> action is generated in the target
|
89
|
+
controller to unwrap the protocol request, forward it on to the relevant method
|
90
|
+
and send back the wrapped return value. <em>This action must not be
|
91
|
+
overridden.</em>
|
92
|
+
|
93
|
+
==== Direct dispatching example
|
94
|
+
|
95
|
+
class PersonController < ApplicationController
|
96
|
+
web_service_api PersonAPI
|
97
|
+
|
98
|
+
def add
|
99
|
+
end
|
100
|
+
|
101
|
+
def remove
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
class PersonAPI < ActionWebService::API::Base
|
106
|
+
...
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
For this example, protocol requests for +Add+ and +Remove+ methods sent to
|
111
|
+
<tt>/person/api</tt> will be routed to the controller methods +add+ and +remove+.
|
112
|
+
|
113
|
+
|
114
|
+
=== Delegated dispatching
|
115
|
+
|
116
|
+
This mode can be turned on by setting the +web_service_dispatching_mode+ option
|
117
|
+
in a controller to <tt>:delegated</tt>.
|
118
|
+
|
119
|
+
In this mode, the controller contains one or more web service objects (objects
|
120
|
+
that implement an ActionWebService::API::Base definition). These web service
|
121
|
+
objects are each mapped onto one controller action only.
|
122
|
+
|
123
|
+
==== Delegated dispatching example
|
124
|
+
|
125
|
+
class ApiController < ApplicationController
|
126
|
+
web_service_dispatching_mode :delegated
|
127
|
+
|
128
|
+
web_service :person, PersonService.new
|
129
|
+
end
|
130
|
+
|
131
|
+
class PersonService < ActionWebService::Base
|
132
|
+
web_service_api PersonAPI
|
133
|
+
|
134
|
+
def add
|
135
|
+
end
|
136
|
+
|
137
|
+
def remove
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
class PersonAPI < ActionWebService::API::Base
|
142
|
+
...
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
For this example, all protocol requests for +PersonService+ are
|
147
|
+
sent to the <tt>/api/person</tt> action.
|
148
|
+
|
149
|
+
The <tt>/api/person</tt> action is generated when the +web_service+
|
150
|
+
method is called. <em>This action must not be overridden.</em>
|
151
|
+
|
152
|
+
Other controller actions (actions that aren't the target of a +web_service+ call)
|
153
|
+
are ignored for ActionWebService purposes, and can do normal action tasks.
|
154
|
+
|
155
|
+
|
156
|
+
=== Layered dispatching
|
157
|
+
|
158
|
+
This mode can be turned on by setting the +web_service_dispatching_mode+ option
|
159
|
+
in a controller to <tt>:layered</tt>.
|
160
|
+
|
161
|
+
This mode is similar to _delegated_ mode, in that multiple web service objects
|
162
|
+
can be attached to one controller, however, all protocol requests are sent to a
|
163
|
+
single endpoint.
|
164
|
+
|
165
|
+
Use this mode when you want to share code between XML-RPC and SOAP clients,
|
166
|
+
for APIs where the XML-RPC method names have prefixes. An example of such
|
167
|
+
a method name would be <tt>blogger.newPost</tt>.
|
168
|
+
|
169
|
+
|
170
|
+
==== Layered dispatching example
|
171
|
+
|
172
|
+
|
173
|
+
class ApiController < ApplicationController
|
174
|
+
web_service_dispatching_mode :layered
|
175
|
+
|
176
|
+
web_service :mt, MovableTypeService.new
|
177
|
+
web_service :blogger, BloggerService.new
|
178
|
+
web_service :metaWeblog, MetaWeblogService.new
|
179
|
+
end
|
180
|
+
|
181
|
+
class MovableTypeService < ActionWebService::Base
|
182
|
+
...
|
183
|
+
end
|
184
|
+
|
185
|
+
class BloggerService < ActionWebService::Base
|
186
|
+
...
|
187
|
+
end
|
188
|
+
|
189
|
+
class MetaWeblogService < ActionWebService::API::Base
|
190
|
+
...
|
191
|
+
end
|
192
|
+
|
193
|
+
|
194
|
+
For this example, an XML-RPC call for a method with a name like
|
195
|
+
<tt>mt.getCategories</tt> will be sent to the <tt>getCategories</tt>
|
196
|
+
method on the <tt>:mt</tt> service.
|
197
|
+
|
198
|
+
|
199
|
+
== Customizing WSDL generation
|
200
|
+
|
201
|
+
You can customize the names used for the SOAP bindings in the generated
|
202
|
+
WSDL by using the wsdl_service_name option in a controller:
|
203
|
+
|
204
|
+
class WsController < ApplicationController
|
205
|
+
wsdl_service_name 'MyApp'
|
206
|
+
end
|
207
|
+
|
208
|
+
You can also customize the namespace used in the generated WSDL for
|
209
|
+
custom types and message definition types:
|
210
|
+
|
211
|
+
class WsController < ApplicationController
|
212
|
+
wsdl_namespace 'http://my.company.com/app/wsapi'
|
213
|
+
end
|
214
|
+
|
215
|
+
The default namespace used is 'urn:ActionWebService', if you don't supply
|
216
|
+
one.
|
217
|
+
|
218
|
+
|
219
|
+
== ActionWebService and UTF-8
|
220
|
+
|
221
|
+
If you're going to be sending back strings containing non-ASCII UTF-8
|
222
|
+
characters using the <tt>:string</tt> data type, you need to make sure that
|
223
|
+
Ruby is using UTF-8 as the default encoding for its strings.
|
224
|
+
|
225
|
+
The default in Ruby is to use US-ASCII encoding for strings, which causes a string
|
226
|
+
validation check in the Ruby SOAP library to fail and your string to be sent
|
227
|
+
back as a Base-64 value, which may confuse clients that expected strings
|
228
|
+
because of the WSDL.
|
229
|
+
|
230
|
+
Two ways of setting the default string encoding are:
|
231
|
+
|
232
|
+
* Start Ruby using the <tt>-Ku</tt> command-line option to the Ruby executable
|
233
|
+
* Set the <tt>$KCODE</tt> flag in <tt>config/environment.rb</tt> to the
|
234
|
+
string <tt>'UTF8'</tt>
|
235
|
+
|
236
|
+
|
237
|
+
== Testing your APIs
|
238
|
+
|
239
|
+
|
240
|
+
=== Functional testing
|
241
|
+
|
242
|
+
You can perform testing of your APIs by creating a functional test for the
|
243
|
+
controller dispatching the API, and calling #invoke in the test case to
|
244
|
+
perform the invocation.
|
245
|
+
|
246
|
+
Example:
|
247
|
+
|
248
|
+
class PersonApiControllerTest < Test::Unit::TestCase
|
249
|
+
def setup
|
250
|
+
@controller = PersonController.new
|
251
|
+
@request = ActionController::TestRequest.new
|
252
|
+
@response = ActionController::TestResponse.new
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_add
|
256
|
+
result = invoke :remove, 1
|
257
|
+
assert_equal true, result
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
This example invokes the API method <tt>test</tt>, defined on
|
262
|
+
the PersonController, and returns the result.
|
263
|
+
|
264
|
+
If you're not using SOAP (or you're having serialisation difficulties),
|
265
|
+
you can test XMLRPC like this:
|
266
|
+
|
267
|
+
class PersonApiControllerTest < Test::Unit::TestCase
|
268
|
+
def setup
|
269
|
+
@controller = PersonController.new
|
270
|
+
@request = ActionController::TestRequest.new
|
271
|
+
@response = ActionController::TestResponse.new
|
272
|
+
|
273
|
+
@protocol = :xmlrpc # can also be :soap, the default
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_add
|
277
|
+
result = invoke :remove, 1 # no change here
|
278
|
+
assert_equal true, result
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
=== Scaffolding
|
283
|
+
|
284
|
+
You can also test your APIs with a web browser by attaching scaffolding
|
285
|
+
to the controller.
|
286
|
+
|
287
|
+
Example:
|
288
|
+
|
289
|
+
class PersonController
|
290
|
+
web_service_scaffold :invocation
|
291
|
+
end
|
292
|
+
|
293
|
+
This creates an action named <tt>invocation</tt> on the PersonController.
|
294
|
+
|
295
|
+
Navigating to this action lets you select the method to invoke, supply the parameters,
|
296
|
+
and view the result of the invocation.
|
297
|
+
|
298
|
+
|
299
|
+
== Using the client support
|
300
|
+
|
301
|
+
Action Web Service includes client classes that can use the same API
|
302
|
+
definition as the server. The advantage of this approach is that your client
|
303
|
+
will have the same support for Active Record and structured types as the
|
304
|
+
server, and can just use them directly, and rely on the marshaling to Do The
|
305
|
+
Right Thing.
|
306
|
+
|
307
|
+
*Note*: The client support is intended for communication between Ruby on Rails
|
308
|
+
applications that both use Action Web Service. It may work with other servers, but
|
309
|
+
that is not its intended use, and interoperability can't be guaranteed, especially
|
310
|
+
not for .NET web services.
|
311
|
+
|
312
|
+
Web services protocol specifications are complex, and Action Web Service client
|
313
|
+
support can only be guaranteed to work with a subset.
|
314
|
+
|
315
|
+
|
316
|
+
==== Factory created client example
|
317
|
+
|
318
|
+
class BlogManagerController < ApplicationController
|
319
|
+
web_client_api :blogger, :xmlrpc, 'http://url/to/blog/api/RPC2', :handler_name => 'blogger'
|
320
|
+
end
|
321
|
+
|
322
|
+
class SearchingController < ApplicationController
|
323
|
+
web_client_api :google, :soap, 'http://url/to/blog/api/beta', :service_name => 'GoogleSearch'
|
324
|
+
end
|
325
|
+
|
326
|
+
See ActionWebService::API::ActionController::ClassMethods for more details.
|
327
|
+
|
328
|
+
==== Manually created client example
|
329
|
+
|
330
|
+
class PersonAPI < ActionWebService::API::Base
|
331
|
+
api_method :find_all, :returns => [[Person]]
|
332
|
+
end
|
333
|
+
|
334
|
+
soap_client = ActionWebService::Client::Soap.new(PersonAPI, "http://...")
|
335
|
+
persons = soap_client.find_all
|
336
|
+
|
337
|
+
class BloggerAPI < ActionWebService::API::Base
|
338
|
+
inflect_names false
|
339
|
+
api_method :getRecentPosts, :returns => [[Blog::Post]]
|
340
|
+
end
|
341
|
+
|
342
|
+
blog = ActionWebService::Client::XmlRpc.new(BloggerAPI, "http://.../xmlrpc", :handler_name => "blogger")
|
343
|
+
posts = blog.getRecentPosts
|
344
|
+
|
345
|
+
|
346
|
+
See ActionWebService::Client::Soap and ActionWebService::Client::XmlRpc for more details.
|
347
|
+
|
348
|
+
== Dependencies
|
349
|
+
|
350
|
+
Action Web Service requires that the Action Pack and Active Record are either
|
351
|
+
available to be required immediately or are accessible as GEMs.
|
352
|
+
|
353
|
+
It also requires a version of Ruby that includes SOAP support in the standard
|
354
|
+
library. At least version 1.8.2 final (2004-12-25) of Ruby is recommended; this
|
355
|
+
is the version tested against.
|
356
|
+
|
357
|
+
|
358
|
+
== Download
|
359
|
+
|
360
|
+
The latest Action Web Service version can be downloaded from
|
361
|
+
http://rubyforge.org/projects/actionservice
|
362
|
+
|
363
|
+
|
364
|
+
== Installation
|
365
|
+
|
366
|
+
You can install Action Web Service with the following command.
|
367
|
+
|
368
|
+
% [sudo] ruby setup.rb
|
369
|
+
|
370
|
+
|
371
|
+
== License
|
372
|
+
|
373
|
+
Action Web Service is released under the MIT license.
|
374
|
+
|
375
|
+
|
376
|
+
== Support
|
377
|
+
|
378
|
+
The Ruby on Rails mailing list
|
379
|
+
|
380
|
+
Or, to contact the author, send mail to bitserf@gmail.com
|
381
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/contrib/rubyforgepublisher'
|
8
|
+
require 'fileutils'
|
9
|
+
require File.join(File.dirname(__FILE__), 'lib', 'action_web_service', 'version')
|
10
|
+
|
11
|
+
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
12
|
+
PKG_NAME = 'actionwebservice'
|
13
|
+
PKG_VERSION = ActionWebService::VERSION::STRING + PKG_BUILD
|
14
|
+
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
15
|
+
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
|
16
|
+
|
17
|
+
RELEASE_NAME = "REL #{PKG_VERSION}"
|
18
|
+
|
19
|
+
RUBY_FORGE_PROJECT = "aws"
|
20
|
+
RUBY_FORGE_USER = "webster132"
|
21
|
+
|
22
|
+
desc "Default Task"
|
23
|
+
task :default => [ :test ]
|
24
|
+
|
25
|
+
|
26
|
+
# Run the unit tests
|
27
|
+
Rake::TestTask.new { |t|
|
28
|
+
t.libs << "test"
|
29
|
+
t.test_files = Dir['test/*_test.rb']
|
30
|
+
t.verbose = true
|
31
|
+
}
|
32
|
+
|
33
|
+
SCHEMA_PATH = File.join(File.dirname(__FILE__), *%w(test fixtures db_definitions))
|
34
|
+
|
35
|
+
desc 'Build the MySQL test database'
|
36
|
+
task :build_database do
|
37
|
+
%x( mysqladmin -uroot create actionwebservice_unittest )
|
38
|
+
%x( mysql -uroot actionwebservice_unittest < #{File.join(SCHEMA_PATH, 'mysql.sql')} )
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
# Generate the RDoc documentation
|
43
|
+
Rake::RDocTask.new { |rdoc|
|
44
|
+
rdoc.rdoc_dir = 'doc'
|
45
|
+
rdoc.title = "Action Web Service -- Web services for Action Pack"
|
46
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
47
|
+
rdoc.options << '--charset' << 'utf-8'
|
48
|
+
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
49
|
+
rdoc.rdoc_files.include('README')
|
50
|
+
rdoc.rdoc_files.include('CHANGELOG')
|
51
|
+
rdoc.rdoc_files.include('lib/action_web_service.rb')
|
52
|
+
rdoc.rdoc_files.include('lib/action_web_service/*.rb')
|
53
|
+
rdoc.rdoc_files.include('lib/action_web_service/api/*.rb')
|
54
|
+
rdoc.rdoc_files.include('lib/action_web_service/client/*.rb')
|
55
|
+
rdoc.rdoc_files.include('lib/action_web_service/container/*.rb')
|
56
|
+
rdoc.rdoc_files.include('lib/action_web_service/dispatcher/*.rb')
|
57
|
+
rdoc.rdoc_files.include('lib/action_web_service/protocol/*.rb')
|
58
|
+
rdoc.rdoc_files.include('lib/action_web_service/support/*.rb')
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
# Create compressed packages
|
63
|
+
spec = Gem::Specification.new do |s|
|
64
|
+
s.platform = Gem::Platform::RUBY
|
65
|
+
s.name = PKG_NAME
|
66
|
+
s.summary = "Web service support for Action Pack."
|
67
|
+
s.description = %q{Adds WSDL/SOAP and XML-RPC web service support to Action Pack}
|
68
|
+
s.version = PKG_VERSION
|
69
|
+
|
70
|
+
s.author = "Leon Breedt, Kent Sibilev"
|
71
|
+
s.email = "bitserf@gmail.com, ksibilev@yahoo.com"
|
72
|
+
s.rubyforge_project = "aws"
|
73
|
+
s.homepage = "http://www.rubyonrails.org"
|
74
|
+
|
75
|
+
s.add_dependency('actionpack', '= 2.3.2' + PKG_BUILD)
|
76
|
+
s.add_dependency('activerecord', '= 2.3.2' + PKG_BUILD)
|
77
|
+
|
78
|
+
s.has_rdoc = true
|
79
|
+
s.requirements << 'none'
|
80
|
+
s.require_path = 'lib'
|
81
|
+
s.autorequire = 'actionwebservice'
|
82
|
+
|
83
|
+
s.files = [ "Rakefile", "setup.rb", "README", "TODO", "CHANGELOG", "MIT-LICENSE" ]
|
84
|
+
s.files = s.files + Dir.glob( "examples/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) }
|
85
|
+
s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) }
|
86
|
+
s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) }
|
87
|
+
s.files = s.files + Dir.glob( "generators/**/*" ).delete_if { |item| item.match( /\.(svn|git)/ ) }
|
88
|
+
end
|
89
|
+
Rake::GemPackageTask.new(spec) do |p|
|
90
|
+
p.gem_spec = spec
|
91
|
+
p.need_tar = true
|
92
|
+
p.need_zip = true
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
# Publish beta gem
|
97
|
+
desc "Publish the API documentation"
|
98
|
+
task :pgem => [:package] do
|
99
|
+
Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
100
|
+
`ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
|
101
|
+
end
|
102
|
+
|
103
|
+
# Publish documentation
|
104
|
+
desc "Publish the API documentation"
|
105
|
+
task :pdoc => [:rdoc] do
|
106
|
+
Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.org", "public_html/aws", "doc").upload
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
def each_source_file(*args)
|
111
|
+
prefix, includes, excludes, open_file = args
|
112
|
+
prefix ||= File.dirname(__FILE__)
|
113
|
+
open_file = true if open_file.nil?
|
114
|
+
includes ||= %w[lib\/action_web_service\.rb$ lib\/action_web_service\/.*\.rb$]
|
115
|
+
excludes ||= %w[lib\/action_web_service\/vendor]
|
116
|
+
Find.find(prefix) do |file_name|
|
117
|
+
next if file_name =~ /\.svn/
|
118
|
+
file_name.gsub!(/^\.\//, '')
|
119
|
+
continue = false
|
120
|
+
includes.each do |inc|
|
121
|
+
if file_name.match(/#{inc}/)
|
122
|
+
continue = true
|
123
|
+
break
|
124
|
+
end
|
125
|
+
end
|
126
|
+
next unless continue
|
127
|
+
excludes.each do |exc|
|
128
|
+
if file_name.match(/#{exc}/)
|
129
|
+
continue = false
|
130
|
+
break
|
131
|
+
end
|
132
|
+
end
|
133
|
+
next unless continue
|
134
|
+
if open_file
|
135
|
+
File.open(file_name) do |f|
|
136
|
+
yield file_name, f
|
137
|
+
end
|
138
|
+
else
|
139
|
+
yield file_name
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
desc "Count lines of the AWS source code"
|
145
|
+
task :lines do
|
146
|
+
total_lines = total_loc = 0
|
147
|
+
puts "Per File:"
|
148
|
+
each_source_file do |file_name, f|
|
149
|
+
file_lines = file_loc = 0
|
150
|
+
while line = f.gets
|
151
|
+
file_lines += 1
|
152
|
+
next if line =~ /^\s*$/
|
153
|
+
next if line =~ /^\s*#/
|
154
|
+
file_loc += 1
|
155
|
+
end
|
156
|
+
puts " #{file_name}: Lines #{file_lines}, LOC #{file_loc}"
|
157
|
+
total_lines += file_lines
|
158
|
+
total_loc += file_loc
|
159
|
+
end
|
160
|
+
puts "Total:"
|
161
|
+
puts " Lines #{total_lines}, LOC #{total_loc}"
|
162
|
+
end
|
163
|
+
|
164
|
+
desc "Publish the release files to RubyForge."
|
165
|
+
task :release => [ :package ] do
|
166
|
+
require 'rubyforge'
|
167
|
+
|
168
|
+
packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
|
169
|
+
|
170
|
+
rubyforge = RubyForge.new
|
171
|
+
rubyforge.login
|
172
|
+
rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
|
173
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
= Post-1.0
|
2
|
+
- Document/Literal SOAP support
|
3
|
+
- URL-based dispatching, URL identifies method
|
4
|
+
|
5
|
+
- Add :rest dispatching mode, a.l.a. Backpack API. Clean up dispatching
|
6
|
+
in general. Support vanilla XML-format as a "Rails" protocol?
|
7
|
+
XML::Simple deserialization into params?
|
8
|
+
|
9
|
+
web_service_dispatching_mode :rest
|
10
|
+
|
11
|
+
def method1(params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def method2(params)
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
/ws/method1
|
19
|
+
<xml>
|
20
|
+
/ws/method2
|
21
|
+
<yaml>
|
22
|
+
|
23
|
+
- Allow locking down a controller to only accept messages for a particular
|
24
|
+
protocol. This will allow us to generate fully conformant error messages
|
25
|
+
in cases where we currently fudge it if we don't know the protocol.
|
26
|
+
|
27
|
+
- Allow AWS user to participate in typecasting, so they can centralize
|
28
|
+
workarounds for buggy input in one place
|
29
|
+
|
30
|
+
= Refactoring
|
31
|
+
- Don't have clean way to go from SOAP Class object to the xsd:NAME type
|
32
|
+
string -- NaHi possibly looking at remedying this situation
|