simple_worker 0.3.16 → 0.3.17
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +3 -1
- data/lib/rails2_init.rb +1 -0
- data/lib/railtie.rb +1 -1
- data/lib/simple_worker/config.rb +3 -1
- data/lib/simple_worker/service.rb +9 -0
- data/test/test_simple_worker.rb +7 -1
- data/test/test_worker_2.rb +1 -1
- metadata +2 -2
data/README.markdown
CHANGED
@@ -98,12 +98,14 @@ Logging
|
|
98
98
|
|
99
99
|
log "Starting to do something..."
|
100
100
|
|
101
|
+
The log will be available for viewing via the SimpleWorker UI or via log in the API.
|
101
102
|
|
102
103
|
Setting Progress
|
103
104
|
----------------
|
104
105
|
|
105
|
-
set_progress(:percent =>
|
106
|
+
set_progress(:percent => 25, :message => "We are a quarter of the way there!")
|
106
107
|
|
108
|
+
You can actually put anything in this hash and it will be returned with a call to status.
|
107
109
|
|
108
110
|
|
109
111
|
Schedule a Recurring Job - CRON
|
data/lib/rails2_init.rb
CHANGED
@@ -3,5 +3,6 @@ SimpleWorker.configure do |config|
|
|
3
3
|
path = File.join(Rails.root, 'app/models/*.rb')
|
4
4
|
puts 'path=' + path
|
5
5
|
config.models = Dir.glob(path)
|
6
|
+
config.extra_requires += ['active_support/core_ext', 'active_record', 'action_mailer']
|
6
7
|
puts 'config.models=' + config.models.inspect
|
7
8
|
end
|
data/lib/railtie.rb
CHANGED
@@ -11,10 +11,10 @@ module SimpleWorker
|
|
11
11
|
puts 'railtie'
|
12
12
|
puts "Initializing list of Rails models..."
|
13
13
|
SimpleWorker.configure do |c2|
|
14
|
-
# path = File.join(File.dirname(caller[0]), '..', 'app/models/*.rb')
|
15
14
|
path = File.join(Rails.root, 'app/models/*.rb')
|
16
15
|
puts 'path=' + path
|
17
16
|
c2.models = Dir.glob(path)
|
17
|
+
config.extra_requires += ['active_support/core_ext', 'active_record', 'action_mailer']
|
18
18
|
puts 'config.models=' + c2.models.inspect
|
19
19
|
end
|
20
20
|
|
data/lib/simple_worker/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
1
3
|
module SimpleWorker
|
2
4
|
|
3
5
|
class Service < Appoxy::Api::Client
|
@@ -46,6 +48,8 @@ module SimpleWorker
|
|
46
48
|
file = File.open(filename, "r") do |f|
|
47
49
|
mystring = f.read
|
48
50
|
end
|
51
|
+
# mystring = Base64.encode64(mystring)
|
52
|
+
# puts 'code=' + mystring
|
49
53
|
options = {"code"=>mystring, "class_name"=>class_name}
|
50
54
|
ret = post("code/put", options)
|
51
55
|
ret
|
@@ -60,6 +64,11 @@ module SimpleWorker
|
|
60
64
|
# puts 'fname2=' + fname2
|
61
65
|
# puts 'merged_file_array=' + merge.inspect
|
62
66
|
File.open(fname2, "w") do |f|
|
67
|
+
if SimpleWorker.config.extra_requires
|
68
|
+
SimpleWorker.config.extra_requires.each do |r|
|
69
|
+
f.write "require '#{r}'\n"
|
70
|
+
end
|
71
|
+
end
|
63
72
|
merge.each do |m|
|
64
73
|
puts "merging #{m} into #{filename}"
|
65
74
|
f.write File.open(m, 'r') { |mo| mo.read }
|
data/test/test_simple_worker.rb
CHANGED
@@ -21,8 +21,14 @@ class SimpleWorkerTests < TestBase
|
|
21
21
|
|
22
22
|
# queue up a task
|
23
23
|
puts 'queuing ' + tw.inspect
|
24
|
-
response_hash_single = tw.queue
|
25
24
|
|
25
|
+
50.times do |i|
|
26
|
+
begin
|
27
|
+
response_hash_single = tw.queue
|
28
|
+
rescue => ex
|
29
|
+
puts ex.message
|
30
|
+
end
|
31
|
+
end
|
26
32
|
|
27
33
|
puts 'response_hash=' + response_hash_single.inspect
|
28
34
|
puts 'task_set_id=' + tw.task_set_id
|
data/test/test_worker_2.rb
CHANGED