Skip to content

Commit

Permalink
Added RakeTasks bootstrap stage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesiarmes committed Aug 27, 2024
1 parent b1de9dc commit d16360d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/bootstrap/rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require_relative 'stage/database'
require_relative 'stage/jobs'
require_relative 'stage/logger'
require_relative 'stage/rake_tasks'

module DocumentTransfer
module Bootstrap
Expand All @@ -25,6 +26,8 @@ def bootstrap
rescue Sequel::DatabaseConnectionError => e
warn("Database connection error: #{e.message}")
end

Stage::RakeTasks.new(@config).bootstrap
end
end
end
Expand Down
20 changes: 20 additions & 0 deletions lib/bootstrap/stage/rake_tasks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

require 'delayed_job'

require_relative 'base'
require_relative '../../document_transfer'

module DocumentTransfer
module Bootstrap
module Stage
# Bootstrap rake tasks.
class RakeTasks < Base
# Load all custom rake tasks.
def bootstrap
DocumentTransfer.load_rake_tasks
end
end
end
end
end
4 changes: 3 additions & 1 deletion spec/support/examples/bootstrap_stages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
DocumentTransfer::Bootstrap.load_stages

stages.to_h do |stage|
klass = DocumentTransfer::Bootstrap::Stage.const_get(stage.capitalize)
klass = DocumentTransfer::Bootstrap::Stage.const_get(
stage.to_s.split('_').map(&:capitalize).join
)
double = instance_double(klass, bootstrap: nil)
allow(klass).to receive(:new).and_return(double)
[stage, double]
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/document_transfer/bootstrap/rake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative '../../../../lib/bootstrap/rake'

RSpec.describe DocumentTransfer::Bootstrap::Rake do
include_examples 'bootstrap_stages', %i[logger database jobs]
include_examples 'bootstrap_stages', %i[logger database jobs rake_tasks]
end

0 comments on commit d16360d

Please sign in to comment.