arask 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/arask.rb +4 -1
- data/lib/arask/arask_job.rb +3 -0
- data/lib/arask/initialize.rb +5 -0
- data/lib/arask/setup.rb +7 -4
- data/lib/arask/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2055444d486251702ec8f09cc6944742f4ef45e
|
4
|
+
data.tar.gz: 3215c191aab13ce67fec68d09ec02962314f528b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba226a137d88675b7375f5bc59cdd780437a5f9bd218c7523ec8ad149823d03511b96a358acb3ca8b2d2a26d9b36a3577bb134925b03ee0f9a8c75721cf53cc0
|
7
|
+
data.tar.gz: af1ab2f4a7933407c0361e4f14fc09a8c00f974db29859a3532fabe374a25f28db8cfca5fc7c252af539f17f28f632c51b77ea3c1cd5bc4709aa88eae6fce408
|
data/README.md
CHANGED
@@ -49,6 +49,11 @@ arask.create script: 'Attachment.process_new', interval: 5.hours, run_first_time
|
|
49
49
|
|
50
50
|
# On exceptions, send email with details
|
51
51
|
arask.on_exception email: 'errors@example.com'
|
52
|
+
|
53
|
+
# Run code on exceptions
|
54
|
+
arask.on_exception do |exception, arask_job|
|
55
|
+
Honeybadger.notify(exception)
|
56
|
+
end
|
52
57
|
```
|
53
58
|
|
54
59
|
### About cron
|
@@ -61,10 +66,9 @@ The interval starts when the task has started running. If a task with the interv
|
|
61
66
|
|
62
67
|
## Todos
|
63
68
|
* Have a "try again" feature. For instance `arask.create script: 'raise "I failed"', interval: :daily, fail_retry: 5.minutes, retry_at_most: 2`
|
64
|
-
* Be able to run a block when an exception occurs. `arask.on_exception do <code> end`
|
65
69
|
* Be able to specify line and number that failed for an exception:
|
66
70
|
```ruby
|
67
|
-
file,line,_ = caller.first.split('
|
71
|
+
file,line,_ = caller.first.split(':')
|
68
72
|
fileline = File.readlines(file)[line.to_i - 1].strip
|
69
73
|
```
|
70
74
|
|
data/lib/arask.rb
CHANGED
@@ -5,11 +5,14 @@ require "arask/setup"
|
|
5
5
|
require 'fugit' # To parse cron
|
6
6
|
|
7
7
|
module Arask
|
8
|
-
class << self; attr_accessor :jobs_touched, :exception_email, :exception_email_from; end
|
8
|
+
class << self; attr_accessor :jobs_touched, :exception_email, :exception_email_from, :exception_block; end
|
9
9
|
|
10
10
|
def self.setup
|
11
11
|
# Make sure we only run setup if Rails is actually run as a server or testing.
|
12
12
|
return unless defined?(Rails::Server) or Rails.env.test?
|
13
|
+
# If we don't wait and rails is setup to use another language, ActiveJob
|
14
|
+
# saves what is now (usually :en) and reloads that when trying to run the
|
15
|
+
# job. Renderering an I18n error of unsupported language.
|
13
16
|
ActiveSupport.on_load :after_initialize, yield: true do
|
14
17
|
Arask.jobs_touched = []
|
15
18
|
yield Setup
|
data/lib/arask/arask_job.rb
CHANGED
data/lib/arask/initialize.rb
CHANGED
data/lib/arask/setup.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module Arask
|
2
2
|
class Setup
|
3
|
-
def self.on_exception(email: nil, from: 'robot@server')
|
4
|
-
Arask.exception_email = email
|
5
|
-
Arask.exception_email_from = from
|
6
|
-
puts "Arask could not parse parameter for on_exception!" unless email.class == String
|
3
|
+
def self.on_exception(email: nil, from: 'robot@server', &block)
|
4
|
+
Arask.exception_email = email unless email.nil?
|
5
|
+
Arask.exception_email_from = from unless from.nil?
|
6
|
+
puts "Arask could not parse parameter for on_exception!" unless email.nil? or email.class == String
|
7
|
+
if block_given?
|
8
|
+
Arask.exception_block = block
|
9
|
+
end
|
7
10
|
end
|
8
11
|
|
9
12
|
def self.create(script: nil, task: nil, job: nil, interval: nil, cron: nil, run_first_time: false)
|
data/lib/arask/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arask
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esben Damgaard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|