dalliance 0.3.1 → 0.3.2

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: db5d9527ed1b1dcfbfae86c153bb1de4f1a1c53b
4
- data.tar.gz: f539fefa59ae983528b6a7acce1b5ed68b70b0b4
3
+ metadata.gz: 1f175a2aa312e8b1f3b2ba9e07322e5c6aee2697
4
+ data.tar.gz: 5a31efc7399491d323e73e363037b2463a9713e0
5
5
  SHA512:
6
- metadata.gz: 294f9ddc6c675c2c06ba4cf3d1f484916e07d10449b9bae4eae8d7509bbfcabd2144e4ad8bf1817bba5ab69b36807e8a9fa11f2761d3d0b5f631b1590de32e8a
7
- data.tar.gz: f4173e1e059088be3ccbc70a24f603f09abe943a758903ad2c6a9d60ff12346e29495d6d511c16d199817556fb6f2e979003cbd13414f38284b5f27018f15b1c
6
+ metadata.gz: 8ea72c7f4cbf88c312da7dbc2fb50bbd8a566fbb36552e2384d69a4575e49e97bf0b20678902c98cf0d8e7cc01d29becb16b504e57b0e9a785dde9c3cd44f2a2
7
+ data.tar.gz: 159e6e91c530bb07ef9ce8ba7a6c8d2c45250d17c029b7a2f974c030e43e92f4bd65d353fd7d33973533a233460b86c464128e31c6d0cda270fd94b76186681b
@@ -2,7 +2,7 @@ module Dalliance
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 1
5
+ TINY = 2
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
data/lib/dalliance.rb CHANGED
@@ -21,7 +21,8 @@ module Dalliance
21
21
  :worker_class => detect_worker_class,
22
22
  :queue => 'dalliance',
23
23
  :logger => detect_logger,
24
- :duration_column => 'dalliance_duration'
24
+ :duration_column => 'dalliance_duration',
25
+ :error_notifier => ->(e){}
25
26
  }
26
27
  end
27
28
 
@@ -53,6 +54,10 @@ module Dalliance
53
54
  options[:duration_column] = value
54
55
  end
55
56
 
57
+ def error_notifier=(value)
58
+ options[:error_notifier] = value
59
+ end
60
+
56
61
  def configure
57
62
  yield(self) if block_given?
58
63
  end
@@ -169,6 +174,10 @@ module Dalliance
169
174
  end
170
175
  end
171
176
 
177
+ def error_notifier
178
+ self.dalliance_options[:error_notifier]
179
+ end
180
+
172
181
  def error_or_completed?
173
182
  validation_error? || processing_error? || completed?
174
183
  end
@@ -228,6 +237,8 @@ module Dalliance
228
237
  end
229
238
  end
230
239
 
240
+ error_notifier.call(e)
241
+
231
242
  #Don't raise the error if we're backgound_processing...
232
243
  raise e unless backgound_processing && self.class.dalliance_options[:worker_class].rescue_error?
233
244
  ensure
@@ -155,6 +155,17 @@ RSpec.describe DallianceModel do
155
155
  expect(subject.dalliance_error_hash).not_to be_empty
156
156
  expect(subject.dalliance_error_hash[:error]).to eq('Persistance Failure: See Logs')
157
157
  end
158
+
159
+ context "error_notifier" do
160
+ it "should pass the errors" do
161
+ DallianceModel.dalliance_options[:error_notifier] = ->(error){ @error_report = "#{error}" }
162
+
163
+ subject.dalliance_background_process
164
+ Delayed::Worker.new(:queues => [:dalliance]).work_off
165
+
166
+ expect(@error_report).to eq('RuntimeError')
167
+ end
168
+ end
158
169
  end
159
170
 
160
171
  context "validation error" do
@@ -171,6 +171,17 @@ RSpec.describe DallianceModel do
171
171
  expect(subject.dalliance_error_hash).not_to be_empty
172
172
  expect(subject.dalliance_error_hash[:error]).to eq('Persistance Failure: See Logs')
173
173
  end
174
+
175
+ context "error_notifier" do
176
+ it "should pass the errors" do
177
+ DallianceModel.dalliance_options[:error_notifier] = ->(error){ @error_report = "#{error}" }
178
+
179
+ subject.dalliance_background_process
180
+ Resque::Worker.new(:dalliance).process
181
+
182
+ expect(@error_report).to eq('RuntimeError')
183
+ end
184
+ end
174
185
  end
175
186
 
176
187
  context "validation error" do
@@ -6,11 +6,11 @@ RSpec.describe 'Dalliance' do
6
6
  context "self#dalliance_status_in_load_select_array" do
7
7
  it "should return [state, human_name]" do
8
8
  expect(DallianceModel.dalliance_status_in_load_select_array).to eq([
9
- ["pending", :pending],
10
- ["processing", :processing],
11
- ["validation error", :validation_error],
12
- ["processing error", :processing_error],
13
- ["completed", :completed]
9
+ ["completed", "completed"],
10
+ ["pending", "pending"],
11
+ ["processing", "processing"],
12
+ ["processing error", "processing_error"],
13
+ ["validation error", "validation_error"]
14
14
  ])
15
15
  end
16
16
  end
@@ -75,6 +75,16 @@ RSpec.describe DallianceModel do
75
75
  expect(subject.dalliance_error_hash).not_to be_empty
76
76
  expect(subject.dalliance_error_hash[:error]).to eq('Persistance Failure: See Logs')
77
77
  end
78
+
79
+ context "error_notifier" do
80
+ it "should pass the errors" do
81
+ DallianceModel.dalliance_options[:error_notifier] = ->(error){ @error_report = "#{error}" }
82
+
83
+ expect { subject.dalliance_background_process }.to raise_error(RuntimeError)
84
+
85
+ expect(@error_report).to eq('RuntimeError')
86
+ end
87
+ end
78
88
  end
79
89
 
80
90
  context "validation error" do
metadata CHANGED
@@ -1,149 +1,149 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dalliance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Sullivan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-09 00:00:00.000000000 Z
11
+ date: 2015-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '4.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '3.1'
30
- - - <
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '4.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '3.1'
40
- - - <
40
+ - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '4.2'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '3.1'
50
- - - <
50
+ - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '4.2'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: state_machine
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - '>='
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  type: :runtime
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - '>='
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: rspec
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - '>='
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: 3.0.0
74
74
  type: :development
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - '>='
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: 3.0.0
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: delayed_job
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - '>='
85
+ - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: 3.0.0
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - '>='
92
+ - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: 3.0.0
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: delayed_job_active_record
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - '>='
99
+ - - ">="
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - '>='
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: sqlite3
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - '>='
113
+ - - ">="
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - '>='
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: resque
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - '>='
127
+ - - ">="
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - '>='
134
+ - - ">="
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
- description: ' Background processing for ActiveRecord using a ''delayable'' worker
138
- and a state_machine '
137
+ description: " Background processing for ActiveRecord using a 'delayable' worker and
138
+ a state_machine "
139
139
  email:
140
140
  - eric.sullivan@annkissam.com
141
141
  executables: []
142
142
  extensions: []
143
143
  extra_rdoc_files: []
144
144
  files:
145
- - .gitignore
146
- - .rspec
145
+ - ".gitignore"
146
+ - ".rspec"
147
147
  - Appraisals
148
148
  - Gemfile
149
149
  - LICENSE
@@ -187,17 +187,17 @@ require_paths:
187
187
  - lib
188
188
  required_ruby_version: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - '>='
190
+ - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  requirements:
195
- - - '>='
195
+ - - ">="
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  requirements: []
199
199
  rubyforge_project: dalliance
200
- rubygems_version: 2.0.3
200
+ rubygems_version: 2.4.5
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: Wrapper for an ActiveRecord model with a single ascynhronous method