sequent-rails 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +27 -0
  4. data/Rakefile +30 -0
  5. data/app/assets/config/sequent_rails_manifest.js +1 -0
  6. data/app/assets/stylesheets/sequent/application.css +15 -0
  7. data/app/assets/stylesheets/sequent/events.css +4 -0
  8. data/app/controllers/sequent/application_controller.rb +5 -0
  9. data/app/controllers/sequent/commands_controller.rb +13 -0
  10. data/app/controllers/sequent/events_controller.rb +23 -0
  11. data/app/controllers/sequent/streams_controller.rb +19 -0
  12. data/app/helpers/sequent/application_helper.rb +4 -0
  13. data/app/helpers/sequent/events_helper.rb +4 -0
  14. data/app/jobs/sequent/application_job.rb +4 -0
  15. data/app/mailers/sequent/application_mailer.rb +6 -0
  16. data/app/models/sequent/application_record.rb +5 -0
  17. data/app/views/layouts/sequent/application.html.erb +42 -0
  18. data/app/views/sequent/commands/show.html.erb +45 -0
  19. data/app/views/sequent/events/_event_record.html.erb +11 -0
  20. data/app/views/sequent/events/index.html.erb +30 -0
  21. data/app/views/sequent/events/show.html.erb +45 -0
  22. data/app/views/sequent/streams/_stream_record.html.erb +10 -0
  23. data/app/views/sequent/streams/index.html.erb +16 -0
  24. data/config/routes.rb +7 -0
  25. data/lib/generators/sequent_install_generator.rb +29 -0
  26. data/lib/generators/templates/db/create_event_store.rb +44 -0
  27. data/lib/sequent-rails.rb +8 -0
  28. data/lib/sequent-rails/engine.rb +9 -0
  29. data/lib/sequent-rails/railtie.rb +11 -0
  30. data/lib/sequent-rails/version.rb +3 -0
  31. data/lib/tasks/sequent/rails_tasks.rake +19 -0
  32. data/spec/controllers/sequent/commands_controller_spec.rb +13 -0
  33. data/spec/controllers/sequent/events_controller_spec.rb +21 -0
  34. data/spec/controllers/sequent/streams_controller_spec.rb +13 -0
  35. data/spec/dummy/Rakefile +6 -0
  36. data/spec/dummy/app/assets/config/manifest.js +3 -0
  37. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  38. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  39. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  40. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  41. data/spec/dummy/app/domains/dummy.rb +28 -0
  42. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  43. data/spec/dummy/app/javascript/packs/application.js +15 -0
  44. data/spec/dummy/app/jobs/application_job.rb +7 -0
  45. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  46. data/spec/dummy/app/models/application_record.rb +3 -0
  47. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  48. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  49. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  50. data/spec/dummy/bin/rails +4 -0
  51. data/spec/dummy/bin/rake +4 -0
  52. data/spec/dummy/bin/setup +32 -0
  53. data/spec/dummy/bin/update +27 -0
  54. data/spec/dummy/config.ru +5 -0
  55. data/spec/dummy/config/application.rb +19 -0
  56. data/spec/dummy/config/boot.rb +5 -0
  57. data/spec/dummy/config/cable.yml +10 -0
  58. data/spec/dummy/config/database.yml +25 -0
  59. data/spec/dummy/config/environment.rb +5 -0
  60. data/spec/dummy/config/environments/development.rb +62 -0
  61. data/spec/dummy/config/environments/production.rb +112 -0
  62. data/spec/dummy/config/environments/test.rb +47 -0
  63. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  64. data/spec/dummy/config/initializers/assets.rb +12 -0
  65. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  66. data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
  67. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  68. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  69. data/spec/dummy/config/initializers/inflections.rb +16 -0
  70. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  71. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  72. data/spec/dummy/config/locales/en.yml +33 -0
  73. data/spec/dummy/config/puma.rb +35 -0
  74. data/spec/dummy/config/routes.rb +3 -0
  75. data/spec/dummy/config/spring.rb +6 -0
  76. data/spec/dummy/config/storage.yml +34 -0
  77. data/spec/dummy/db/development.sqlite3 +0 -0
  78. data/spec/dummy/db/migrate/20190306181535_create_event_store.rb +44 -0
  79. data/spec/dummy/db/schema.rb +44 -0
  80. data/spec/dummy/db/sequent_schema.rb +51 -0
  81. data/spec/dummy/db/test.sqlite3 +0 -0
  82. data/spec/dummy/log/development.log +4533 -0
  83. data/spec/dummy/log/test.log +3523 -0
  84. data/spec/dummy/postgres +0 -0
  85. data/spec/dummy/public/404.html +67 -0
  86. data/spec/dummy/public/422.html +67 -0
  87. data/spec/dummy/public/500.html +66 -0
  88. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  89. data/spec/dummy/public/apple-touch-icon.png +0 -0
  90. data/spec/dummy/public/favicon.ico +0 -0
  91. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1d/1dQeaWjMQHspoJITm3S5rKch7Na9LY8hEOuvV7-zpV0.cache +0 -0
  92. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4u/4upH7Ppgh7FnLtwm4nA_acTB5-PGL0MFJUlyjF6e2Fs.cache +1 -0
  93. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7P/7PS02kUE9Zs_4rX1yK2VjGjCTSYNqMf8W7hJ0rEEkM0.cache +1 -0
  94. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/At/AtH6UmnAL8UWD50ttSa4pOTWQSvzlU6sqB7yUMX7kxo.cache +1 -0
  95. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Bz/BzmMouzoHq2P5iUzSVty3FLpZJRHSZgyVU-gX5VaM9w.cache +0 -0
  96. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/CB/CBvcsH236VTECTQ1Nau3yiBbx4xm-6YzJLPOhZL-UcI.cache +0 -0
  97. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/CZ/CZ14YU2CmknFTo2fmCxnF3GX6GvfIBzUcAJPQrNVqnY.cache +2 -0
  98. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Jd/JdyGYcgVngpZ0ZvNH-NoNocc8Uc0OxOjzADBr_fdE1o.cache +2 -0
  99. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/O-/O-WYnJo6YnRKSnkmMhhm0yqdywR7ZMe3ZtUaH4CVHIY.cache +0 -0
  100. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Rl/RlXzNldRsfe_qJAbM0vxH2tPAdB8mjPMYVTzscDqBHQ.cache +2 -0
  101. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Tr/TrnRBzBupQnsm7FRKpjHzr-rur9n6E41wBhR5mCNOxM.cache +1 -0
  102. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/U0/U04DM1V7i_pb0XbkSMsKVmwmnlmPqTHKXp6RVsz6OtE.cache +1 -0
  103. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/VT/VTL3b-HPToYtYE2fOSpYLuYo5ii9yaJatDertXtDQQE.cache +1 -0
  104. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Xj/XjmI6iua5y59N4-RziEfKRchfYFNSSwwSyZIC6mzWAo.cache +1 -0
  105. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ZY/ZYGTEco0q8pXH0nLnNtIdi4sJT6RP3Opwonr5nXpcCI.cache +0 -0
  106. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aw/awzofY3gI_LwBNk6Y6K7r_aYZiTQylZZQNAObbems2A.cache +0 -0
  107. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/h8/h88OM1n3S0NU75Avy6Cwv1eZBpJ0-CKSseVj9o3Z-5A.cache +1 -0
  108. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iO/iOovmGrTgTMk6e-g3JCY133TBXG9mOx_7MGukjgXTIs.cache +0 -0
  109. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/lH/lH3cPMVbHurfIhlRo9w435AshPNIdg4Z44o0q2zwqyA.cache +1 -0
  110. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/n_/n_xYqQYhwEMQknb3jFQnjlxxBE9TzMNHCdJ-bEyZFIw.cache +2 -0
  111. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/nx/nxTv3sKVUQZADJyM3dPaVmUA78MIsMLD_K279yN_GsI.cache +2 -0
  112. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/qA/qAT0qzQX02MqiB2n7v1PG81xwe5IXG1KpgVPPLp2FrM.cache +1 -0
  113. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/s_/s_YjQyhcUDLVttYhyZ751NX0iyHYFYFSEG-ffw1zEqE.cache +1 -0
  114. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/tH/tHG2oi8K6QfFkmj3qWVTgDUV5DjzUT_g_mGt-CNzS7o.cache +3 -0
  115. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wc/wc--IRm0aoGpFXGbBMkwSfBevbtd4_JLH4x1mQe7Z0E.cache +1 -0
  116. data/spec/rails_helper.rb +63 -0
  117. data/spec/spec_helper.rb +96 -0
  118. metadata +330 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c4e22995fdd50ae7ac93569a69bb4fea414079f0dba7f0d6271ba61c1c6aa143
4
+ data.tar.gz: 66802970375645cd5df85d6fb6e78b127674cc467ffdd976338722fd3e743a8b
5
+ SHA512:
6
+ metadata.gz: 770e604dcd3953f4c68ff1e716a48602b1f57e1c6489f0b43b357569cb1501d3604477631189ad0a89de1051d0e58b95ee778c5a23ca629bbc76ba025d42251d
7
+ data.tar.gz: 7f676ff3085b24a681188ba369f74030e74852374499986befd079f854703ab6d0ea3f9c2f0f330d5f9347804ba550af6a3df5b4b00a6480e9d0846824e59732
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019 Sophie Déziel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # Sequent-Rails
2
+ Warning: This is an experiment gem, not sutable for production use.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'sequent-rails'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ bundle
17
+ rails generate sequent:install
18
+ rails db:migrate
19
+ ```
20
+
21
+ This will generate a migration file to create Sequent's event store in the database and then run it.
22
+
23
+ ## Contributing
24
+ Contribution directions go here.
25
+
26
+ ## License
27
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Sequent-Rails'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rspec/core'
25
+ require 'rspec/core/rake_task'
26
+
27
+ desc "Run all specs in spec directory (excluding plugin specs)"
28
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
29
+
30
+ task default: :spec
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/sequent.css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,5 @@
1
+ module Sequent
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ require_dependency "sequent/application_controller"
2
+
3
+ module Sequent
4
+ class CommandsController < ApplicationController
5
+ def index
6
+ @commands = Sequent::Core::CommandRecord.all.order(id: :desc)
7
+ end
8
+
9
+ def show
10
+ @command = Sequent::Core::CommandRecord.find(params[:id])
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ require_dependency "sequent/application_controller"
2
+
3
+ module Sequent
4
+ class EventsController < ApplicationController
5
+ def index
6
+ @grouped_events = get_events.limit(100).order(id: :desc).includes(:command_record).group_by(&:command_record)
7
+ end
8
+
9
+ def show
10
+ @event = Sequent::Core::EventRecord.find(params[:id])
11
+ end
12
+
13
+ private
14
+
15
+ def get_events
16
+ if params[:stream_id].present?
17
+ Sequent::Core::StreamRecord.find(params[:stream_id]).event_records
18
+ else
19
+ Sequent::Core::EventRecord.all
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ require_dependency "sequent/application_controller"
2
+
3
+ module Sequent
4
+ class StreamsController < ApplicationController
5
+ def index
6
+ @streams = get_streams.order(id: :desc)
7
+ end
8
+
9
+ private
10
+
11
+ def get_streams
12
+ if params[:aggregate_type].present?
13
+ Sequent::Core::StreamRecord.where(aggregate_type: params[:aggregate_type])
14
+ else
15
+ Sequent::Core::StreamRecord.all
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ module Sequent
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Sequent
2
+ module EventsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Sequent
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Sequent
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Sequent
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,42 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <%= csrf_meta_tags %>
8
+ <%= csp_meta_tag %>
9
+
10
+ <title>Sequent rails</title>
11
+
12
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.0/css/bootstrap.min.css">
13
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
14
+
15
+ <%= stylesheet_link_tag "sequent/application", media: "all" %>
16
+
17
+
18
+ <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
19
+ <!-- Leave those next 4 lines if you care about users using IE8 -->
20
+ <!--[if lt IE 9]>
21
+ <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
22
+ <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
23
+ <![endif]-->
24
+ </head>
25
+ <body>
26
+ <div class='container'>
27
+ <ul class="nav nav-tabs">
28
+ <li class="nav-item">
29
+ <%= link_to "Streams", streams_path, class: 'nav-link' %>
30
+ </li>
31
+ <li class="nav-item">
32
+ <%= link_to "Events", events_path, class: 'nav-link' %>
33
+ </li>
34
+ </ul>
35
+ <%= yield %>
36
+ </div>
37
+
38
+ <!-- Including Bootstrap JS (with its jQuery dependency) so that dynamic components work -->
39
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
40
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.0/js/bootstrap.min.js"></script>
41
+ </body>
42
+ </html>
@@ -0,0 +1,45 @@
1
+ <table class="table table-bordered">
2
+ <thead class="thead-dark">
3
+ <tr>
4
+ <th scope="col">Attribute</th>
5
+ <th scope="col">Value</th>
6
+ </tr>
7
+ </thead>
8
+
9
+ <tbody>
10
+ <tr>
11
+ <th scope="row">id</th>
12
+ <td><%= @command.id %></td>
13
+ </tr>
14
+
15
+ <tr>
16
+ <th scope="row">Type</th>
17
+ <td><%= @command.command_type %></td>
18
+ </tr>
19
+
20
+ <tr>
21
+ <th scope="row">User</th>
22
+ <td><%= @command.user_id %></td>
23
+ </tr>
24
+
25
+ <tr>
26
+ <th scope="row">Created At</th>
27
+ <td><%= @command.created_at %></td>
28
+ </tr>
29
+
30
+ <tr>
31
+ <th scope="row">aggregate_id</th>
32
+ <td><%= @command.aggregate_id %></td>
33
+ </tr>
34
+
35
+ <tr>
36
+ <th scope="row">event_json</th>
37
+ <td>
38
+ <code>
39
+ <%= simple_format JSON.pretty_generate(JSON.parse @command.command_json) %>
40
+ </code>
41
+ </td>
42
+ </tr>
43
+ </tbody>
44
+ </table>
45
+
@@ -0,0 +1,11 @@
1
+ <tr>
2
+ <th scope="row"> <%= event_record.id %></th>
3
+ <td><%= link_to event_record.event_type, event_path(event_record) %></td>
4
+ <td><%= link_to event_record.aggregate_id, stream_events_path(stream_id: event_record.stream_record_id) %></td>
5
+ <td><%= event_record.sequence_number %></td>
6
+ <td>
7
+ <code>
8
+ <%= JSON.parse(event_record.event_json).except("sequence_number", "aggregate_id").to_json %>
9
+ </code>
10
+ </td>
11
+ </tr>
@@ -0,0 +1,30 @@
1
+ <%= link_to "Aggregate:" + params[:aggregate_id], url_for(aggregate_id: nil), class: 'badge badge-secondary' if params[:aggregate_id] %>
2
+ <%= link_to "Stream: " + params[:stream_id], url_for(stream_id: nil), class: 'badge badge-secondary' if params[:stream_id] %>
3
+
4
+ <table class="table table-striped table-hover">
5
+ <thead class="thead-dark">
6
+ <tr>
7
+ <th scope="col"> id</th>
8
+ <th scope="col"> event_type</th>
9
+ <th scope="col"> aggregate_id</th>
10
+ <th scope="col"> sequence_number</th>
11
+ <th scope="col"> event_json</th>
12
+ </tr>
13
+ </thead>
14
+
15
+ <% @grouped_events.each do |command, events| %>
16
+ <thead class="thead-light">
17
+ <tr>
18
+ <th colspan="4">
19
+ <%= link_to command.command_type, command_path(command) %>
20
+ </th>
21
+ <th colspan="4">
22
+ User: <%= command.user_id %>
23
+ </th>
24
+ </tr>
25
+ </thead>
26
+ <tbody class="events">
27
+ <%= render collection: events, partial: 'event_record' %>
28
+ </tbody>
29
+ <% end %>
30
+ </table>
@@ -0,0 +1,45 @@
1
+ <table class="table table-bordered">
2
+ <thead class="thead-dark">
3
+ <tr>
4
+ <th scope="col">Attribute</th>
5
+ <th scope="col">Value</th>
6
+ </tr>
7
+ </thead>
8
+
9
+ <tbody>
10
+ <tr>
11
+ <th scope="row">Id</th>
12
+ <td><%= @event.id %></td>
13
+ </tr>
14
+
15
+ <tr>
16
+ <th scope="row">Type</th>
17
+ <td><%= @event.event_type %></td>
18
+ </tr>
19
+
20
+ <tr>
21
+ <th scope="row">Aggregate Id</th>
22
+ <td><%= @event.aggregate_id %></td>
23
+ </tr>
24
+
25
+ <tr>
26
+ <th scope="row">Sequence Number</th>
27
+ <td><%= @event.sequence_number %></td>
28
+ </tr>
29
+
30
+ <tr>
31
+ <th scope="row">Command</th>
32
+ <td><%= link_to @event.command_record.command_type, command_path(@event.command_record) %></td>
33
+ </tr>
34
+
35
+ <tr>
36
+ <th scope="row">JSON</th>
37
+ <td>
38
+ <code>
39
+ <%= simple_format JSON.pretty_generate(JSON.parse @event.event_json) %>
40
+ </code>
41
+ </td>
42
+ </tr>
43
+ </tbody>
44
+ </table>
45
+
@@ -0,0 +1,10 @@
1
+ <tr>
2
+ <th scope="row"> <%= stream_record.id %></th>
3
+ <td><%= link_to stream_record.aggregate_id, stream_events_path(stream_record.id) %></td>
4
+ <td><%= link_to stream_record.aggregate_type, url_for(aggregate_type: stream_record.aggregate_type) %></td>
5
+ <td>
6
+ <code>
7
+ <%= stream_record.attributes.to_json %>
8
+ </code>
9
+ </td>
10
+ </tr>
@@ -0,0 +1,16 @@
1
+ <%= link_to "Type: " + params[:aggregate_type], url_for(aggregate_type: nil), class: 'badge badge-secondary' if params[:aggregate_type] %>
2
+
3
+ <table class="table table-striped table-hover">
4
+ <thead class="thead-dark">
5
+ <tr>
6
+ <th scope="col">id</th>
7
+ <th scope="col">aggregate_id</th>
8
+ <th scope="col">aggregate_type</th>
9
+ <th scope="col">data</th>
10
+ </tr>
11
+ </thead>
12
+
13
+ <tbody class="events">
14
+ <%= render partial: 'stream_record', collection: @streams %>
15
+ </tbody>
16
+ </table>
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Sequent::Engine.routes.draw do
2
+ resources :events, only: [:index, :show]
3
+ resources :commands, only: [:show]
4
+ resources :streams, only: [:index, :show] do
5
+ resources :events, only: [:index]
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ class Sequent::InstallGenerator < Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+ include ActiveRecord::Generators::Migration
6
+
7
+ source_root File.expand_path('lib/generators/templates/db/', Gem.loaded_specs['sequent-rails'].full_gem_path)
8
+ desc "Copies a migration file to create the Event Store in the database of your application"
9
+
10
+ def create_initializer_file
11
+ migration_template 'create_event_store.rb', "db/migrate/create_event_store.rb"
12
+ end
13
+
14
+ private
15
+
16
+ def migration_exists?
17
+ Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_create_event_store.rb$/).first
18
+ end
19
+
20
+ def migration_version
21
+ if rails5_and_up?
22
+ "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
23
+ end
24
+ end
25
+
26
+ def rails5_and_up?
27
+ Rails::VERSION::MAJOR >= 5
28
+ end
29
+ end