Skip to content

Commit

Permalink
Merge pull request #44 from alphagov/worker-zeitwerk
Browse files Browse the repository at this point in the history
Use Zeitwerk for autoloading in document sync worker
  • Loading branch information
csutter authored Oct 6, 2023
2 parents b67e264 + 9b58563 commit ab229a6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ group :document_sync_worker do
gem "govuk_message_queue_consumer"
gem "jsonpath"
gem "plek"
gem "zeitwerk"
end

group :test do
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ DEPENDENCIES
rspec-rails
rubocop-govuk
simplecov
zeitwerk

RUBY VERSION
ruby 3.2.2p53
Expand Down
12 changes: 4 additions & 8 deletions lib/document_sync_worker.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# Gems specific to the document sync worker are in their own group in the Gemfile
Bundler.require(:document_sync_worker)

require "document_sync_worker/configuration"
require "document_sync_worker/message_processor"

require "document_sync_worker/document"
require "document_sync_worker/document/base"
require "document_sync_worker/document/publish"
require "document_sync_worker/document/unpublish"

module DocumentSyncWorker
loader = Zeitwerk::Loader.new
loader.push_dir("#{__dir__}/document_sync_worker", namespace: DocumentSyncWorker)
loader.setup

def self.configuration
@configuration ||= Configuration.new
end
Expand Down
1 change: 0 additions & 1 deletion spec/lib/document_sync_worker/message_processor_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require "govuk_message_queue_consumer"
require "govuk_message_queue_consumer/test_helpers"

RSpec.describe DocumentSyncWorker::MessageProcessor do
Expand Down
2 changes: 0 additions & 2 deletions spec/lib/document_sync_worker_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require "govuk_message_queue_consumer"

RSpec.describe DocumentSyncWorker do
describe ".run" do
let(:consumer) { instance_double(GovukMessageQueueConsumer::Consumer, run: nil) }
Expand Down

0 comments on commit ab229a6

Please sign in to comment.