def puts_red(heredoc); puts set_color heredoc, :red; end def puts_green(heredoc); puts set_color heredoc, :green; end puts_red "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" puts_red "@@ @@@@@@@@ @@@@@@@@37@@@" puts_red "@ @@@@@ @@@@@@@@@@@@@" puts_red "@ @@@@@ @@@@ @@@@" puts_red "@ @@@@@ @@@@ @@" puts_red "@ @@@@ @@@@@@ @" puts_red "@ @@@@@@@ @@@@@@ @" puts_red "@ @@ @@@@@@ @@@@@@ @" puts_red "@ @@@@ @@@@ @@" puts_red "@@ @@@@@ @@@@@ @@@@" puts_red "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" puts_red "@@@@@@@@ https://www.rubidium.io @@@@@@@@@" puts_red "@@@@@@@@@@@@@@ 85.4678 @@@@@@@@@@@@@@@@@@" puts_red "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" puts "" puts "" # Checks for unstagged commits return_message = "There are unstaged commits. Do you want to continue?" return if !run("git diff --no-patch --exit-code") && no?(return_message) # TEMPLATE START gem 'rails_event_store', '~> 1.0.0' after_bundle do initializer 'rails_event_store.rb', <<~CODE require 'rails_event_store' require 'aggregate_root' require 'arkency/command_bus' Rails.configuration.to_prepare do Rails.configuration.event_store = RailsEventStore::Client.new Rails.configuration.command_bus = Arkency::CommandBus.new AggregateRoot.configure do |config| config.default_event_store = Rails.configuration.event_store end # Subscribe event handlers below # Rails.configuration.event_store.tap do |store| # store.subscribe(InvoiceReadModel.new, to: [InvoicePrinted]) # store.subscribe(->(event) { SendOrderConfirmation.new.call(event) }, to: [OrderSubmitted]) # store.subscribe_to_all_events(->(event) { Rails.logger.info(event.type) }) # end # Register command handlers below # Rails.configuration.command_bus.tap do |bus| # bus.register(PrintInvoice, Invoicing::OnPrint.new) # bus.register(SubmitOrder, ->(cmd) { Ordering::OnSubmitOrder.new.call(cmd) }) # end end CODE generate 'rails_event_store_active_record:migration' rails_command 'db:migrate' route "mount RailsEventStore::Browser => '/res' if Rails.env.development?"end # TEMPLATE END puts "" puts "" puts_green "Template Name: Event driven Rails application with Rails Event Store" puts_green "By: dev (https://www.rubidium.io/profiles/dev)" puts_green "https://www.rubidium.io/templates/event-driven-rails-application-with-rails-event-store"