simplews 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,5 @@
1
+ == 1.3.2 2009-03-21
2
+
1
3
  == 1.3.1 2008-12-20
2
4
 
3
5
  * 1 minor enhancement:
data/Manifest.txt CHANGED
@@ -1,18 +1,18 @@
1
1
  History.txt
2
2
  Manifest.txt
3
3
  PostInstall.txt
4
- README.txt
4
+ README.rdoc
5
5
  Rakefile
6
6
  config/hoe.rb
7
7
  config/requirements.rb
8
8
  lib/simplews.rb
9
9
  lib/simplews/jobs.rb
10
- lib/simplews/version.rb
11
10
  script/console
12
11
  script/destroy
13
12
  script/generate
14
13
  script/txt2html
15
14
  setup.rb
15
+ simplews.gemspec
16
16
  tasks/deployment.rake
17
17
  tasks/environment.rake
18
18
  tasks/website.rake
data/Rakefile CHANGED
@@ -1,4 +1,28 @@
1
- require 'config/requirements'
2
- require 'config/hoe' # setup Hoe + all gem configuration
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
+ require File.dirname(__FILE__) + '/lib/simplews'
3
3
 
4
- Dir['tasks/**/*.rake'].each { |rake| load rake }
4
+ # Generate all the Rake tasks
5
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
+ $hoe = Hoe.new('simplews', SimpleWS::VERSION) do |p|
7
+ p.developer('Miguel Vazquez', 'mikisvaz@yahoo.com')
8
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
+ p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
10
+ p.rubyforge_name = p.name # TODO this is default value
11
+ # p.extra_deps = [
12
+ # ['activesupport','>= 2.0.2'],
13
+ # ]
14
+ p.extra_dev_deps = [
15
+ ['newgem', ">= #{::Newgem::VERSION}"]
16
+ ]
17
+
18
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
19
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
20
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
21
+ p.rsync_args = '-av --delete --ignore-errors'
22
+ end
23
+
24
+ require 'newgem/tasks' # load /tasks/*.rake
25
+ Dir['tasks/**/*.rake'].each { |t| load t }
26
+
27
+ # TODO - want other tests/tasks run by default? Add them to the list
28
+ # task :default => [:spec, :features]
data/lib/simplews/jobs.rb CHANGED
@@ -4,6 +4,8 @@ require 'yaml'
4
4
  require 'drb'
5
5
  require 'singleton'
6
6
  require 'rand'
7
+ require 'zlib'
8
+
7
9
 
8
10
 
9
11
  class SimpleWS::Jobs < SimpleWS
@@ -43,6 +45,8 @@ class SimpleWS::Jobs < SimpleWS
43
45
  name = Scheduler::random_name("job-") unless name =~ /\w/
44
46
 
45
47
  taken = @@names.select{|n| n =~ /^#{ name }(-\d+)?$/}
48
+ taken += Job.taken(name)
49
+ taken = taken.sort.uniq
46
50
  if taken.any?
47
51
  if taken.length == 1
48
52
  return name + '-1'
@@ -134,7 +138,7 @@ class SimpleWS::Jobs < SimpleWS
134
138
  end
135
139
 
136
140
  def self.abort(name)
137
- Process.kill "INT", @@pids[name]
141
+ Process.kill("INT", @@pids[name]) if @@pids[name]
138
142
  end
139
143
 
140
144
  def self.abort_jobs
@@ -165,9 +169,12 @@ class SimpleWS::Jobs < SimpleWS
165
169
  FileUtils.mkdir_p @@savedir unless File.exist? @@savedir
166
170
  end
167
171
 
172
+ def self.taken(name = "")
173
+ Dir.glob(@@savedir + "/#{ name }*.marshal").collect{|n| n.match(/(#{ name }.*).marshal/)[1]}
174
+ end
168
175
  def self.path(file, name)
169
- if file =~ /^\//
170
- file.gsub(/\{JOB\}/)
176
+ if file =~ /^\/|#{@@workdir}/
177
+ file.gsub(/\{JOB\}/, name)
171
178
  else
172
179
  File.join(@@workdir, file.gsub(/\{JOB\}/,name))
173
180
  end
@@ -181,14 +188,22 @@ class SimpleWS::Jobs < SimpleWS
181
188
 
182
189
  def self.job_info(name)
183
190
  info = nil
191
+
192
+ retries = 2
184
193
  begin
185
- sleep 1
186
194
  info = Marshal::load(File.open(File.join(@@savedir,name + '.marshal')))
187
- raise Exception unless info.is_a? Hash
195
+ raise Exception unless info.is_a?(Hash) && info[:info]
188
196
  rescue Exception
189
- raise JobNotFound, "Job with name #{ name } was not found"
197
+ if retries > 0
198
+ retries -= 1
199
+ sleep 1
200
+ retry
201
+ end
202
+ info = nil
190
203
  end
191
204
 
205
+ raise JobNotFound, "Job with name '#{ name }' was not found" if info.nil?
206
+
192
207
  info
193
208
  end
194
209
 
@@ -227,6 +242,10 @@ class SimpleWS::Jobs < SimpleWS
227
242
  fout.close
228
243
  end
229
244
 
245
+ def message(message)
246
+ @state[:messages] << message
247
+ save
248
+ end
230
249
  def step(status, message = nil)
231
250
  @state[:status] = status
232
251
  @state[:messages] << message if message && message != ""
@@ -269,12 +288,14 @@ class SimpleWS::Jobs < SimpleWS
269
288
  save
270
289
  @pid = Process.fork do
271
290
  begin
291
+ puts "Job #{@name} starting with pid #{Process.pid}"
292
+
272
293
  trap(:INT) { raise SimpleWS::Jobs::Aborted }
273
294
  self.send task, *args
274
295
  step :done
275
296
  exit(0)
276
297
  rescue SimpleWS::Jobs::Aborted
277
- step(:aborted)
298
+ step(:aborted, "Job Aborted")
278
299
  exit(-1)
279
300
  rescue Exception
280
301
  if !$!.kind_of? SystemExit
@@ -360,7 +381,7 @@ class SimpleWS::Jobs < SimpleWS
360
381
  end
361
382
 
362
383
  serve :done, %w(job), :job => :string, :return => :boolean do |job|
363
- [:done, :error, :aborted].include? Scheduler.job_info(job)[:status]
384
+ [:done, :error, :aborted].include? Scheduler.job_info(job)[:status].to_sym
364
385
  end
365
386
 
366
387
  serve :error, %w(job), :job => :string, :return => :boolean do |job|
data/lib/simplews.rb CHANGED
@@ -44,6 +44,8 @@ require 'builder'
44
44
 
45
45
 
46
46
  class SimpleWS < SOAP::RPC::StandaloneServer
47
+ VERSION = "1.3.2"
48
+
47
49
 
48
50
  # This is a helper function for clients. Given the +url+ where the
49
51
  # server is listening, as well as the name of the server, it can
@@ -169,8 +171,8 @@ class SimpleWS < SOAP::RPC::StandaloneServer
169
171
  @messages << message
170
172
 
171
173
  operation = Builder::XmlMarkup.new(:indent => 2).operation :name => "#{ name }" do |xml|
172
- xml.input :message => "#{ name }Request"
173
- xml.output :message => "#{ name }Response"
174
+ xml.input :message => "tns:#{ name }Request"
175
+ xml.output :message => "tns:#{ name }Response"
174
176
  end
175
177
 
176
178
  @operations << operation
@@ -244,6 +246,7 @@ EOT
244
246
  :boolean => 'xsd:boolean',
245
247
  :string => 'xsd:string',
246
248
  :integer => 'xsd:integer',
249
+ :float => 'xsd:float',
247
250
  :array => 'tns:ArrayOfString',
248
251
  :hash => 'tns:Map',
249
252
  :binary => 'xsd:base64Binary',
data/simplews.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{simplews}
5
+ s.version = "1.3.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Miguel Vazquez"]
9
+ s.date = %q{2009-06-17}
10
+ s.description = %q{This defines a class that can simplifies creating Web Services. It inherits from soap2r's SOAP::RPC::StandaloneServer and provides a few enhancements, the most important the fact that it is able to produce the WSDL automatically.}
11
+ s.email = ["mikisvaz@yahoo.com"]
12
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "website/index.txt"]
13
+ s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "config/hoe.rb", "config/requirements.rb", "lib/simplews.rb", "lib/simplews/jobs.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "simplews.gemspec", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "test/simplews/test_jobs.rb", "test/test_helper.rb", "test/test_simplews.rb", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.html.erb"]
14
+ s.has_rdoc = true
15
+ s.post_install_message = %q{PostInstall.txt}
16
+ s.rdoc_options = ["--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{simplews}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{This defines a class that can simplifies creating Web Services}
21
+ s.test_files = ["test/test_simplews.rb", "test/test_helper.rb", "test/simplews/test_jobs.rb"]
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_development_dependency(%q<newgem>, [">= 1.2.3"])
29
+ s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
30
+ else
31
+ s.add_dependency(%q<newgem>, [">= 1.2.3"])
32
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
33
+ end
34
+ else
35
+ s.add_dependency(%q<newgem>, [">= 1.2.3"])
36
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
37
+ end
38
+ end
@@ -66,7 +66,7 @@ class TestJobs < Test::Unit::TestCase
66
66
  puts driver.messages(name)
67
67
  assert(driver.aborted(name))
68
68
 
69
- FileUtils.cp "tmp-TestJWS/.save/test-abort.yaml", "tmp-TestJWS/.save/copy.yaml"
69
+ FileUtils.cp "tmp-TestJWS/.save/test-abort.marshal", "tmp-TestJWS/.save/copy.marshal"
70
70
  assert(driver.aborted("copy"))
71
71
 
72
72
  # Test queue
data/test/test_helper.rb CHANGED
@@ -1,5 +1,3 @@
1
1
  require 'test/unit'
2
2
  require File.dirname(__FILE__) + '/../lib/simplews'
3
- require File.dirname(__FILE__) + '/../lib/simplews/asynchronous'
4
- require File.dirname(__FILE__) + '/../lib/simplews/forked'
5
3
  require File.dirname(__FILE__) + '/../lib/simplews/jobs'
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.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
@@ -9,9 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-14 00:00:00 +01:00
12
+ date: 2009-06-17 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: newgem
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.3
24
+ version:
15
25
  - !ruby/object:Gem::Dependency
16
26
  name: hoe
17
27
  type: :development
@@ -22,9 +32,9 @@ dependencies:
22
32
  - !ruby/object:Gem::Version
23
33
  version: 1.8.0
24
34
  version:
25
- description: Simplifies the development of Web Services, producing WSDL automatically for example. Wraps soap4r.
35
+ description: This defines a class that can simplifies creating Web Services. It inherits from soap2r's SOAP::RPC::StandaloneServer and provides a few enhancements, the most important the fact that it is able to produce the WSDL automatically.
26
36
  email:
27
- - miguel.vazquez@fdi.ucm.es
37
+ - mikisvaz@yahoo.com
28
38
  executables: []
29
39
 
30
40
  extensions: []
@@ -33,24 +43,24 @@ extra_rdoc_files:
33
43
  - History.txt
34
44
  - Manifest.txt
35
45
  - PostInstall.txt
36
- - README.txt
46
+ - README.rdoc
37
47
  - website/index.txt
38
48
  files:
39
49
  - History.txt
40
50
  - Manifest.txt
41
51
  - PostInstall.txt
42
- - README.txt
52
+ - README.rdoc
43
53
  - Rakefile
44
54
  - config/hoe.rb
45
55
  - config/requirements.rb
46
56
  - lib/simplews.rb
47
57
  - lib/simplews/jobs.rb
48
- - lib/simplews/version.rb
49
58
  - script/console
50
59
  - script/destroy
51
60
  - script/generate
52
61
  - script/txt2html
53
62
  - setup.rb
63
+ - simplews.gemspec
54
64
  - tasks/deployment.rake
55
65
  - tasks/environment.rake
56
66
  - tasks/website.rake
@@ -63,18 +73,11 @@ files:
63
73
  - website/stylesheets/screen.css
64
74
  - website/template.html.erb
65
75
  has_rdoc: true
66
- homepage: http://simplews.rubyforge.org
67
- post_install_message: |+
68
-
69
- For more information on simplews, see http://simplews.rubyforge.org
70
-
71
- NOTE: Change this information in PostInstall.txt
72
- You can also delete it if you don't want it.
73
-
74
-
76
+ homepage:
77
+ post_install_message: PostInstall.txt
75
78
  rdoc_options:
76
79
  - --main
77
- - README.txt
80
+ - README.rdoc
78
81
  require_paths:
79
82
  - lib
80
83
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -95,7 +98,7 @@ rubyforge_project: simplews
95
98
  rubygems_version: 1.3.1
96
99
  signing_key:
97
100
  specification_version: 2
98
- summary: Simplifies the development of Web Services, producing WSDL automatically for example. Wraps soap4r.
101
+ summary: This defines a class that can simplifies creating Web Services
99
102
  test_files:
100
103
  - test/test_simplews.rb
101
104
  - test/test_helper.rb
@@ -1,10 +0,0 @@
1
- module Simplews
2
- module VERSION #:nodoc:
3
- MAJOR = 1
4
- MINOR = 3
5
- TINY = 1
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- self
9
- end
10
- end
File without changes