Skip to content

Commit 3894f28

Browse files
committed
Release v4.2.0
1 parent 7b35cf7 commit 3894f28

File tree

16 files changed

+95
-42
lines changed

16 files changed

+95
-42
lines changed

.rubocop.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Style/FrozenStringLiteralComment:
3030

3131
Style/StringLiterals:
3232
EnforcedStyle: single_quotes
33-
ConsistentQuotesInMultiline: true
33+
ConsistentQuotesInMultiline: false
3434

3535
Style/SymbolArray:
3636
EnforcedStyle: brackets
@@ -80,6 +80,7 @@ Metrics/CyclomaticComplexity:
8080
- "lib/jetstream_bridge/test_helpers.rb" # Test helper with complex setup
8181
- "lib/jetstream_bridge/core/logging.rb" # URL sanitization with multiple branches
8282
- "lib/jetstream_bridge/consumer/inbox/inbox_message.rb" # NATS message parsing
83+
- "lib/jetstream_bridge/consumer/inbox/inbox_processor.rb" # Inbox processing with multiple branches
8384
- "lib/jetstream_bridge/core/connection.rb" # Connection validation with multiple checks
8485
- "lib/jetstream_bridge/core/debug_helper.rb" # Stream info with compatibility checks
8586
- "lib/jetstream_bridge/test_helpers/mock_nats.rb" # Mock NATS implementation
@@ -99,6 +100,7 @@ Metrics/ModuleLength:
99100
Exclude:
100101
- "lib/jetstream_bridge.rb" # Main module with convenience methods
101102
- "lib/jetstream_bridge/core/debug_helper.rb" # Debug helper with stream info methods
103+
- "lib/jetstream_bridge/rails/integration.rb" # Rails integration with autostart logic
102104

103105
Metrics/ClassLength:
104106
Max: 200
@@ -124,6 +126,7 @@ Naming/PredicatePrefix:
124126
Enabled: true
125127
Exclude:
126128
- "lib/jetstream_bridge/test_helpers.rb" # RSpec matcher convention uses have_*
129+
- "lib/jetstream_bridge/test_helpers/matchers.rb" # RSpec matcher convention uses have_*
127130
- "lib/jetstream_bridge/core/model_utils.rb" # ActiveRecord introspection uses has_*
128131
- "lib/jetstream_bridge/models/outbox_event.rb" # ActiveRecord introspection uses has_*
129132
- "lib/jetstream_bridge/models/inbox_event.rb" # ActiveRecord introspection uses has_*
@@ -164,6 +167,7 @@ Style/OpenStructUse:
164167
Enabled: true
165168
Exclude:
166169
- "lib/jetstream_bridge/test_helpers.rb" # Test doubles for NATS messages
170+
- "lib/jetstream_bridge/test_helpers/integration_helpers.rb" # Test doubles for NATS messages
167171
- "lib/jetstream_bridge/test_helpers/mock_nats.rb" # Mock NATS message objects
168172

169173
# ---------- Packaging / Gemspec ----------

CHANGELOG.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,56 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [4.2.0] - 2025-11-24
9+
10+
### Added
11+
12+
- **Modular Code Organization** - Restructured codebase with dedicated modules
13+
- New `JetstreamBridge::Core` module for core utilities (connection, logging, model utils, helpers)
14+
- New `JetstreamBridge::Rails` module for Rails-specific integration
15+
- Improved separation of concerns and code discoverability
16+
- Better namespace organization for future extensibility
17+
18+
- **Enhanced Test Helpers** - Comprehensive testing utilities split into focused modules
19+
- `JetstreamBridge::TestHelpers::Fixtures` - Convenient fixture generation for events and messages
20+
- `JetstreamBridge::TestHelpers::IntegrationHelpers` - Full NATS message simulation for integration tests
21+
- `JetstreamBridge::TestHelpers::Matchers` - RSpec matchers for event publishing assertions
22+
- Improved test doubles with realistic NATS message structure
23+
- Better support for testing event-driven Rails applications
24+
25+
- **Getting Started Guide** - New comprehensive guide in `docs/GETTING_STARTED.md`
26+
- Quick installation and setup instructions
27+
- Publishing and consuming examples
28+
- Rails integration patterns
29+
- Links to advanced documentation
30+
31+
### Changed
32+
33+
- **Rails Integration** - Reorganized Rails-specific code
34+
- Moved from single `lib/jetstream_bridge/railtie.rb` to dedicated `lib/jetstream_bridge/rails/` directory
35+
- `JetstreamBridge::Rails::Railtie` - Rails lifecycle integration
36+
- `JetstreamBridge::Rails::Integration` - Autostart logic and Rails environment detection
37+
- Cleaner separation between gem core and Rails integration
38+
39+
- **Documentation** - Restructured README for clarity
40+
- Condensed README focusing on quick start and highlights
41+
- Moved detailed guides to dedicated docs directory
42+
- Improved navigation with links to specialized documentation
43+
- More concise examples and clearer feature descriptions
44+
45+
- **Gemspec** - Enhanced package configuration
46+
- Added `docs/**/*.md` to distributed files
47+
- Added `extra_rdoc_files` for better documentation
48+
- Updated description to emphasize production-readiness
49+
50+
### Fixed
51+
52+
- **Code Quality** - Resolved all RuboCop style violations
53+
- Fixed string literal consistency issues
54+
- Improved code formatting and indentation
55+
- Reduced complexity in conditional assignments
56+
- Updated RuboCop configuration for new file structure
57+
858
## [4.1.0] - 2025-11-23
959

1060
### Added

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
jetstream_bridge (4.1.0)
4+
jetstream_bridge (4.2.0)
55
activerecord (>= 7.1.5.2, < 8.0)
66
activesupport (>= 7.1.5.2, < 8.0)
77
mutex_m

jetstream_bridge.gemspec

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Gem::Specification.new do |spec|
1010

1111
spec.summary = 'Production-safe realtime data bridge using NATS JetStream'
1212
spec.description = <<~DESC.strip
13-
Publisher/Consumer utilities for NATS JetStream with environment-scoped subjects,
14-
overlap guards, DLQ routing, retries/backoff, and optional Inbox/Outbox patterns.
15-
Includes health checks, auto-reconnection, graceful shutdown, and topology setup
16-
helpers for production-safe operation.
13+
Production-ready publishers/consumers for NATS JetStream with environment-scoped
14+
subjects, overlap guards, DLQ routing, retries/backoff, and optional inbox/outbox
15+
patterns. Includes health checks, auto-reconnection, graceful shutdown, topology
16+
setup helpers, and Rails generators.
1717
DESC
1818

1919
spec.license = 'MIT'
@@ -39,11 +39,13 @@ Gem::Specification.new do |spec|
3939
'lib/**/*.rake',
4040
'lib/**/templates/**/*',
4141
'README.md',
42+
'docs/**/*.md',
4243
'LICENSE',
4344
'CHANGELOG.md'
4445
].select { |f| File.file?(f) }
4546
end
4647

48+
spec.extra_rdoc_files = ['README.md', 'CHANGELOG.md', 'docs/GETTING_STARTED.md']
4749
spec.require_paths = ['lib']
4850

4951
# Runtime dependencies

lib/jetstream_bridge/consumer/inbox/inbox_repository.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ def initialize(klass)
1111
end
1212

1313
def find_or_build(msg)
14-
if ModelUtils.has_columns?(@klass, :event_id)
15-
record = @klass.find_or_initialize_by(event_id: msg.event_id)
16-
elsif ModelUtils.has_columns?(@klass, :stream_seq)
17-
record = @klass.find_or_initialize_by(stream_seq: msg.seq)
18-
else
19-
record = @klass.new
20-
end
14+
record = if ModelUtils.has_columns?(@klass, :event_id)
15+
@klass.find_or_initialize_by(event_id: msg.event_id)
16+
elsif ModelUtils.has_columns?(@klass, :stream_seq)
17+
@klass.find_or_initialize_by(stream_seq: msg.seq)
18+
else
19+
@klass.new
20+
end
2121

2222
lock_record(record)
2323
end

lib/jetstream_bridge/consumer/message_processor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def initialize(jts, handler, dlq: nil, backoff: nil, middleware_chain: nil)
6363
end
6464

6565
def handle_message(msg, auto_ack: true)
66-
ctx = MessageContext.build(msg)
66+
ctx = MessageContext.build(msg)
6767
event, early_action = parse_message(msg, ctx)
6868
return apply_action(msg, early_action) if early_action && auto_ack
6969
return early_action if early_action

lib/jetstream_bridge/core/connection.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,8 @@ def sanitize_urls(urls)
450450
def cleanup_connection!(close_nc: true)
451451
begin
452452
# Avoid touching RSpec doubles used in unit tests
453-
unless defined?(RSpec::Mocks::Double) && @nc.is_a?(RSpec::Mocks::Double)
454-
@nc.close if close_nc && @nc&.respond_to?(:close) && @nc.connected?
455-
end
453+
is_rspec_double = defined?(RSpec::Mocks::Double) && @nc.is_a?(RSpec::Mocks::Double)
454+
@nc.close if !is_rspec_double && close_nc && @nc.respond_to?(:close) && @nc.connected?
456455
rescue StandardError
457456
# ignore cleanup errors
458457
end

lib/jetstream_bridge/models/inbox_event.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ def respond_to_missing?(_method_name, _include_private = false)
174174
def raise_missing_ar!(which, method_name)
175175
raise(
176176
"#{which} requires ActiveRecord (tried to call ##{method_name}). " \
177-
"Enable `use_inbox` only in apps with ActiveRecord, or add " \
178-
"`gem \"activerecord\"` to your Gemfile."
177+
'Enable `use_inbox` only in apps with ActiveRecord, or add ' \
178+
'`gem "activerecord"` to your Gemfile.'
179179
)
180180
end
181181
end

lib/jetstream_bridge/models/outbox_event.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ def respond_to_missing?(_method_name, _include_private = false)
169169
def raise_missing_ar!(which, method_name)
170170
raise(
171171
"#{which} requires ActiveRecord (tried to call ##{method_name}). " \
172-
"Enable `use_outbox` only in apps with ActiveRecord, or add " \
173-
"`gem \"activerecord\"` to your Gemfile."
172+
'Enable `use_outbox` only in apps with ActiveRecord, or add ' \
173+
'`gem "activerecord"` to your Gemfile.'
174174
)
175175
end
176176
end

lib/jetstream_bridge/rails.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# Entry point for Rails-specific integration (lifecycle helpers + railtie)
44
require_relative 'rails/integration'
5-
require_relative 'rails/railtie' if defined?(::Rails::Railtie)
5+
require_relative 'rails/railtie' if defined?(Rails::Railtie)

0 commit comments

Comments
 (0)