arask 1.2.4 → 1.2.5

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: 124439fc5b51273732a02efb953350c77953bfd4c2fe120460d6bb74b8762f02
4
- data.tar.gz: a6c54e857d937e5d4e87a38b50c2c75a8beeb1d3e708e903047b15de2e6a74af
3
+ metadata.gz: 277e0095ea412d5b05a792f0a2210b987165b9e18c292770f5655b75ffa5dc38
4
+ data.tar.gz: 3afcc9cc2d53b69aeb4831d30b26afa1931289bfdd58fdf3c75dc3199d9a55ac
5
5
  SHA512:
6
- metadata.gz: f9b78ff561bb8e9dfcc1850f70f52550e045b6fee4a3fba4e2e687e9bce3d83f6e8032cd222dc07c45da5580fdad5f7a82065e8ce971628c8bea75003327c19f
7
- data.tar.gz: 1a075fc84d7cf53155725221774277822da02adfe06e418443fd6d825bdae0eb440bf41ee17c11504ab1325291b6c5bc7422d8ef5210e37cd3f4af2ff25c8435
6
+ metadata.gz: df3e1a1400bd5e3584380219422f586551af432e13cdee39544640295a9bd7635c594957c45d8af3bf080ac0f09010e28928e8b79aebbfbe1a8ebbdd1aa1d4e2
7
+ data.tar.gz: 1ecd42c9bf9448c4fccd78f335cc9b84fd26201ac6727894849de3ca0318a6f5194199f5c193c865ca1ba1458fc5ccab78d0b90626db9aea72f9738a6f097b9d
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Arask
2
+
2
3
  [![Gem Version](https://badge.fury.io/rb/arask.svg)](https://badge.fury.io/rb/arask)
3
4
  [![Build Status](https://travis-ci.org/Ebbe/arask.svg?branch=master)](https://travis-ci.org/Ebbe/arask)
4
5
  [![Coverage Status](https://coveralls.io/repos/github/Ebbe/arask/badge.svg?branch=master)](https://coveralls.io/github/Ebbe/arask?branch=master)
@@ -10,12 +11,15 @@ No need to setup anything outside of Rails. If Rails is running, so is Arask. If
10
11
  Use cron syntax or simply define the interval.
11
12
 
12
13
  ## Installation
14
+
13
15
  Add this line to your application's Gemfile:
16
+
14
17
  ```ruby
15
18
  gem 'arask'
16
19
  ```
17
20
 
18
21
  Execute:
22
+
19
23
  ```bash
20
24
  $ bundle install
21
25
  $ rails generate arask:install
@@ -25,9 +29,11 @@ $ rails db:migrate
25
29
  Setup your tasks in config/initializers/arask.rb. Initially it looks [like this](lib/arask/initialize.rb).
26
30
 
27
31
  ## Usage
32
+
28
33
  After installation, you can edit config/initializers/arask.rb with your tasks.
29
34
 
30
35
  ### Examples of jobs in the initializer
36
+
31
37
  ```ruby
32
38
  # Rake tasks with cron syntax
33
39
  arask.create task: 'send:logs', cron: '0 2 * * *' # At 02:00 every day
@@ -57,16 +63,20 @@ end
57
63
  ```
58
64
 
59
65
  ### About cron
66
+
60
67
  Arask uses [fugit](https://github.com/floraison/fugit) to parse cron and get next execution time. It follows normal cron syntax. You can test your cron at https://crontab.guru/.
61
68
 
62
69
  Not supported is `@reboot`.
63
70
 
64
71
  ### About interval
72
+
65
73
  The interval starts when the task has started running. If a task with the interval `:hourly` is run at 08:37PM, then it will run the next time at 09:37PM.
66
74
 
67
75
  ## Todos
68
- * Have a "try again" feature. For instance `arask.create script: 'raise "I failed"', interval: :daily, fail_retry: 5.minutes, retry_at_most: 2`
69
- * Be able to specify line and number that failed for an exception:
76
+
77
+ - Have a "try again" feature. For instance `arask.create script: 'raise "I failed"', interval: :daily, fail_retry: 5.minutes, retry_at_most: 2`
78
+ - Be able to specify line and number that failed for an exception:
79
+
70
80
  ```ruby
71
81
  file,line,_ = caller.first.split(':')
72
82
  fileline = File.readlines(file)[line.to_i - 1].strip
@@ -75,16 +85,28 @@ fileline = File.readlines(file)[line.to_i - 1].strip
75
85
  ## Special environments
76
86
 
77
87
  ### Heroku
88
+
78
89
  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
90
 
80
91
  ### Docker
92
+
81
93
  Nothing special to setup.
82
94
 
83
95
  ## Caveats
96
+
84
97
  If you reload a database dump, your jobs could be run again.
85
98
 
86
99
  ## Contributing
100
+
87
101
  Please use https://github.com/Ebbe/arask
88
102
 
103
+ ## Running tests
104
+
105
+ ```bash
106
+ $ bundle install
107
+ $ bundle exec rake test
108
+ ```
109
+
89
110
  ## License
111
+
90
112
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/lib/arask.rb CHANGED
@@ -9,10 +9,22 @@ module Arask
9
9
 
10
10
  def self.setup(force_run = false, &block)
11
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
12
+ if Rails::VERSION::MAJOR>=6
13
+ # Make sure we only run setup now if we are testing.
14
+ # Else we would run them at every cli execution.
15
+ # railtie.rb inits the jobs when the server is ready
16
+ Arask.init_jobs if force_run
17
+ else # Rails is less than 6
18
+
19
+ # Make sure we only run setup if Rails is actually run as a server or testing.
20
+ return unless defined?(Rails::Server) or force_run
21
+ # If we don't wait and rails is setup to use another language, ActiveJob
22
+ # saves what is now (usually :en) and reloads that when trying to run the
23
+ # job. Renderering an I18n error of unsupported language.
24
+ ActiveSupport.on_load :after_initialize, yield: true do
25
+ Arask.init_jobs
26
+ end
27
+ end
16
28
  end
17
29
 
18
30
  def self.init_jobs
data/lib/arask/railtie.rb CHANGED
@@ -3,6 +3,6 @@ module Arask
3
3
  # Executes when the rails server is running
4
4
  server do
5
5
  Arask.init_jobs
6
- end
6
+ end if Rails::VERSION::MAJOR>=6
7
7
  end
8
8
  end
data/lib/arask/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arask
2
- VERSION = '1.2.4'
2
+ VERSION = '1.2.5'
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.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esben Damgaard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-05-04 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.2.3
93
+ rubygems_version: 3.2.15
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Automatic RAils taSKs (with minimal setup)