arask 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcbb7e796b4c0ce2d360cde65075152aeab553efd89cd72c3468e49f977f0749
4
- data.tar.gz: '01859423bc4eea6a8a6780b2ea714e25402814f3380e6b3cfb88a0ac39f85b38'
3
+ metadata.gz: 124439fc5b51273732a02efb953350c77953bfd4c2fe120460d6bb74b8762f02
4
+ data.tar.gz: a6c54e857d937e5d4e87a38b50c2c75a8beeb1d3e708e903047b15de2e6a74af
5
5
  SHA512:
6
- metadata.gz: b637b301591bdd5c16e024d9a235d5c27b97c72938c90f054e2c68b122ca8b2136b5062aeee1caa88d08141db2e3433f3191f4f664a38736fdf6794ecfd15c88
7
- data.tar.gz: 0c3692b6c17623e7206099e35e316c3ddfc5e3fbef5c1a82ac611e791624f6bec082eccb4f41a3c59230a2d098412159983d5f5d38decaf04c06a936bbd0f1cc
6
+ metadata.gz: f9b78ff561bb8e9dfcc1850f70f52550e045b6fee4a3fba4e2e687e9bce3d83f6e8032cd222dc07c45da5580fdad5f7a82065e8ce971628c8bea75003327c19f
7
+ data.tar.gz: 1a075fc84d7cf53155725221774277822da02adfe06e418443fd6d825bdae0eb440bf41ee17c11504ab1325291b6c5bc7422d8ef5210e37cd3f4af2ff25c8435
data/README.md CHANGED
@@ -72,8 +72,13 @@ file,line,_ = caller.first.split(':')
72
72
  fileline = File.readlines(file)[line.to_i - 1].strip
73
73
  ```
74
74
 
75
- ## Setup for Heroku
76
- None. But if you use a hobby dyno and it falls to sleep, so will Arask. As soon as the dyno wakes up, Arask will run any pending jobs.
75
+ ## Special environments
76
+
77
+ ### Heroku
78
+ Nothing special to setup. But if you use a hobby dyno and it falls to sleep, so will Arask. As soon as the dyno wakes up, Arask will run any pending jobs.
79
+
80
+ ### Docker
81
+ Nothing special to setup.
77
82
 
78
83
  ## Caveats
79
84
  If you reload a database dump, your jobs could be run again.
data/lib/arask.rb CHANGED
@@ -5,22 +5,25 @@ 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, :exception_block; end
8
+ class << self; attr_accessor :jobs_touched, :exception_email, :exception_email_from, :exception_block, :jobs_block; end
9
9
 
10
- def self.setup(force_run = false)
11
- # Make sure we only run setup if Rails is actually run as a server or testing.
12
- return unless defined?(Rails::Server) or force_run
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.
16
- ActiveSupport.on_load :after_initialize, yield: true do
17
- Arask.jobs_touched = []
18
- yield Setup
19
- begin
20
- AraskJob.all.where.not(id: Arask.jobs_touched).delete_all
21
- Arask.queue_self
22
- rescue
23
- end
10
+ def self.setup(force_run = false, &block)
11
+ Arask.jobs_block = block
12
+ # Make sure we only run setup now if we are testing.
13
+ # Else we would run them at every cli execution.
14
+ # railtie.rb inits the jobs when the server is ready
15
+ Arask.init_jobs if force_run
16
+ end
17
+
18
+ def self.init_jobs
19
+ Arask.jobs_touched = []
20
+ Arask.jobs_block.call(Setup)
21
+ Arask.jobs_block = nil
22
+ begin
23
+ AraskJob.all.where.not(id: Arask.jobs_touched).delete_all
24
+ Arask.jobs_touched = nil
25
+ Arask.queue_self
26
+ rescue
24
27
  end
25
28
  end
26
29
 
data/lib/arask/railtie.rb CHANGED
@@ -1,4 +1,8 @@
1
1
  module Arask
2
2
  class Railtie < ::Rails::Railtie
3
+ # Executes when the rails server is running
4
+ server do
5
+ Arask.init_jobs
6
+ end
3
7
  end
4
8
  end
data/lib/arask/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arask
2
- VERSION = '1.2.3'
2
+ VERSION = '1.2.4'
3
3
  end
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.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esben Damgaard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-13 00:00:00.000000000 Z
11
+ date: 2021-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubygems_version: 3.0.3
93
+ rubygems_version: 3.2.3
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Automatic RAils taSKs (with minimal setup)