assistor 0.1.1 → 0.2.1

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
- SHA1:
3
- metadata.gz: 264bca886df08dba506ee6c4de145d501be9ce17
4
- data.tar.gz: 6dd73ee78a783abeab0ae3b172e33267c6248156
2
+ SHA256:
3
+ metadata.gz: e6e649e23aa2801c54dcdd2ba0c9d477c36e0161434a590e48645835c0415167
4
+ data.tar.gz: 9f602137d03d923b2cc8b7a75b3e000dc00b40c6e79d14b8e9f21d7897111113
5
5
  SHA512:
6
- metadata.gz: 52fc67de9df4303ca9e32cfebefed22cadf392ab093166666507cd8805e956e56439212aefd86e74e6d4607b1c8a6e25bea122b3a7a665bb257d7de6c777bc2d
7
- data.tar.gz: 877900ed7ac6d7f3fb05ff8139e65e8ca90dcb460bab3cf4e639a1ee8f0ed86feac11b92690830166b2c120d784d2baaca41e46fb52aba3c4eb4c8438e09858d
6
+ metadata.gz: f00187585c4baeebbe81113575eab57178e0e66c73a1a7a47b054554b298e3a959a8a85d11a3e4eca6793e129ef76a536d031d0d6465aa4de4686cfabb50d6d1
7
+ data.tar.gz: bd89d5f603543493c2bd68425205601347f341af7d9778fec01f9f95a4249a9383948e2c841e4098ab232d2f6d029ebb66eee5a22dcdd8edeb45a8300f6d372d
data/README.md CHANGED
@@ -48,10 +48,6 @@ class ExampleJob < Assistor::AbstractJob
48
48
  def run
49
49
  sleep @i
50
50
  end
51
-
52
- def fail(exception)
53
- ExceptionHandler.handle exception
54
- end
55
51
  end
56
52
 
57
53
  class ExampleQueue < Assistor::AbstractQueue
@@ -77,6 +73,7 @@ configuration = Assistor::Configuration.new
77
73
  configuration.id = 'example'
78
74
  configuration.size = 3
79
75
  configuration.delay = 0.2
76
+ configuration.exception_handler = Proc.new { |exception| ExceptionHandler.handle(exception) }_
80
77
  configuration.log_file = File.join(File.expand_path('..', __FILE__), 'example.log')
81
78
  configuration.pid_file = File.join(File.expand_path('..', __FILE__), 'example.pid')
82
79
 
@@ -7,9 +7,5 @@ module Assistor
7
7
  def run
8
8
  raise NotImplementedError
9
9
  end
10
-
11
- def fail(exception)
12
- raise NotImplementedError
13
- end
14
10
  end
15
11
  end
@@ -48,7 +48,7 @@ module Assistor
48
48
  with_pid_file { @job.run }
49
49
  rescue => e
50
50
  log_file.error e
51
- @job.fail e
51
+ @configuration.exception_handler.call(e)
52
52
  end
53
53
 
54
54
  def stop
@@ -10,5 +10,13 @@ module Assistor
10
10
  def pid_file=(file)
11
11
  @pid_file = PidFile.new file
12
12
  end
13
+
14
+ def exception_handler=(exception_handler)
15
+ @exception_handler = exception_handler
16
+ end
17
+
18
+ def exception_handler
19
+ @exception_handler || Proc.new {}
20
+ end
13
21
  end
14
22
  end
@@ -19,6 +19,7 @@ module Assistor
19
19
  end
20
20
  rescue => e
21
21
  log_file.error e
22
+ @configuration.exception_handler.call(e)
22
23
  end
23
24
 
24
25
  private
@@ -38,6 +39,7 @@ module Assistor
38
39
  exit!(0)
39
40
  rescue => e
40
41
  log_file.error e
42
+ @configuration.exception_handler.call(e)
41
43
  end
42
44
 
43
45
  def stop!
@@ -47,6 +49,7 @@ module Assistor
47
49
  exit!(1)
48
50
  rescue => e
49
51
  log_file.error e
52
+ @configuration.exception_handler.call(e)
50
53
  end
51
54
 
52
55
  def assist(queue)
@@ -60,6 +63,7 @@ module Assistor
60
63
  assistant_group.add(assistant)
61
64
  rescue => e
62
65
  log_file.error e
66
+ @configuration.exception_handler.call(e)
63
67
  end
64
68
 
65
69
  def daemonize
@@ -1,3 +1,3 @@
1
1
  module Assistor
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,71 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assistor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Kowalewski
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-10 00:00:00.000000000 Z
11
+ date: 2023-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.13'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.13'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 0.44.1
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: 0.44.1
54
+ version: '0'
69
55
  description: Simple background processing framework for Ruby
70
56
  email:
71
57
  - me@tkowalewski.pl
@@ -77,6 +63,7 @@ files:
77
63
  - CODE_OF_CONDUCT.md
78
64
  - LICENSE.txt
79
65
  - README.md
66
+ - lib/assistor.rb
80
67
  - lib/assistor/abstract_job.rb
81
68
  - lib/assistor/abstract_queue.rb
82
69
  - lib/assistor/assistant.rb
@@ -86,30 +73,27 @@ files:
86
73
  - lib/assistor/log_file.rb
87
74
  - lib/assistor/pid_file.rb
88
75
  - lib/assistor/version.rb
89
- - lib/assistor.rb
90
76
  homepage: https://github.com/tkowalewski/assistor
91
77
  licenses:
92
78
  - MIT
93
79
  metadata: {}
94
- post_install_message:
80
+ post_install_message:
95
81
  rdoc_options: []
96
82
  require_paths:
97
83
  - lib
98
84
  required_ruby_version: !ruby/object:Gem::Requirement
99
85
  requirements:
100
- - - '>='
86
+ - - ">="
101
87
  - !ruby/object:Gem::Version
102
88
  version: '0'
103
89
  required_rubygems_version: !ruby/object:Gem::Requirement
104
90
  requirements:
105
- - - '>='
91
+ - - ">="
106
92
  - !ruby/object:Gem::Version
107
93
  version: '0'
108
94
  requirements: []
109
- rubyforge_project:
110
- rubygems_version: 2.0.2
111
- signing_key:
95
+ rubygems_version: 3.1.2
96
+ signing_key:
112
97
  specification_version: 4
113
98
  summary: Simple background processing framework for Ruby
114
99
  test_files: []
115
- has_rdoc: