simple_worker 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -217,6 +217,10 @@ module SimpleWorker
217
217
  SimpleWorker.service.schedule_status(schedule_id)
218
218
  end
219
219
 
220
+ def get_log
221
+ SimpleWorker.service.log(task_id)
222
+ end
223
+
220
224
  # Callbacks for developer
221
225
  def before_upload
222
226
 
@@ -48,6 +48,7 @@ module SimpleWorker
48
48
  new_code = true
49
49
  else
50
50
  # puts "#{class_name}: same code, not uploading"
51
+ return
51
52
  end
52
53
 
53
54
 
@@ -120,12 +121,19 @@ module SimpleWorker
120
121
  Zip::ZipFile.open(fname2, 'w') do |f|
121
122
  if merged_gems
122
123
  merged_gems.each do |gem|
124
+ # puts 'gem=' + gem.inspect
123
125
  path = get_gem_path(gem[:name], gem[:version])
124
126
  if path
125
127
  puts "Collecting gem #{path}"
126
128
  Dir["#{path}/**/**"].each do |file|
127
- f.add('gems/'+"#{gem["name"]}/"+ file.sub(path+'/', ''), file)
129
+ # puts 'gem2=' + gem.inspect
130
+ zdest = "gems/#{gem[:name]}/#{file.sub(path+'/', '')}"
131
+ # puts 'gem file=' + file.to_s
132
+ # puts 'zdest=' + zdest
133
+ f.add(zdest, file)
128
134
  end
135
+ else
136
+ raise "Gem #{gem[:name]} #{gem[:version]} was not found."
129
137
  end
130
138
  end
131
139
  end
@@ -0,0 +1,23 @@
1
+ class AwesomeJob < SimpleWorker::Base
2
+ merge_gem 'dropbox'
3
+ # bumpdsfsdfdsfasdf
4
+
5
+ def run
6
+ begin
7
+ s = Dropbox::Session.new('...', '...')
8
+ rescue => ex
9
+ log "Dropbox doesn't like it when you don't have keys"
10
+ end
11
+ # s.mode = :dropbox
12
+ # s.authorizing_user = 'email@gmail.com'
13
+ # s.authorizing_password = '...'
14
+ # s.authorize!
15
+ #
16
+ # tmp_file = Tempfile.new('myfile.txt')
17
+ # tmp_file.write("blahblah")
18
+ # tmp_file.close
19
+ #
20
+ # s.upload tmp_file.path, 'Test'
21
+ # tmp_file.unlink
22
+ end
23
+ end
data/test/test_base.rb CHANGED
@@ -29,4 +29,29 @@ class TestBase < Test::Unit::TestCase
29
29
 
30
30
  end
31
31
  end
32
+
33
+ def wait_for_task(params={})
34
+ tries = 0
35
+ status = nil
36
+ sleep 1
37
+ while tries < 60
38
+ status = status_for(params)
39
+ puts 'status = ' + status.inspect
40
+ if status["status"] == "complete" || status["status"] == "error"
41
+ break
42
+ end
43
+ sleep 2
44
+ end
45
+ status
46
+ end
47
+
48
+ def status_for(ob)
49
+ if ob.is_a?(Hash)
50
+ ob[:schedule_id] ? WORKER.schedule_status(ob[:schedule_id]) : WORKER.status(ob[:task_id])
51
+ else
52
+ ob.status
53
+ end
54
+ end
55
+
56
+
32
57
  end
data/test/test_gems.rb ADDED
@@ -0,0 +1,18 @@
1
+ require_relative 'test_base'
2
+ require_relative 'awesome_job'
3
+
4
+
5
+ class TestGems < TestBase
6
+
7
+ def test_dropbox_gem
8
+
9
+ worker = AwesomeJob.new
10
+ worker.queue
11
+
12
+ wait_for_task(worker)
13
+
14
+ puts 'log=' + worker.get_log
15
+
16
+ end
17
+
18
+ end
@@ -98,30 +98,6 @@ class SimpleWorkerTests < TestBase
98
98
  end
99
99
 
100
100
 
101
- def wait_for_task(params={})
102
- tries = 0
103
- status = nil
104
- sleep 1
105
- while tries < 60
106
- status = status_for(params)
107
- puts 'status = ' + status.inspect
108
- if status["status"] == "complete" || status["status"] == "error"
109
- break
110
- end
111
- sleep 2
112
- end
113
- status
114
- end
115
-
116
- def status_for(ob)
117
- if ob.is_a?(Hash)
118
- ob[:schedule_id] ? WORKER.schedule_status(ob[:schedule_id]) : WORKER.status(ob[:task_id])
119
- else
120
- ob.status
121
- end
122
- end
123
-
124
-
125
101
  def test_require_relative_merge
126
102
 
127
103
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 4
9
- version: 0.5.4
8
+ - 5
9
+ version: 0.5.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Travis Reeder
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-26 00:00:00 -07:00
17
+ date: 2011-03-27 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -63,6 +63,7 @@ files:
63
63
  - lib/simple_worker/used_in_worker.rb
64
64
  - rails/init.rb
65
65
  - README.markdown
66
+ - test/awesome_job.rb
66
67
  - test/cool_model.rb
67
68
  - test/cool_worker.rb
68
69
  - test/db_worker.rb
@@ -72,6 +73,7 @@ files:
72
73
  - test/scheduled_worker.rb
73
74
  - test/second_worker.rb
74
75
  - test/test_base.rb
76
+ - test/test_gems.rb
75
77
  - test/test_inheritance.rb
76
78
  - test/test_no_config.rb
77
79
  - test/test_simple_worker.rb
@@ -113,6 +115,7 @@ signing_key:
113
115
  specification_version: 3
114
116
  summary: The official SimpleWorker gem for http://www.simpleworker.com
115
117
  test_files:
118
+ - test/awesome_job.rb
116
119
  - test/cool_model.rb
117
120
  - test/cool_worker.rb
118
121
  - test/db_worker.rb
@@ -122,6 +125,7 @@ test_files:
122
125
  - test/scheduled_worker.rb
123
126
  - test/second_worker.rb
124
127
  - test/test_base.rb
128
+ - test/test_gems.rb
125
129
  - test/test_inheritance.rb
126
130
  - test/test_no_config.rb
127
131
  - test/test_simple_worker.rb