aws_cron 0.1.2 → 0.1.3

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: e27104d0b2a0ec1698327f6b41a7af179770b3b6
4
- data.tar.gz: 2e5ebe6f3633a7f7eb7b5b03a988a9e2ee1c0ae6
3
+ metadata.gz: f738118da7f17c26961f99904538ce8c99db1415
4
+ data.tar.gz: ba0570b3818810e1767d6b0f9dff32d6aba34e94
5
5
  SHA512:
6
- metadata.gz: 1252104291260f1c91a8d8318a8d238e6c194daaee75f9d045bf56786f6edff156ef350beff2842eae30b7203c233eb4258d26030e606107401204a8604d333f
7
- data.tar.gz: 46b0aef02dc3d2fc892fd174ca74b4528ccc96122ad84ff85c27522d876a0911d70672369582f06c7e9edb0d8d6199538ce8be8e5433f87d2e7e3910402aa9ef
6
+ metadata.gz: 669f655281b2f9c50471598ff530dd8c49d2f1fd30cc9283aa937efa62db6d9f50ecefb4ee0fc288d8ce334653eed176d9591fd2af80c42cf0006d94ced0db68
7
+ data.tar.gz: b5ffab3eaa67464489a182c85abca854f67c8c4405b6dd2ea830e1e3882cb4bb9ec3b45ed1d747ee157fe59b3faf1e38285667eefc04f26bd9b5069cada1c2c3
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # AwsCron
2
2
 
3
- [![CircleCI](https://circleci.com/gh/wealthsimple/aws_cron.svg?style=shield)](https://circleci.com/gh/wealthsimple/aws_cron) [![Code Climate](https://codeclimate.com/github/wealthsimple/aws_cron/badges/gpa.svg)](https://codeclimate.com/github/wealthsimple/aws_cron) [![Gem Version](https://badge.fury.io/rb/aws_cron.svg)](http://badge.fury.io/rb/aws_cron)
3
+ [![Gem Version](https://badge.fury.io/rb/aws_cron.svg)](http://badge.fury.io/rb/aws_cron)
4
+ [![CircleCI](https://circleci.com/gh/wealthsimple/aws_cron.svg?style=shield)](https://circleci.com/gh/wealthsimple/aws_cron)
5
+ [![Code Climate](https://codeclimate.com/github/wealthsimple/aws_cron/badges/gpa.svg)](https://codeclimate.com/github/wealthsimple/aws_cron)
6
+ [![codecov](https://codecov.io/gh/wealthsimple/aws_cron/branch/master/graph/badge.svg)](https://codecov.io/gh/wealthsimple/aws_cron)
7
+ [![Gitter chat](https://img.shields.io/gitter/room/wealthsimple/Lobby.svg?style=flat)](https://gitter.im/wealthsimple/Lobby)
4
8
 
5
9
  <!-- Tocer[start]: Auto-generated, don't remove. -->
6
10
 
@@ -12,7 +12,7 @@ module AwsCron
12
12
  end
13
13
 
14
14
  def self.version
15
- "0.1.2"
15
+ "0.1.3"
16
16
  end
17
17
 
18
18
  def self.version_label
@@ -19,8 +19,25 @@ module AwsCron
19
19
 
20
20
  def should_run(time)
21
21
  last_execution_time = @cron.last(time)
22
+ next_execution_time = @cron.next(time)
22
23
 
23
- time >= last_execution_time - @leniency_secs && time < last_execution_time + @leniency_secs
24
+ # Addresses 'parse-cron' behaviour of not being able to tell
25
+ # if the cron schedule matches the current time.
26
+ # If your cron should run at 9AM, asking
27
+ # CronParser at exactly 9AM will yield:
28
+ # last: yesterday 9AM
29
+ # next: tomorrow 9AM
30
+ #
31
+ # But at 9:01AM, it will yield:
32
+ # last: today 9AM
33
+ # next: tomorrow 9AM
34
+ current_execution_time = @cron.last(time + 1.minute)
35
+
36
+ time_matches?(time, last_execution_time) || time_matches?(time, next_execution_time) || time_matches?(time, current_execution_time)
37
+ end
38
+
39
+ def time_matches?(time, reference_time)
40
+ time >= reference_time - @leniency_secs && time < reference_time + @leniency_secs
24
41
  end
25
42
  end
26
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Costa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-21 00:00:00.000000000 Z
11
+ date: 2016-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport