queue-bus 0.13.0 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 511b1d30315adbfe76e6fa303aaba3158d56d39bea93355a0d28c18c8b0578cb
4
- data.tar.gz: ba55e76505d56b98a416ff60c64c2c384734cd18af332768f6631e490caf4ed5
3
+ metadata.gz: 5383fd5290386ad57b383532a59406032e960ee344dc218db4c6c2e83a8fc8df
4
+ data.tar.gz: 6e695fc97a76265c6fa98984278e517b5e21dc7142c7d7b9ff646e02e52af5ef
5
5
  SHA512:
6
- metadata.gz: b0f0d47e2be417d33b1f396043fd604ff936d9a1f258550b725673b4a9649d6e6153edaca77a064996ab3f0c43b59849ab04a66c49f3afb4f2d058a7c788f1e3
7
- data.tar.gz: 941c73b6e35945a181651bb03746fff2022947fe89102daebd76f72e211150dfd2382ebd41bbd35857b1c5b9a2f099389b25392ba8e0c210615b624ef5898fb0
6
+ metadata.gz: 7a238383614d2505facac1c2003d8b55cff3d3c68c1bd0a136ce5444cbae92377df9fd9316feb912180bc2a9272f30257dcc028c345178cc56c18f6c9fee8aa5
7
+ data.tar.gz: 507b3514db5c2290e4c2cedf60d77cfed61f8fc9b4b0ae1c647de40350fdd52342144b4bdba32ad94fc5f734fd4413d80f7517ff083ebda0d8f1b28984c28421
data/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.13.1]
10
+
11
+ ### Fixes
12
+
13
+ - Allows matching on 0 via the `on_heartbeat` subscription
14
+
15
+ ### Added
16
+
17
+ - Allows matching on `wday` via the `on_heartbeat` subscription
18
+
9
19
  ## [0.13.0]
10
20
 
11
21
  ### Added
@@ -16,7 +16,7 @@ module QueueBus
16
16
  @subscriptions.size
17
17
  end
18
18
 
19
- def on_heartbeat(key, minute: nil, hour: nil, minute_interval: nil, hour_interval: nil, &block) # rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/ParameterLists, Metrics/CyclomaticComplexity, Metrics/AbcSize
19
+ def on_heartbeat(key, minute: nil, hour: nil, wday: nil, minute_interval: nil, hour_interval: nil, &block) # rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/ParameterLists, Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/LineLength
20
20
  if minute_interval && !minute_interval.positive?
21
21
  raise ArgumentError, 'minute_interval must be a positive integer'
22
22
  end
@@ -28,17 +28,23 @@ module QueueBus
28
28
  matcher = { bus_event_type: :heartbeat_minutes }
29
29
 
30
30
  if minute
31
- raise ArgumentError, 'minute must be a positive integer' unless minute.positive?
31
+ raise ArgumentError, 'minute must not be negative' if minute.negative?
32
32
 
33
33
  matcher['minute'] = minute
34
34
  end
35
35
 
36
36
  if hour
37
- raise ArgumentError, 'hour must be a positive integer' unless hour.positive?
37
+ raise ArgumentError, 'hour must not be negative' if hour.negative?
38
38
 
39
39
  matcher['hour'] = hour
40
40
  end
41
41
 
42
+ if wday
43
+ raise ArgumentError, 'wday must not be negative' if wday.negative?
44
+
45
+ matcher['wday'] = wday
46
+ end
47
+
42
48
  subscribe(key, matcher) do |event|
43
49
  if (minute_interval.nil? || (event['minute'] % minute_interval).zero?) &&
44
50
  (hour_interval.nil? || (event['hour'] % hour_interval).zero?)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QueueBus
4
- VERSION = '0.13.0'
4
+ VERSION = '0.13.1'
5
5
  end
@@ -61,7 +61,8 @@ module QueueBus
61
61
  end
62
62
 
63
63
  it 'subscribes to hour 8' do
64
- expect(dispatch.subscriptions.all.first.matcher.filters).to eq('bus_event_type' => 'heartbeat_minutes', 'hour' => '8')
64
+ expect(dispatch.subscriptions.all.first.matcher.filters)
65
+ .to eq('bus_event_type' => 'heartbeat_minutes', 'hour' => '8')
65
66
  end
66
67
  end
67
68
 
@@ -73,7 +74,8 @@ module QueueBus
73
74
  end
74
75
 
75
76
  it 'subscribes to minute 4' do
76
- expect(dispatch.subscriptions.all.first.matcher.filters).to eq('bus_event_type' => 'heartbeat_minutes', 'minute' => '4')
77
+ expect(dispatch.subscriptions.all.first.matcher.filters)
78
+ .to eq('bus_event_type' => 'heartbeat_minutes', 'minute' => '4')
77
79
  end
78
80
  end
79
81
 
@@ -90,6 +92,19 @@ module QueueBus
90
92
  end
91
93
  end
92
94
 
95
+ context 'when running on wday 2' do
96
+ before do
97
+ dispatch.on_heartbeat event_name, wday: 2 do |_event|
98
+ Runner2.run({})
99
+ end
100
+ end
101
+
102
+ it 'subscribes to wday 2' do
103
+ expect(dispatch.subscriptions.all.first.matcher.filters)
104
+ .to eq('bus_event_type' => 'heartbeat_minutes', 'wday' => '2')
105
+ end
106
+ end
107
+
93
108
  context 'when declaring minute intervals' do
94
109
  before do
95
110
  dispatch.on_heartbeat event_name, minute_interval: 5 do |_event|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: queue-bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Leonard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-15 00:00:00.000000000 Z
11
+ date: 2021-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json