happn 1.1.0 → 1.1.7

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: 06b2f20b019373ac23f020f1b5c060f5f5185dddba551ace75ef4fc9a129d8ec
4
- data.tar.gz: b7b767f5e7abb62eb33661afaea52b7a2695674ddd2b18255002c18ad4923fed
3
+ metadata.gz: 69a473282e160c8ae5a0f8eea7615bae2700e63e2b458ae59c0e221a36824a26
4
+ data.tar.gz: 19140eaf6bac43db02fb65fbfdd1b6ffaa8eb95bb29307d0a2be561649ff11e5
5
5
  SHA512:
6
- metadata.gz: 94cf0746e1fac94dfde7da681c1abe4c4632411d79d46123d546b41bc84a87ece483e5a9e5b0094fba1e98518fc15d9aa202ea65cb8e05accce59176122059a0
7
- data.tar.gz: c63c774536d302c301b33ba1d37e828abddf2eae9e9783b8e60ae44ea45601a3f221df5ecc13265381c00ac3ae5b25078e54e1782855b604889a06f2d38515ca
6
+ metadata.gz: 8bb235e0cf250362916c7f399829248eaef752e2e4772178c7690896901aa763eb9dc9f2741bf12ff18caad3f925bbb151edd8109ea056b64cafa7f69494327d
7
+ data.tar.gz: 1b30f2f49e6450d670c903f16096d42bc188ac279154a8d4d256795e446274ca0dc3424118e6a8b494611ab3773992c69afd6d59629bb9cc5620a5be087670fa
data/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ### [1.1.7] - 2026-08-01
9
+
10
+ * **Breaking**: `required_ruby_version` is raised from `>= 3.0` to `>= 3.2`.
11
+ * `Happn::EventConsumer` now requires `json` explicitly.
12
+ * `Happn::Event#timestamp` returns `nil` again for an empty or blank timestamp, as it did up to 1.0.3 through `String#to_datetime`.
13
+ * Integration tests with RabbitMQ.
14
+
15
+ ### [1.1.6] - 2026-07-31
16
+
17
+ * Suite of tests
18
+ * Gem metadata: source code, changelog, `required_ruby_version >= 3.0`, a real description, and a package restricted to the library itself
19
+ * `Happn::Event#has_change?` and `Happn::Event#delete_change` now accept an attribute name given as a `String`, like `change_before` and `change_after` already did. They used to silently match nothing in that case.
20
+ * A query attribute explicitly set to `nil` now means _"all"_, as documented, instead of producing an empty word in the routing key. `Happn::Query` normalizes it into `:all` at build time, so the binding declared on the exchange and the local dispatch of the event agree with each other.
21
+
8
22
  ### [1.1.0] - 2026-07-30
9
23
 
10
24
  * Remove the `activesupport` dependency: `Happn::Configuration` no longer relies on `ActiveSupport::Configurable`, and `Happn::Event` no longer relies on `String#to_datetime` / `Object#try`
data/MIT-LICENSE CHANGED
@@ -1,20 +1,21 @@
1
- Copyright 2018
1
+ MIT License
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
3
+ Copyright (c) 2026 Commuty SA
10
4
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
13
11
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -7,7 +7,7 @@ This gem connects a single RabbitMQ queue and bind it automatically to its excha
7
7
 
8
8
  ## Requirements
9
9
 
10
- * Ruby 2.2
10
+ * Ruby >= 3.2
11
11
  * Tested with RabbitMQ 3.5.8
12
12
  * `happn-ruby` works with or without Rails (tested with Rails 4 and 5).
13
13
 
@@ -16,7 +16,7 @@ This gem connects a single RabbitMQ queue and bind it automatically to its excha
16
16
  Add the gem to your project's Gemfile:
17
17
 
18
18
  ```ruby
19
- gem "happn", git: "https://github.com/crepesourcing/happn-ruby.git"
19
+ gem "happn"
20
20
  ```
21
21
 
22
22
  Then, configure `Happn`. If you use Rails, you can create an initializer into your Rails app (`config/initializers/happn.rb`). This code can be called anywhere before starting `Happn.init`.
@@ -105,6 +105,27 @@ end
105
105
 
106
106
  When Zeitwerk is defined and when `Rails.application.eager_load!` returns `false`, you should call `Zeitwerk::Loader.eager_load_all`.
107
107
 
108
+ ## Running the tests
109
+
110
+ The test suite is written with [RSpec](https://rspec.info) and needs no running RabbitMQ: the broker is stubbed.
111
+
112
+ ```bash
113
+ bundle install
114
+ bundle exec rake # or: bundle exec rspec
115
+ ```
116
+
117
+ ## Running the integration tests
118
+
119
+ The test suite above needs no running RabbitMQ. A second suite, under `spec_integration/`, exercises `Happn`
120
+ against a real broker instead: queue and binding lifecycle, message routing, consumption and acknowledgement,
121
+ and the reject-and-exit contract when a projector handler raises.
122
+
123
+ ```bash
124
+ docker compose up -d --wait # starts RabbitMQ with the management plugin
125
+ bundle exec rake integration # or: bundle exec rspec spec_integration
126
+ docker compose down
127
+ ```
128
+
108
129
  ## Overall configuration options
109
130
 
110
131
  All options have a default value. However, all of them can be changed in your `Happn.configure` block.
@@ -127,3 +148,22 @@ All options have a default value. However, all of them can be changed in your `H
127
148
  | `bunny_options` | `{}` | Hash of symbols | Optional | Additional options to add when connecting the RabbitMQ broker. This overrides the existing options with the same name. | `{ verify_peer: true }` |
128
149
  | `management_options` | `{}` | Hash of symbols | Optional | Additional options to add when accessing the RabbitMQ Managmement. This overrides the existing options with the same name. The options are defined at https://github.com/ruby-amqp/rabbitmq_http_api_client | `{ verify: false }` |
129
150
  | `on_error` | `nil` | `block` with an argument `exception` | false | When the consumption of an event raises an Error, the consumption exits. However, this block can be called before exiting the consumption execution. | `lambda { |exception| Raven.capture_exception(exception) }` (see Sentry's [documentation](https://github.com/getsentry/raven-ruby) |
151
+
152
+ ## How to release a new version
153
+
154
+ Releases are published to [RubyGems](https://rubygems.org/gems/happn) by GitHub Actions
155
+ (`.github/workflows/release.yml`), through [Trusted Publishing](https://guides.rubygems.org/trusted-publishing/):
156
+ no API key is stored in this repository, the workflow exchanges a short-lived GitHub OIDC token for a
157
+ scoped RubyGems credential.
158
+
159
+ 1. Update `Happn::VERSION` in `lib/happn/version.rb` and the `CHANGELOG.md`
160
+ 2. Commit and push these changes to `main`
161
+ 3. Tag the commit and push the tag:
162
+
163
+ ```
164
+ $ git tag -a v1.1.7 -m "Version 1.1.7"
165
+ $ git push origin v1.1.7
166
+ ```
167
+
168
+ The workflow then checks that the tag matches `Happn::VERSION`, runs the tests, builds the gem
169
+ and pushes it. It only publishes tags starting with `v`.
data/happn.gemspec CHANGED
@@ -9,17 +9,26 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Commuty"]
10
10
  spec.email = ["support@commuty.net"]
11
11
  spec.summary = "Gem to connect a RabbitMQ exchange and listen for events."
12
- spec.description = "Gem to connect a RabbitMQ exchange and listen for events."
13
- spec.homepage = "https://gitlab.spin42.me/commuty/happn"
12
+ spec.description = "Happn connects a RabbitMQ topic exchange and consumes CREPE events sequentially. " \
13
+ "It lets developers declare \"projectors\" that match events on their emitter, kind, " \
14
+ "name and status, and binds its queue to the exchange according to those matchers."
15
+ spec.homepage = "https://github.com/crepesourcing/happn-ruby"
14
16
  spec.license = "MIT"
15
17
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.required_ruby_version = ">= 3.2"
19
+
20
+ spec.metadata = {
21
+ "source_code_uri" => spec.homepage,
22
+ "changelog_uri" => "#{spec.homepage}/blob/main/CHANGELOG.md",
23
+ "bug_tracker_uri" => "#{spec.homepage}/issues",
24
+ "rubygems_mfa_required" => "true"
25
+ }
26
+
27
+ spec.files = Dir.glob(["lib/**/*.rb", "CHANGELOG.md", "MIT-LICENSE", "README.md", "happn.gemspec"]).sort
19
28
  spec.require_paths = ["lib"]
20
29
 
21
30
  spec.add_development_dependency "bundler", ">=1.17"
22
- spec.add_development_dependency "rake", ">=12.0"
31
+ spec.add_development_dependency "rake", ">= 13.0"
23
32
  spec.add_development_dependency "rspec", "~>3.0"
24
33
  spec.add_dependency "bunny", ">=2.19.0"
25
34
  spec.add_dependency "rabbitmq_http_api_client", ">=2.0.0"
data/lib/happn/event.rb CHANGED
@@ -38,7 +38,12 @@ module Happn
38
38
  end
39
39
 
40
40
  def timestamp
41
- DateTime.parse(@meta[:timestamp])
41
+ raw_timestamp = @meta[:timestamp]
42
+ if raw_timestamp.nil? || raw_timestamp.to_s.strip.empty?
43
+ nil
44
+ else
45
+ DateTime.parse(raw_timestamp)
46
+ end
42
47
  end
43
48
 
44
49
  def id
@@ -70,11 +75,11 @@ module Happn
70
75
  end
71
76
 
72
77
  def has_change?(attribute_name)
73
- !changes[attribute_name].nil?
78
+ !changes[attribute_name.to_sym].nil?
74
79
  end
75
80
 
76
81
  def delete_change(attribute_name)
77
- changes.delete(attribute_name)
82
+ changes.delete(attribute_name.to_sym)
78
83
  end
79
84
 
80
85
  private
@@ -1,4 +1,5 @@
1
1
  require "bunny"
2
+ require "json"
2
3
  require "rabbitmq/http/client"
3
4
 
4
5
  module Happn
data/lib/happn/query.rb CHANGED
@@ -8,10 +8,10 @@ module Happn
8
8
  raise "'Dot' is not a valid character"
9
9
  end
10
10
 
11
- @emitter = emitter
12
- @kind = kind
13
- @name = name
14
- @status = status
11
+ @emitter = normalize(emitter)
12
+ @kind = normalize(kind)
13
+ @name = normalize(name)
14
+ @status = normalize(status)
15
15
  end
16
16
 
17
17
  def to_routing_key
@@ -20,6 +20,10 @@ module Happn
20
20
 
21
21
  private
22
22
 
23
+ def normalize(query_expression)
24
+ query_expression.nil? ? :all : query_expression
25
+ end
26
+
23
27
  def to_expression(query_expression)
24
28
  query_expression == :all ? "*" : query_expression
25
29
  end
data/lib/happn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Happn
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.7"
3
3
  end
data/lib/happn.rb CHANGED
@@ -54,7 +54,6 @@ module Happn
54
54
  config.on_error = nil
55
55
  config.bunny_options = {}
56
56
  config.management_options = {}
57
- config.on_error = nil
58
57
  end
59
58
 
60
59
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Commuty
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '12.0'
32
+ version: '13.0'
33
33
  type: :development
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '12.0'
39
+ version: '13.0'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rspec
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -79,7 +79,9 @@ dependencies:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: 2.0.0
82
- description: Gem to connect a RabbitMQ exchange and listen for events.
82
+ description: Happn connects a RabbitMQ topic exchange and consumes CREPE events sequentially.
83
+ It lets developers declare "projectors" that match events on their emitter, kind,
84
+ name and status, and binds its queue to the exchange according to those matchers.
83
85
  email:
84
86
  - support@commuty.net
85
87
  executables: []
@@ -87,7 +89,6 @@ extensions: []
87
89
  extra_rdoc_files: []
88
90
  files:
89
91
  - CHANGELOG.md
90
- - Gemfile
91
92
  - MIT-LICENSE
92
93
  - README.md
93
94
  - happn.gemspec
@@ -100,10 +101,14 @@ files:
100
101
  - lib/happn/subscription.rb
101
102
  - lib/happn/subscription_repository.rb
102
103
  - lib/happn/version.rb
103
- homepage: https://gitlab.spin42.me/commuty/happn
104
+ homepage: https://github.com/crepesourcing/happn-ruby
104
105
  licenses:
105
106
  - MIT
106
- metadata: {}
107
+ metadata:
108
+ source_code_uri: https://github.com/crepesourcing/happn-ruby
109
+ changelog_uri: https://github.com/crepesourcing/happn-ruby/blob/main/CHANGELOG.md
110
+ bug_tracker_uri: https://github.com/crepesourcing/happn-ruby/issues
111
+ rubygems_mfa_required: 'true'
107
112
  rdoc_options: []
108
113
  require_paths:
109
114
  - lib
@@ -111,14 +116,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
116
  requirements:
112
117
  - - ">="
113
118
  - !ruby/object:Gem::Version
114
- version: '0'
119
+ version: '3.2'
115
120
  required_rubygems_version: !ruby/object:Gem::Requirement
116
121
  requirements:
117
122
  - - ">="
118
123
  - !ruby/object:Gem::Version
119
124
  version: '0'
120
125
  requirements: []
121
- rubygems_version: 4.0.17
126
+ rubygems_version: 3.6.9
122
127
  specification_version: 4
123
128
  summary: Gem to connect a RabbitMQ exchange and listen for events.
124
129
  test_files: []
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec