queue-bus 0.13.6 → 0.15.0

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: 500e592a3741d0ce34feb2a39fb603d562e5d72771c8134a2002e6a4a2bcbc60
4
- data.tar.gz: d4b6febb4d5be7acdaea3ed0697c2758ab2c77a365d9c4cae48d2a72c49efdd5
3
+ metadata.gz: 46bdb4080e33e82a9063240f1dfa396175e96b53e5fce4ccb09846d5e0a08f73
4
+ data.tar.gz: fd876ca4119401ca8e924a9010ab5d60262913c3461df19a5a5078009a170427
5
5
  SHA512:
6
- metadata.gz: 3fe8c421c706f6ddeb65eef00f0dc943282e54220a82b494118e556f3e07b0b8f3923ed71043134868ae4f47966fd1e5b39eee05357bd59fff0c2814d487e8d5
7
- data.tar.gz: 3e66f46b18f40268894879b891fa34d9c520590fb5f2827a11727cca780b7554a37a436d073e5ee3f06e2178e9357d3e5d07e3bcd5296363125e17d9b6e56743
6
+ metadata.gz: 2bfe7e0274d3f3d5f771c6bec1a18b010db32595442976d4d04a844624a550a154bf27e3a01f1f1dac8b5bbe6b21040693fd43abb9aa2bf2e7a432b229756b18
7
+ data.tar.gz: a02a22239b4c6a01a7c2353b76e573785bff00fc74b25eb3997b11ba50ac29c4335fbf35c7ff532436e845dd30fb802c9d3233dd4948c575ca0070d9901493d8
data/.rubocop.yml CHANGED
@@ -10,8 +10,8 @@ Style/FrozenStringLiteralComment:
10
10
  Style/DateTime:
11
11
  Enabled: true
12
12
 
13
- # http://rubocop.readthedocs.io/en/latest/cops_metrics/#metricslinelength
14
- Metrics/LineLength:
13
+ # https://docs.rubocop.org/rubocop/cops_layout.html#layoutlinelength
14
+ Layout/LineLength:
15
15
  Max: 100
16
16
 
17
17
  Metrics/MethodLength:
@@ -29,7 +29,3 @@ Layout/DotPosition:
29
29
  # https://rubocop.readthedocs.io/en/latest/cops_style/#stylehashsyntax
30
30
  Style/HashSyntax:
31
31
  Enabled: true
32
-
33
- # https://rubocop-rspec.readthedocs.io/en/latest/cops_rspec/#rspecfocus
34
- RSpec/Focus:
35
- Enabled: true
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.15.0]
10
+ - Replaces multi_json with Ruby's built-in `json` library, which every supported Ruby ships with, and drops the multi_json dependency. Output matches multi_json's default `json` adapter. multi_json switched to oj or yajl automatically when either was installed, so apps with those gems now get `json` instead. Apps that relied on queue-bus to load multi_json for them need to require it themselves.
11
+
12
+ ## [0.14.0]
13
+ - Declares `required_ruby_version >= 2.4`, matching the rubocop target.
14
+ - Uses `MultiJSON.parse`/`generate` and `MultiJSON::ParseError` when available, fixing multi_json 1.21 deprecation warnings ahead of their removal in 2.0.
15
+ - Fixes a flaky middleware ordering spec.
16
+
9
17
  ## [0.13.6]
10
18
  - Fixing setnx deprecation
11
19
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'multi_json'
3
+ require 'json'
4
4
 
5
5
  module QueueBus
6
6
  module Util
@@ -11,24 +11,16 @@ module QueueBus
11
11
  # Given a Ruby object, returns a string suitable for storage in a
12
12
  # queue.
13
13
  def encode(object)
14
- if MultiJson.respond_to?(:dump) && MultiJson.respond_to?(:load)
15
- MultiJson.dump object
16
- else
17
- MultiJson.encode object
18
- end
14
+ ::JSON.dump(object.respond_to?(:as_json) ? object.as_json : object)
19
15
  end
20
16
 
21
17
  # Given a string, returns a Ruby object.
22
18
  def decode(object)
23
- return unless object
19
+ return if object.nil? || object.strip.empty?
24
20
 
25
21
  begin
26
- if MultiJson.respond_to?(:dump) && MultiJson.respond_to?(:load)
27
- MultiJson.load object
28
- else
29
- MultiJson.decode object
30
- end
31
- rescue ::MultiJson::DecodeError => e
22
+ ::JSON.parse(object)
23
+ rescue ::JSON::ParserError => e
32
24
  raise DecodeException, e.message, e.backtrace
33
25
  end
34
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QueueBus
4
- VERSION = '0.13.6'
4
+ VERSION = '0.15.0'
5
5
  end
data/queue-bus.gemspec CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = ''
12
12
  s.summary = 'A simple event bus on top of background queues'
13
13
  s.description = 'A simple event bus on top of common background queues. Publish and subscribe to events as they occur using what you already have.'
14
+ s.required_ruby_version = '>= 2.4'
14
15
 
15
16
  s.rubyforge_project = 'queue-bus'
16
17
 
@@ -19,7 +20,6 @@ Gem::Specification.new do |s|
19
20
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
21
  s.require_paths = ['lib']
21
22
 
22
- s.add_dependency('multi_json')
23
23
  s.add_dependency('redis')
24
24
 
25
25
  # if using resque
@@ -10,13 +10,16 @@ RSpec.describe QueueBus::Middleware do
10
10
 
11
11
  let(:base_class) do
12
12
  # Creates a unique base class that provides tracking of calls.
13
+ calls = 0
13
14
  Class.new(QueueBus::Middleware::Abstract) do
14
15
  class << self
15
16
  attr_accessor :called_at
16
17
  end
17
18
 
18
- def call(_args)
19
- self.class.called_at = Time.now
19
+ # A sequence number rather than Time.now, since consecutive calls can
20
+ # share a timestamp and then sort in the wrong order.
21
+ define_method(:call) do |_args|
22
+ self.class.called_at = (calls += 1)
20
23
  @app.call
21
24
  end
22
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: queue-bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.6
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Leonard
@@ -9,20 +9,6 @@ bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
- - !ruby/object:Gem::Dependency
13
- name: multi_json
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - ">="
17
- - !ruby/object:Gem::Version
18
- version: '0'
19
- type: :runtime
20
- prerelease: false
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: '0'
26
12
  - !ruby/object:Gem::Dependency
27
13
  name: redis
28
14
  requirement: !ruby/object:Gem::Requirement
@@ -165,14 +151,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
151
  requirements:
166
152
  - - ">="
167
153
  - !ruby/object:Gem::Version
168
- version: '0'
154
+ version: '2.4'
169
155
  required_rubygems_version: !ruby/object:Gem::Requirement
170
156
  requirements:
171
157
  - - ">="
172
158
  - !ruby/object:Gem::Version
173
159
  version: '0'
174
160
  requirements: []
175
- rubygems_version: 3.6.9
161
+ rubygems_version: 4.0.17
176
162
  specification_version: 4
177
163
  summary: A simple event bus on top of background queues
178
164
  test_files: