simple_worker 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -80,6 +80,13 @@ Let's say someone does something in your app and you want to send an email about
80
80
 
81
81
  This will send it off to the SimpleWorker cloud.
82
82
 
83
+ To queue worker without uploading you could try to do following:
84
+
85
+ data[:attr_encoded] = Base64.encode64({'@to'=>'example@email.com'}.to_json)
86
+ data[:sw_config] = SimpleWorker.config.get_atts_to_send
87
+ SimpleWorker.service.queue('EmailWorker', data)
88
+
89
+
83
90
  Setting Priority
84
91
  ----------------------------------------------
85
92
 
@@ -41,11 +41,15 @@ module SimpleWorker
41
41
  def merge_gem(gem_name, options={})
42
42
  gem_info = SimpleWorker::MergeHelper.create_gem_info(gem_name, options)
43
43
  @merged_gems[gem_name.to_s] = gem_info
44
- #puts 'before require ' + (options[:require] || gem_name)
45
- begin
46
- require gem_info[:require]
47
- rescue LoadError=>ex
48
- raise "Gem #{gem_name} was found, but we could not load the file '#{options[:require] || gem_name}.rb'. You may need to use :require=>x.........."
44
+ reqs = gem_info[:require].is_a?(Array) ? gem_info[:require] : [gem_info[:require]]
45
+ reqs.each do |r|
46
+ r2 = "#{gem_info[:path]}/lib/#{r}"
47
+ begin
48
+ puts 'requiring ' + r2
49
+ require r2
50
+ rescue LoadError=>ex
51
+ raise "Gem #{gem_name} was found, but we could not load the file '#{r2}'. You may need to use :require=>x.........."
52
+ end
49
53
  end
50
54
  end
51
55
 
@@ -151,7 +155,7 @@ module SimpleWorker
151
155
  # puts 'run_local'
152
156
  set_auto_attributes
153
157
  init_database
154
- init_mailer
158
+ init_mailer
155
159
  begin
156
160
  run
157
161
  rescue => ex
@@ -163,11 +167,11 @@ module SimpleWorker
163
167
  end
164
168
  end
165
169
 
166
- def init_mailer
170
+ def init_mailer
167
171
  if SimpleWorker.config.mailer
168
172
  require 'action_mailer'
169
- ActionMailer::Base.raise_delivery_errors = true
170
- ActionMailer::Base.smtp_settings = (SimpleWorker.config.mailer)
173
+ ActionMailer::Base.raise_delivery_errors = true
174
+ ActionMailer::Base.smtp_settings = (SimpleWorker.config.mailer)
171
175
  end
172
176
  end
173
177
 
@@ -162,9 +162,6 @@ job_data.merge!(run_data)
162
162
  #puts 'job_data=' + job_data.inspect
163
163
 
164
164
  sw_config = job_data['sw_config']
165
- init_database_connection(sw_config)
166
- init_mailer(sw_config)
167
-
168
165
  ")
169
166
 
170
167
 
@@ -184,15 +181,6 @@ end
184
181
  "
185
182
  end
186
183
 
187
- if SimpleWorker.config.database && !SimpleWorker.config.database.empty?
188
- f.write "require 'active_record'\n"
189
- end
190
-
191
- if merged_mailers && !merged_mailers.empty?
192
- # todo: isn't 'action_mailer already required in railtie?
193
- f.write "require 'action_mailer'\n"
194
- f.write "ActionMailer::Base.prepend_view_path('templates')\n"
195
- end
196
184
  #if SimpleWorker.config.auto_merge
197
185
  merged_gems.each_pair do |k, gem|
198
186
  SimpleWorker.logger.debug "Bundling gem #{gem[:name]}..."
@@ -214,6 +202,13 @@ end
214
202
  # end
215
203
  end
216
204
 
205
+ if merged_mailers && !merged_mailers.empty?
206
+ # todo: isn't 'action_mailer already required in railtie?
207
+ f.write "require 'action_mailer'\n"
208
+ f.write "init_mailer(sw_config)\n"
209
+ f.write "ActionMailer::Base.prepend_view_path('templates')\n"
210
+ end
211
+ f.write "init_database_connection(sw_config)"
217
212
  if SimpleWorker.config.extra_requires
218
213
  SimpleWorker.config.extra_requires.each do |r|
219
214
  f.write "require '#{r}'\n"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: simple_worker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.12
5
+ version: 1.0.13
6
6
  platform: ruby
7
7
  authors:
8
8
  - Travis Reeder
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-10-13 00:00:00 Z
13
+ date: 2011-10-26 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: zip