simple_worker 0.3.16 → 0.3.17

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/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 => progress, :message => "Server running. Trying to connect...")
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
 
@@ -15,10 +15,12 @@ module SimpleWorker
15
15
  :host,
16
16
  :global_attributes,
17
17
  :models,
18
- :database
18
+ :database,
19
+ :extra_requires
19
20
 
20
21
  def initialize
21
22
  @global_attributes = {}
23
+ @extra_requires = []
22
24
  end
23
25
 
24
26
  end
@@ -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 }
@@ -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
@@ -5,7 +5,7 @@ rescue Exception => ex
5
5
  require 'simple_worker'
6
6
  end
7
7
 
8
- # Bump for new checksum.sdf
8
+ # Bump for new checksum.sdf adsfjlaksdjf dasfasdfadsf
9
9
  class TestWorker2 < SimpleWorker::Base
10
10
 
11
11
  merge File.join(File.dirname(__FILE__), 'models', 'model_1.rb')
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 16
9
- version: 0.3.16
8
+ - 17
9
+ version: 0.3.17
10
10
  platform: ruby
11
11
  authors:
12
12
  - Travis Reeder