arask 1.1.0 → 1.1.1

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
  SHA1:
3
- metadata.gz: 655fe5d9cc2a34ed951492948dfb6074d5d2dc78
4
- data.tar.gz: 96e999e71c7da10bd302a2e531ac03c151a6cf29
3
+ metadata.gz: 6167531a32f3c62d0745ec6b77492feb12f845a3
4
+ data.tar.gz: '055198c14e303f027f9ddb1659a42b9c556d28c4'
5
5
  SHA512:
6
- metadata.gz: 33142e354cdd8bacefa017f47bfded3bc1b2c91d4a48b3895e10e99dc0cb37906fd13ec9d4fc84faeea02744c5e362cc451fa1937248b6d0aee10ac58b21b63d
7
- data.tar.gz: ec4ba50c19be1c1baabb22612bffff7649a765f8bcf019b747b3c0262eb93665b3ee2ae66803cddf5175c7b23d5402479ce9a0d78a8df307738ccfbdbf8f82c8
6
+ metadata.gz: 409bafc717efdbec7472c10dcaaed07bd6e682c78f840e8676452682472475e93e4b8857a2cbce0026b9adcce38f2b52c880b3260ca869da12d63140dd9f9e89
7
+ data.tar.gz: 42828f4a61372615ab0f4372690ce69212e9511d47750db85641e8274f547848bffe016913f06cc416f73ba90c78b4b6bf6fe6ad5e485b315a205051004eb25e
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Arask
2
- [![Build Status](https://travis-ci.org/Ebbe/arask.svg?branch=master)](https://travis-ci.org/Ebbe/arask)
3
2
  [![Gem Version](https://badge.fury.io/rb/arask.svg)](https://badge.fury.io/rb/arask)
3
+ [![Build Status](https://travis-ci.org/Ebbe/arask.svg?branch=master)](https://travis-ci.org/Ebbe/arask)
4
+ [![Coverage Status](https://coveralls.io/repos/github/Ebbe/arask/badge.svg?branch=master)](https://coveralls.io/github/Ebbe/arask?branch=master)
4
5
 
5
6
  Automatic RAils taSKs (with minimal setup).
6
7
 
@@ -8,6 +9,21 @@ No need to setup anything outside of Rails. If Rails is running, so is Arask. If
8
9
 
9
10
  Use cron syntax or simply define the interval.
10
11
 
12
+ ## Installation
13
+ Add this line to your application's Gemfile:
14
+ ```ruby
15
+ gem 'arask'
16
+ ```
17
+
18
+ Execute:
19
+ ```bash
20
+ $ bundle install
21
+ $ rails generate arask:install
22
+ $ rails db:migrate
23
+ ```
24
+
25
+ Setup your tasks in config/initializers/arask.rb. Initially it looks [like this](lib/arask/initialize.rb).
26
+
11
27
  ## Usage
12
28
  After installation, you can edit config/initializers/arask.rb with your tasks.
13
29
 
@@ -43,21 +59,6 @@ Not supported is `@reboot`.
43
59
  ### About interval
44
60
  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.
45
61
 
46
- ## Installation
47
- Add this line to your application's Gemfile:
48
- ```ruby
49
- gem 'arask'
50
- ```
51
-
52
- Execute:
53
- ```bash
54
- $ bundle install
55
- $ rails generate arask:install
56
- $ rails db:migrate
57
- ```
58
-
59
- Setup your tasks in config/initializers/arask.rb. Initially it looks [like this](lib/arask/initialize.rb).
60
-
61
62
  ## Todos
62
63
  * Have a "try again" feature. For instance `arask.create script: 'raise "I failed"', interval: :daily, fail_retry: 5.minutes, retry_at_most: 2`
63
64
 
data/lib/arask/setup.rb CHANGED
@@ -7,6 +7,8 @@ module Arask
7
7
  end
8
8
 
9
9
  def self.create(script: nil, task: nil, job: nil, interval: nil, cron: nil, run_first_time: false)
10
+ file,line,_ = caller.first.split(' ')[0].split(':')
11
+ p File.readlines(file)[line.to_i - 1].strip
10
12
  interval = parse_interval_or_cron(interval, cron)
11
13
  if interval.nil?
12
14
  puts 'Arask: You did not specify either cron: or interval:! When should the task run?'
data/lib/arask/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arask
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
data/lib/arask.rb CHANGED
@@ -8,14 +8,16 @@ module Arask
8
8
  class << self; attr_accessor :jobs_touched, :exception_email, :exception_email_from; end
9
9
 
10
10
  def self.setup
11
- # Make sure we only run setup if Rails is actually run as a server or testing.
12
- return unless defined?(Rails::Server) or Rails.env.test?
13
- Arask.jobs_touched = []
14
- yield Setup
15
- begin
16
- AraskJob.all.where.not(id: Arask.jobs_touched).delete_all
17
- Arask.queue_self
18
- rescue
11
+ ActiveSupport.on_load :after_initialize, yield: true do
12
+ # Make sure we only run setup if Rails is actually run as a server or testing.
13
+ return unless defined?(Rails::Server) or Rails.env.test?
14
+ Arask.jobs_touched = []
15
+ yield Setup
16
+ begin
17
+ AraskJob.all.where.not(id: Arask.jobs_touched).delete_all
18
+ Arask.queue_self
19
+ rescue
20
+ end
19
21
  end
20
22
  end
21
23
 
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.1.0
4
+ version: 1.1.1
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-06-28 00:00:00.000000000 Z
11
+ date: 2018-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails