background_worker 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8571c96ec0aca2ab3d9cf9f4fc0aa283152b77af
4
- data.tar.gz: 51694792968c8e536ad250b6384de5d9a5c82c8d
3
+ metadata.gz: fcc18679c11c98ef7f0da1d7d5112004edd1bfb4
4
+ data.tar.gz: 3d4cacb66997222274d85dde11e5787c3fad9ffb
5
5
  SHA512:
6
- metadata.gz: b4c475813fd08d41afe57a2d19ec98ce0646bfc5dd872189fd451adaedf8bee3dca36cccdcf1b8c5ad8fa7402515d84dbf7835f6f1eeb6df4c19d765a8248d4e
7
- data.tar.gz: 81a60b3710d2592f14e150998fa49a1232778f69c9e93a86e0bc5ab11285552f8aaf2636b6082aa324a8ae90659adf96bcee175ab4f88372cbd7d9ce96494259
6
+ metadata.gz: 37680e16cc121d912e38df598045df83c3e8e3fce5dedb168830932ac1e126d3de8fbfdb34860f0806c4999f26f4a891a7589310adfb323a7810aa4e4cab5553
7
+ data.tar.gz: 4002280277529ea9af57c9714d19f1649a920719501e06eb1c9c63c521a295ce4acbb980dc652509f7cd9b10d7257e4725cba829bbb484275c8b17a6eb526967
@@ -9,10 +9,10 @@ module BackgroundWorker
9
9
  def initialize(options = {})
10
10
  Time.zone = Setting.time_zone
11
11
 
12
- @uid = options['uid']
12
+ @uid = options[:uid]
13
13
 
14
14
  # Store state persistently, to enable status checkups & progress reporting
15
- @state = BackgroundWorker::PersistentState.new(@uid, options.except('uid'))
15
+ @state = BackgroundWorker::PersistentState.new(@uid, options.except(:uid))
16
16
  log("Created #{self.class}")
17
17
  log("Options are: #{options.pretty_inspect}")
18
18
  end
@@ -61,16 +61,18 @@ module BackgroundWorker
61
61
 
62
62
  # Public method to do in background...
63
63
  def perform_in_background(method_name, options = {})
64
+ opts = options.symbolize_keys
65
+
64
66
  method_name = method_name.to_sym
65
- options[:uid] ||= BackgroundWorker::Uid.new(to_s, method_name).generate
67
+ opts[:uid] ||= BackgroundWorker::Uid.new(to_s, method_name).generate
66
68
 
67
69
  # Store into shared-cache before kicking job off
68
- BackgroundWorker::PersistentState.new(options[:uid], options.except(:uid))
70
+ BackgroundWorker::PersistentState.new(opts[:uid], opts.except(:uid))
69
71
 
70
72
  # Enqueue to the background queue
71
- BackgroundWorker.enqueue(self, method_name, options)
73
+ BackgroundWorker.enqueue(self, method_name, opts)
72
74
 
73
- options[:uid]
75
+ opts[:uid]
74
76
  end
75
77
 
76
78
  # This method is called by the job runner
@@ -2,7 +2,7 @@ require 'logger'
2
2
 
3
3
  module BackgroundWorker
4
4
  class Config
5
- attr_reader :logger
5
+ attr_reader :logger, :enqueue_with
6
6
 
7
7
  # Configuration includes following options:
8
8
  # logger: what logger to user throughout
@@ -1,3 +1,3 @@
1
1
  module BackgroundWorker
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -3,7 +3,7 @@ module BackgroundWorker
3
3
  attr_reader :worker, :method_name, :options
4
4
 
5
5
  def initialize(worker, method_name, options)
6
- fail ArgumentError, "'uid' is required to identify worker" unless options['uid'].present?
6
+ fail ArgumentError, "'uid' is required to identify worker" unless options[:uid].present?
7
7
  @worker = worker
8
8
  @method_name = method_name
9
9
  @options = options
@@ -15,7 +15,7 @@ module BackgroundWorker
15
15
 
16
16
  rescue StandardError => e
17
17
  log_worker_error(e)
18
- BackgroundWorker.after_exception.call(e)
18
+ BackgroundWorker.after_exception(e)
19
19
 
20
20
  ensure
21
21
  log_worker_finality
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: background_worker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Noack
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-04-30 00:00:00.000000000 Z
13
+ date: 2015-05-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler