simplews 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rake_pipeline.rb +5 -0
- data/lib/simplews/jobs.rb +10 -0
- data/lib/simplews.rb +47 -5
- metadata +1 -1
data/lib/rake_pipeline.rb
CHANGED
@@ -182,6 +182,11 @@ module Rake::Pipeline
|
|
182
182
|
$_current_job.send(symbol, *args)
|
183
183
|
end
|
184
184
|
else
|
185
|
+
# Announce steps
|
186
|
+
def step(state, message ="")
|
187
|
+
puts "#{ state }: #{ message }"
|
188
|
+
end
|
189
|
+
|
185
190
|
# Add values to the info file
|
186
191
|
def info(values = {})
|
187
192
|
info = Rake::Pipeline::Info.load_info(@@current_task)
|
data/lib/simplews/jobs.rb
CHANGED
@@ -365,6 +365,11 @@ class SimpleWS::Jobs < SimpleWS
|
|
365
365
|
end
|
366
366
|
|
367
367
|
def task(name, params=[], types={}, results = [], &block)
|
368
|
+
STEP_DESCRIPTIONS[name.to_s] ||= @@last_description
|
369
|
+
PARAMETER_DESCRIPTIONS[name.to_s] ||= @@last_param_description
|
370
|
+
@@last_description = nil
|
371
|
+
@@last_param_description = nil
|
372
|
+
|
368
373
|
Scheduler.task name, results, block
|
369
374
|
serve name.to_s, params + ['suggested_name'], types.merge(:suggested_name => 'string', :return => :string) do |*args|
|
370
375
|
Scheduler.run name, *args
|
@@ -373,6 +378,11 @@ class SimpleWS::Jobs < SimpleWS
|
|
373
378
|
|
374
379
|
@@tasks = {}
|
375
380
|
def self.task(name, params=[], types={}, results =[], &block)
|
381
|
+
STEP_DESCRIPTIONS[name.to_s] ||= @@last_description
|
382
|
+
PARAMETER_DESCRIPTIONS[name.to_s] ||= @@last_param_description
|
383
|
+
@@last_description = nil
|
384
|
+
@@last_param_description = nil
|
385
|
+
|
376
386
|
Scheduler.task name, results, block
|
377
387
|
@@tasks[name] = {:params => params, :types => types};
|
378
388
|
end
|
data/lib/simplews.rb
CHANGED
@@ -109,6 +109,7 @@ class SimpleWS < SOAP::RPC::StandaloneServer
|
|
109
109
|
|
110
110
|
puts "Server #{ name } at #{ host }:#{ port }"
|
111
111
|
|
112
|
+
desc "Return the WSDL describing the web server"
|
112
113
|
serve :wsdl, %w(), :return => :string
|
113
114
|
METHODS.each{|name, info|
|
114
115
|
serve name, info[:args], info[:types], &info[:block]
|
@@ -121,8 +122,32 @@ class SimpleWS < SOAP::RPC::StandaloneServer
|
|
121
122
|
default_namespace = "urn:#{name}"
|
122
123
|
end
|
123
124
|
|
124
|
-
|
125
|
+
# Add a description for the next method served.
|
126
|
+
@@last_description = nil
|
127
|
+
@@last_param_description = nil
|
128
|
+
STEP_DESCRIPTIONS = {}
|
129
|
+
PARAMETER_DESCRIPTIONS = {}
|
130
|
+
def desc(text)
|
131
|
+
@@last_description = text
|
132
|
+
end
|
125
133
|
|
134
|
+
# Add descriptions for the parameters of the next method served
|
135
|
+
def param_desc(param_descriptions)
|
136
|
+
@@last_param_description = {}
|
137
|
+
param_descriptions.each{|param, description| @@last_param_description[param.to_s] = description}
|
138
|
+
end
|
139
|
+
|
140
|
+
# Add a description for the next method served defined in at the class level
|
141
|
+
def self.desc(text)
|
142
|
+
@@last_description = text
|
143
|
+
end
|
144
|
+
|
145
|
+
# Add descriptions for the parameters of the next method served at the class
|
146
|
+
# level
|
147
|
+
def self.param_desc(param_descriptions)
|
148
|
+
@@last_param_description = {}
|
149
|
+
param_descriptions.each{|param, description| @@last_param_description[param.to_s] = description}
|
150
|
+
end
|
126
151
|
|
127
152
|
# This method tells the server to provide a method named by the +name+
|
128
153
|
# parameter, with arguments listed in the +args+ parameter. The
|
@@ -138,7 +163,10 @@ class SimpleWS < SOAP::RPC::StandaloneServer
|
|
138
163
|
# method is taken to return no value. Other than that, if a parameter
|
139
164
|
# type is omitted it is taken to be :string.
|
140
165
|
def serve(name, args=[], types={}, &block)
|
141
|
-
|
166
|
+
STEP_DESCRIPTIONS[name] ||= @@last_description
|
167
|
+
PARAMETER_DESCRIPTIONS[name] ||= @@last_param_description
|
168
|
+
@@last_description = nil
|
169
|
+
@@last_param_description = nil
|
142
170
|
if block
|
143
171
|
inline_name = "_inline_" + name.to_s
|
144
172
|
add_to_ruby(inline_name, &block)
|
@@ -156,6 +184,10 @@ class SimpleWS < SOAP::RPC::StandaloneServer
|
|
156
184
|
# instance check if there where any methods declared to be served in the class
|
157
185
|
# and add them.
|
158
186
|
def self.serve(name, args=[], types={}, &block)
|
187
|
+
STEP_DESCRIPTIONS[name] ||= @@last_description
|
188
|
+
PARAMETER_DESCRIPTIONS[name] ||= @@last_param_description
|
189
|
+
@@last_description = nil
|
190
|
+
@@last_param_description = nil
|
159
191
|
METHODS[name] = {:args => args, :types => types, :block => block}
|
160
192
|
end
|
161
193
|
|
@@ -193,20 +225,30 @@ class SimpleWS < SOAP::RPC::StandaloneServer
|
|
193
225
|
args.each{|param|
|
194
226
|
type = types[param.to_s] || types[param.to_sym] || :string
|
195
227
|
type = type.to_sym
|
196
|
-
xml.part :name => param, :type => TYPES2WSDL[type]
|
228
|
+
xml.part :name => param, :type => TYPES2WSDL[type] do
|
229
|
+
if PARAMETER_DESCRIPTIONS[name] && PARAMETER_DESCRIPTIONS[name][param.to_s]
|
230
|
+
xml.documentation PARAMETER_DESCRIPTIONS[name][param.to_s]
|
231
|
+
end
|
232
|
+
end
|
197
233
|
}
|
198
234
|
end
|
199
235
|
@messages << message
|
236
|
+
|
200
237
|
message = Builder::XmlMarkup.new(:indent => 2).message :name => "#{ name }Response" do |xml|
|
201
238
|
type = types[:return] || types["return"] || :string
|
202
239
|
if type
|
203
240
|
type = type.to_sym
|
204
|
-
|
205
|
-
|
241
|
+
end
|
242
|
+
xml.part :name => 'return', :type => TYPES2WSDL[type] do
|
243
|
+
if PARAMETER_DESCRIPTIONS[name] && PARAMETER_DESCRIPTIONS[name]['return']
|
244
|
+
xml.documentation PARAMETER_DESCRIPTIONS[name]['return']
|
245
|
+
end
|
246
|
+
end
|
206
247
|
end
|
207
248
|
@messages << message
|
208
249
|
|
209
250
|
operation = Builder::XmlMarkup.new(:indent => 2).operation :name => "#{ name }" do |xml|
|
251
|
+
xml.documentation STEP_DESCRIPTIONS[name] if STEP_DESCRIPTIONS[name]
|
210
252
|
xml.input :message => "tns:#{ name }Request"
|
211
253
|
xml.output :message => "tns:#{ name }Response"
|
212
254
|
end
|