simplews 1.7.0 → 1.7.1

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.
Files changed (3) hide show
  1. data/lib/simplews.rb +8 -6
  2. data/lib/simplews/jobs.rb +28 -1
  3. metadata +2 -2
@@ -110,6 +110,7 @@ class SimpleWS < SOAP::RPC::StandaloneServer
110
110
  puts "Server #{ name } at #{ host }:#{ port }"
111
111
 
112
112
  desc "Return the WSDL describing the web server"
113
+ param_desc :return => "WSDL description"
113
114
  serve :wsdl, %w(), :return => :string
114
115
  METHODS.each{|name, info|
115
116
  serve name, info[:args], info[:types], &info[:block]
@@ -127,24 +128,24 @@ class SimpleWS < SOAP::RPC::StandaloneServer
127
128
  @@last_param_description = nil
128
129
  STEP_DESCRIPTIONS = {}
129
130
  PARAMETER_DESCRIPTIONS = {}
130
- def desc(text)
131
+ def desc(text = "")
131
132
  @@last_description = text
132
133
  end
133
134
 
134
135
  # Add descriptions for the parameters of the next method served
135
- def param_desc(param_descriptions)
136
+ def param_desc(param_descriptions = {})
136
137
  @@last_param_description = {}
137
138
  param_descriptions.each{|param, description| @@last_param_description[param.to_s] = description}
138
139
  end
139
140
 
140
141
  # Add a description for the next method served defined in at the class level
141
- def self.desc(text)
142
+ def self.desc(text = "")
142
143
  @@last_description = text
143
144
  end
144
145
 
145
146
  # Add descriptions for the parameters of the next method served at the class
146
147
  # level
147
- def self.param_desc(param_descriptions)
148
+ def self.param_desc(param_descriptions = {})
148
149
  @@last_param_description = {}
149
150
  param_descriptions.each{|param, description| @@last_param_description[param.to_s] = description}
150
151
  end
@@ -235,15 +236,16 @@ class SimpleWS < SOAP::RPC::StandaloneServer
235
236
  @messages << message
236
237
 
237
238
  message = Builder::XmlMarkup.new(:indent => 2).message :name => "#{ name }Response" do |xml|
238
- type = types[:return] || types["return"] || :string
239
+ type = [types[:return], types["return"]].compact.first
240
+ type = :string if type.nil?
239
241
  if type
240
242
  type = type.to_sym
241
- end
242
243
  xml.part :name => 'return', :type => TYPES2WSDL[type] do
243
244
  if PARAMETER_DESCRIPTIONS[name] && PARAMETER_DESCRIPTIONS[name]['return']
244
245
  xml.documentation PARAMETER_DESCRIPTIONS[name]['return']
245
246
  end
246
247
  end
248
+ end
247
249
  end
248
250
  @messages << message
249
251
 
@@ -369,6 +369,7 @@ class SimpleWS::Jobs < SimpleWS
369
369
  PARAMETER_DESCRIPTIONS[name.to_s] ||= @@last_param_description
370
370
  @@last_description = nil
371
371
  @@last_param_description = nil
372
+ PARAMETER_DESCRIPTIONS[name.to_s]['return'] ||= 'Job identifier' if PARAMETER_DESCRIPTIONS[name.to_s]
372
373
 
373
374
  Scheduler.task name, results, block
374
375
  serve name.to_s, params + ['suggested_name'], types.merge(:suggested_name => 'string', :return => :string) do |*args|
@@ -382,6 +383,10 @@ class SimpleWS::Jobs < SimpleWS
382
383
  PARAMETER_DESCRIPTIONS[name.to_s] ||= @@last_param_description
383
384
  @@last_description = nil
384
385
  @@last_param_description = nil
386
+ if PARAMETER_DESCRIPTIONS[name.to_s]
387
+ PARAMETER_DESCRIPTIONS[name.to_s]['return'] ||= 'Job identifier'
388
+ PARAMETER_DESCRIPTIONS[name.to_s]['suggested_name'] ||= 'Suggested name for the job'
389
+ end
385
390
 
386
391
  Scheduler.task name, results, block
387
392
  @@tasks[name] = {:params => params, :types => types};
@@ -408,44 +413,66 @@ class SimpleWS::Jobs < SimpleWS
408
413
  end
409
414
  }
410
415
 
416
+
417
+ desc "Return the names of the jobs in the queue"
418
+ param_desc :return => "Array of job names"
411
419
  serve :queue, [], :return => :array do
412
420
  Scheduler.queue.collect{|info| info[:name]}
413
421
  end
414
422
 
423
+ desc "Check the status of a job"
424
+ param_desc :job => "Job identifier", :return => "Status code. Special status codes are: 'queue', 'done', 'error', and 'aborted'"
415
425
  serve :status, ['job'], :job => :string, :return => :string do |job|
416
426
  Scheduler.job_info(job)[:status].to_s
417
427
  end
418
428
 
429
+ desc "Return an array with the messages issued by the job"
430
+ param_desc :job => "Job identifier", :return => "Array with message strings"
419
431
  serve :messages, ['job'], :job => :string, :return => :array do |job|
420
432
  Scheduler.job_info(job)[:messages]
421
433
  end
422
434
 
435
+ desc "Return a YAML string containing arbitrary information set up by the job"
436
+ param_desc :job => "Job identifier", :return => "Hash with arbitrary values in YAML format"
423
437
  serve :info, ['job'], :job => :string, :return => :string do |job|
424
438
  Scheduler.job_info(job)[:info].to_yaml
425
439
  end
426
440
 
427
- serve :abort, %w(job), :job => :string do |job|
441
+ desc "Abort the job"
442
+ param_desc :job => "Job identifier"
443
+ serve :abort, %w(job), :job => :string, :return => false do |job|
428
444
  Scheduler.abort(job)
429
445
  end
430
446
 
447
+ desc "Check if the job is done. Could have finished successfully, with error, or have been aborted"
448
+ param_desc :job => "Job identifier", :return => "True if the job has status 'done', 'error' or 'aborted'"
431
449
  serve :done, %w(job), :job => :string, :return => :boolean do |job|
432
450
  [:done, :error, :aborted].include? Scheduler.job_info(job)[:status].to_sym
433
451
  end
434
452
 
453
+ desc "Check if the job has finished with error. The last message is the error message"
454
+ param_desc :job => "Job identifier", :return => "True if the job has status 'error'"
435
455
  serve :error, %w(job), :job => :string, :return => :boolean do |job|
436
456
  Scheduler.job_info(job)[:status] == :error
437
457
  end
438
458
 
459
+ desc "Check if the job has been aborted"
460
+ param_desc :job => "Job identifier", :return => "True if the job has status 'aborted'"
439
461
  serve :aborted, %w(job), :job => :string, :return => :boolean do |job|
440
462
  Scheduler.job_info(job)[:status] == :aborted
441
463
  end
442
464
 
465
+ desc "Return an array with result identifiers to be used with the 'result' operation. The content of the results depends
466
+ on the task"
467
+ param_desc :job => "Job identifier", :return => "Array of result identifiers"
443
468
  serve :results, %w(job), :return => :array do |job|
444
469
  results = Scheduler.job_results(job)
445
470
  @results.merge! Hash[*results.flatten]
446
471
  results.collect{|p| p[0]}
447
472
  end
448
473
 
474
+ desc "Return the content of the result specified by the result identifier. These identifiers are retrieve using the 'results' operation"
475
+ param_desc :result => "Result identifier", :return => "Content of the result file, in Base64 encoding for compatibility"
449
476
  serve :result, %w(result), :return => :binary do |result|
450
477
  path = @results[result]
451
478
  raise ResultNotFound unless File.exist? path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplews
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-30 00:00:00 +01:00
12
+ date: 2009-12-31 00:00:00 +01:00
13
13
  default_executable: start_ws
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency