examples/multiple_listeners/Rakefile
# frozen_string_literal: true
if RUBY_VERSION <= '3.1'
puts 'This example requires Ruby 3.1 or higher.'
exit! 1
end
# Usage:
#
# rake DISABLE_EVENT_LOGS=t
# rake DISABLE_LISTENER=t
#
# rake HIDE_GIVEN_AND_CONTINUE=t
#
# rake BREAK_ACCOUNT_CREATION=t
# rake BREAK_USER_CREATION=t
# rake BREAK_USER_TOKEN_CREATION=t
#
# rake BREAK_ACCOUNT_CREATION=t HIDE_GIVEN_AND_CONTINUE=t
task default: %i[solid_result_event_logs]
desc 'creates an account and an owner user through Solid::Result'
task :solid_result_event_logs do
require_relative 'config'
Solid::Result.configuration do |config|
config.feature.disable!(:event_logs) if ENV['DISABLE_EVENT_LOGS']
unless ENV['DISABLE_LISTENER']
config.event_logs.listener = Solid::Result::EventLogs::Listeners[
EventLogsListener::Stdout,
Solid::Result::EventLogsRecord::Listener
]
end
end
result = nil
bench = Benchmark.measure do
result = Account::OwnerCreation.new.call(
owner: {
name: "\tJohn Doe \n",
email: ' JOHN.doe@email.com',
password: '123123123',
password_confirmation: '123123123'
}
)
rescue RuntimeBreaker::Interruption => e
nil
end
puts "\nSolid::Result::EventLogsRecord.count: #{Solid::Result::EventLogsRecord.count}"
puts "\nBenchmark: #{bench}"
end