simplews 1.5.1 → 1.5.2

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.
data/lib/simplews/jobs.rb CHANGED
@@ -295,6 +295,10 @@ class SimpleWS::Jobs < SimpleWS
295
295
  save
296
296
  end
297
297
 
298
+ def result_filenames
299
+ @state[:results]
300
+ end
301
+
298
302
  def abort
299
303
  raise SimpleWS::Jobs::Aborted
300
304
  save
data/lib/simplews/rake.rb CHANGED
@@ -5,19 +5,24 @@ require 'rake'
5
5
 
6
6
  class SimpleWS::Jobs::Scheduler::Job
7
7
 
8
- def add_message(reg_exp, step, message)
9
- @step_messages ||= {}
10
- @step_messages[Regexp.new(reg_exp)] = "#{ step }: #{ message }"
8
+ # Add step information to rule tasks, as the 'desc' method cannot be used to
9
+ # describe them for the time being.
10
+ def add_description(reg_exp, step, message)
11
+ @step_descriptions ||= {}
12
+ @step_descriptions[Regexp.new(reg_exp)] = "#{ step }: #{ message }"
11
13
  end
12
14
 
15
+ # Instruct rake to load the rakefile, named Rakefile by default, and use it
16
+ # to produce the file specified first as product of the web service task. The
17
+ # 'execute' method of the Rake::Tasks class method execute is monkey-patched
18
+ # to log the steps. Since this is executed on a new process, there should be
19
+ # no side-effects from the patching.
13
20
  def rake(rakefile = "Rakefile")
14
- $_current_job = self
15
- $_step_messages = @step_messages || {}
16
21
  Rake::Task.class_eval <<-'EOC'
17
22
  alias_method :old_execute, :execute
18
23
  def execute(*args)
19
24
  action = name
20
- message = $_step_messages.collect{|rexp, msg|
25
+ message = $_step_desriptions.collect{|rexp, msg|
21
26
  if name.match(rexp)
22
27
  msg
23
28
  else
@@ -39,8 +44,15 @@ class SimpleWS::Jobs::Scheduler::Job
39
44
  end
40
45
  EOC
41
46
 
47
+ $step_descriptions = {}
42
48
  load rakefile
43
- files = SimpleWS::Jobs::Scheduler::Job.job_info(job_name)[:results]
49
+ $step_descriptions.each{|re, info|
50
+ add_description(re, info[:step], info[:message])
51
+ }
52
+ files = result_filenames
53
+
54
+ $_current_job = self
55
+ $_step_desriptions = @step_descriptions || {}
44
56
  Rake::Task[files.first].invoke
45
57
  end
46
58
 
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.5.1
4
+ version: 1.5.2
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-01 00:00:00 +01:00
12
+ date: 2009-12-08 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency