rails-mermaid_erd_markdown 0.1.0 → 0.2.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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +45 -0
  3. data/.rubocop.yml +13 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Gemfile +16 -0
  7. data/Gemfile.lock +223 -0
  8. data/LICENSE.txt +21 -0
  9. data/bin/console +15 -0
  10. data/bin/setup +8 -0
  11. data/lib/rails-mermaid_erd_markdown/configuration.rb +14 -13
  12. data/lib/rails-mermaid_erd_markdown/version.rb +1 -1
  13. data/lib/rails-mermaid_erd_markdown.rb +1 -0
  14. data/rails-mermaid_erd_markdown.gemspec +35 -0
  15. data/sig/rails/mermaid_erd_markdown.rbs +6 -0
  16. data/test/dummy-rails/.dockerignore +37 -0
  17. data/test/dummy-rails/.ruby-version +1 -0
  18. data/test/dummy-rails/Rakefile +6 -0
  19. data/test/dummy-rails/app/assets/config/manifest.js +4 -0
  20. data/test/dummy-rails/app/assets/images/.keep +0 -0
  21. data/test/dummy-rails/app/assets/stylesheets/application.css +15 -0
  22. data/test/dummy-rails/app/channels/application_cable/channel.rb +4 -0
  23. data/test/dummy-rails/app/channels/application_cable/connection.rb +4 -0
  24. data/test/dummy-rails/app/controllers/application_controller.rb +2 -0
  25. data/test/dummy-rails/app/controllers/concerns/.keep +0 -0
  26. data/test/dummy-rails/app/helpers/application_helper.rb +2 -0
  27. data/test/dummy-rails/app/javascript/application.js +3 -0
  28. data/test/dummy-rails/app/javascript/controllers/application.js +9 -0
  29. data/test/dummy-rails/app/javascript/controllers/hello_controller.js +7 -0
  30. data/test/dummy-rails/app/javascript/controllers/index.js +11 -0
  31. data/test/dummy-rails/app/jobs/application_job.rb +7 -0
  32. data/test/dummy-rails/app/mailers/application_mailer.rb +4 -0
  33. data/test/dummy-rails/app/models/application_record.rb +3 -0
  34. data/test/dummy-rails/app/models/concerns/.keep +0 -0
  35. data/test/dummy-rails/app/views/layouts/application.html.erb +16 -0
  36. data/test/dummy-rails/app/views/layouts/mailer.html.erb +13 -0
  37. data/test/dummy-rails/app/views/layouts/mailer.text.erb +1 -0
  38. data/test/dummy-rails/bin/bundle +114 -0
  39. data/test/dummy-rails/bin/docker-entrypoint +8 -0
  40. data/test/dummy-rails/bin/importmap +4 -0
  41. data/test/dummy-rails/bin/rails +4 -0
  42. data/test/dummy-rails/bin/rake +4 -0
  43. data/test/dummy-rails/bin/setup +33 -0
  44. data/test/dummy-rails/config/application.rb +27 -0
  45. data/test/dummy-rails/config/boot.rb +3 -0
  46. data/test/dummy-rails/config/cable.yml +10 -0
  47. data/test/dummy-rails/config/credentials.yml.enc +1 -0
  48. data/test/dummy-rails/config/database.yml +25 -0
  49. data/test/dummy-rails/config/environment.rb +5 -0
  50. data/test/dummy-rails/config/environments/development.rb +76 -0
  51. data/test/dummy-rails/config/environments/production.rb +97 -0
  52. data/test/dummy-rails/config/environments/test.rb +64 -0
  53. data/test/dummy-rails/config/importmap.rb +7 -0
  54. data/test/dummy-rails/config/initializers/content_security_policy.rb +25 -0
  55. data/test/dummy-rails/config/initializers/filter_parameter_logging.rb +8 -0
  56. data/test/dummy-rails/config/initializers/inflections.rb +16 -0
  57. data/test/dummy-rails/config/initializers/permissions_policy.rb +13 -0
  58. data/test/dummy-rails/config/locales/en.yml +31 -0
  59. data/test/dummy-rails/config/puma.rb +35 -0
  60. data/test/dummy-rails/config/routes.rb +10 -0
  61. data/test/dummy-rails/config/storage.yml +34 -0
  62. data/test/dummy-rails/config.ru +6 -0
  63. data/test/dummy-rails/db/seeds.rb +9 -0
  64. data/test/dummy-rails/test/application_system_test_case.rb +5 -0
  65. data/test/dummy-rails/test/channels/application_cable/connection_test.rb +13 -0
  66. data/test/dummy-rails/test/controllers/.keep +0 -0
  67. data/test/dummy-rails/test/fixtures/files/.keep +0 -0
  68. data/test/dummy-rails/test/helpers/.keep +0 -0
  69. data/test/dummy-rails/test/integration/.keep +0 -0
  70. data/test/dummy-rails/test/mailers/.keep +0 -0
  71. data/test/dummy-rails/test/models/.keep +0 -0
  72. data/test/dummy-rails/test/system/.keep +0 -0
  73. data/test/dummy-rails/test/test_helper.rb +15 -0
  74. data/test/dummy-rails/vendor/.keep +0 -0
  75. data/test/dummy-rails/vendor/javascript/.keep +0 -0
  76. data/test/test_helper.rb +8 -0
  77. data/test/test_rails/test_rails-mermaid_erd_markdown.rb +49 -0
  78. data/test/util/mock_ERD.md +27 -0
  79. metadata +90 -2
@@ -0,0 +1,31 @@
1
+ # Files in the config/locales directory are used for internationalization and
2
+ # are automatically loaded by Rails. If you want to use locales other than
3
+ # English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t "hello"
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t("hello") %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more about the API, please read the Rails Internationalization guide
20
+ # at https://guides.rubyonrails.org/i18n.html.
21
+ #
22
+ # Be aware that YAML interprets the following case-insensitive strings as
23
+ # booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
24
+ # must be quoted to be interpreted as strings. For example:
25
+ #
26
+ # en:
27
+ # "yes": yup
28
+ # enabled: "ON"
29
+
30
+ en:
31
+ hello: "Hello world"
@@ -0,0 +1,35 @@
1
+ # This configuration file will be evaluated by Puma. The top-level methods that
2
+ # are invoked here are part of Puma's configuration DSL. For more information
3
+ # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
4
+
5
+ # Puma can serve each request in a thread from an internal thread pool.
6
+ # The `threads` method setting takes two numbers: a minimum and maximum.
7
+ # Any libraries that use thread pools should be configured to match
8
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
9
+ # and maximum; this matches the default thread size of Active Record.
10
+ max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
11
+ min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
12
+ threads min_threads_count, max_threads_count
13
+
14
+ # Specifies that the worker count should equal the number of processors in production.
15
+ if ENV["RAILS_ENV"] == "production"
16
+ require "concurrent-ruby"
17
+ worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count })
18
+ workers worker_count if worker_count > 1
19
+ end
20
+
21
+ # Specifies the `worker_timeout` threshold that Puma will use to wait before
22
+ # terminating a worker in development environments.
23
+ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
24
+
25
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
26
+ port ENV.fetch("PORT") { 3000 }
27
+
28
+ # Specifies the `environment` that Puma will run in.
29
+ environment ENV.fetch("RAILS_ENV") { "development" }
30
+
31
+ # Specifies the `pidfile` that Puma will use.
32
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
33
+
34
+ # Allow puma to be restarted by `bin/rails restart` command.
35
+ plugin :tmp_restart
@@ -0,0 +1,10 @@
1
+ Rails.application.routes.draw do
2
+ # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
3
+
4
+ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
5
+ # Can be used by load balancers and uptime monitors to verify that the app is live.
6
+ get "up" => "rails/health#show", as: :rails_health_check
7
+
8
+ # Defines the root path route ("/")
9
+ # root "posts#index"
10
+ end
@@ -0,0 +1,34 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket-<%= Rails.env %>
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket-<%= Rails.env %>
23
+
24
+ # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name-<%= Rails.env %>
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
@@ -0,0 +1,6 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative "config/environment"
4
+
5
+ run Rails.application
6
+ Rails.application.load_server
@@ -0,0 +1,9 @@
1
+ # This file should ensure the existence of records required to run the application in every environment (production,
2
+ # development, test). The code here should be idempotent so that it can be executed at any point in every environment.
3
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
4
+ #
5
+ # Example:
6
+ #
7
+ # ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
8
+ # MovieGenre.find_or_create_by!(name: genre_name)
9
+ # end
@@ -0,0 +1,5 @@
1
+ require "test_helper"
2
+
3
+ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
4
+ driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
5
+ end
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ module ApplicationCable
4
+ class ConnectionTest < ActionCable::Connection::TestCase
5
+ # test "connects with cookies" do
6
+ # cookies.signed[:user_id] = 42
7
+ #
8
+ # connect
9
+ #
10
+ # assert_equal connection.user_id, "42"
11
+ # end
12
+ end
13
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+ require_relative "../config/environment"
3
+ require "rails/test_help"
4
+
5
+ module ActiveSupport
6
+ class TestCase
7
+ # Run tests in parallel with specified workers
8
+ parallelize(workers: :number_of_processors)
9
+
10
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
11
+ fixtures :all
12
+
13
+ # Add more helper methods to be used by all tests here...
14
+ end
15
+ end
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+ require "rails-mermaid_erd_markdown"
5
+ require "rails-mermaid_erd_markdown/configuration"
6
+
7
+ require "minitest/autorun"
8
+ require File.expand_path("./dummy-rails/config/environment", __dir__)
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+ require "rails-mermaid_erd"
5
+
6
+ class MermaidErdMarkdownTest < Minitest::Test
7
+ def test_that_it_has_a_version_number
8
+ refute_nil MermaidErdMarkdown::VERSION
9
+ end
10
+
11
+ def setup
12
+ markdown_file_path = File.expand_path("../../test/util/mock_ERD.md", __dir__)
13
+ mock_erd = File.read(markdown_file_path)
14
+ @mock_erd = mock_erd
15
+ end
16
+
17
+ def test_generate_mermaid_erd
18
+ stubbed_model_data = {
19
+ Models: [
20
+ { TableName: "articles", ModelName: "Article", IsModelExist: true,
21
+ Columns: [
22
+ { name: "id", type: :integer, key: "PK", comment: nil },
23
+ { name: "title", type: :string, key: "", comment: nil },
24
+ { name: "content", type: :text, key: "", comment: nil },
25
+ { name: "created_at", type: :datetime, key: "", comment: nil },
26
+ { name: "updated_at", type: :datetime, key: "", comment: nil }
27
+ ] },
28
+ { TableName: "comments", ModelName: "Comment", IsModelExist: true,
29
+ Columns: [
30
+ { name: "id", type: :integer, key: "PK", comment: nil },
31
+ { name: "commenter", type: :string, key: "", comment: nil },
32
+ { name: "body", type: :text, key: "", comment: nil },
33
+ { name: "article_id", type: :integer, key: "FK", comment: nil },
34
+ { name: "created_at", type: :datetime, key: "", comment: nil },
35
+ { name: "updated_at", type: :datetime, key: "", comment: nil }
36
+ ] }
37
+ ], Relations: [
38
+ { LeftModelName: "Comment", LeftValue: "}o", Line: "--", RightModelName: "Article",
39
+ RightValue: "||", Comment: "BT:article" }
40
+ ]
41
+ }
42
+ result = nil
43
+
44
+ RailsMermaidErd::Builder.stub :model_data, stubbed_model_data do
45
+ result = MermaidErdMarkdown.generate_mermaid_erd
46
+ end
47
+ assert_equal @mock_erd, result
48
+ end
49
+ end
@@ -0,0 +1,27 @@
1
+ ```mermaid
2
+ erDiagram
3
+ %% --------------------------------------------------------
4
+ %% Entity-Relationship Diagram
5
+ %% --------------------------------------------------------
6
+
7
+ %% table name: articles
8
+ Article{
9
+ integer id PK
10
+ string title
11
+ text content
12
+ datetime created_at
13
+ datetime updated_at
14
+ }
15
+
16
+ %% table name: comments
17
+ Comment{
18
+ integer id PK
19
+ string commenter
20
+ text body
21
+ integer article_id FK
22
+ datetime created_at
23
+ datetime updated_at
24
+ }
25
+
26
+ Comment }o--|| Article : "BT:article"
27
+ ```
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-mermaid_erd_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - humzahkiani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-28 00:00:00.000000000 Z
11
+ date: 2024-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails-mermaid_erd
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.2
27
41
  description:
28
42
  email:
29
43
  - 89326566+humzahkiani@users.noreply.github.com
@@ -31,12 +45,86 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
48
+ - ".gitignore"
49
+ - ".rubocop.yml"
50
+ - CHANGELOG.md
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE.txt
34
55
  - README.md
35
56
  - Rakefile
57
+ - bin/console
58
+ - bin/setup
36
59
  - docs/examples/erd.yml
37
60
  - lib/rails-mermaid_erd_markdown.rb
38
61
  - lib/rails-mermaid_erd_markdown/configuration.rb
39
62
  - lib/rails-mermaid_erd_markdown/version.rb
63
+ - rails-mermaid_erd_markdown.gemspec
64
+ - sig/rails/mermaid_erd_markdown.rbs
65
+ - test/dummy-rails/.dockerignore
66
+ - test/dummy-rails/.ruby-version
67
+ - test/dummy-rails/Rakefile
68
+ - test/dummy-rails/app/assets/config/manifest.js
69
+ - test/dummy-rails/app/assets/images/.keep
70
+ - test/dummy-rails/app/assets/stylesheets/application.css
71
+ - test/dummy-rails/app/channels/application_cable/channel.rb
72
+ - test/dummy-rails/app/channels/application_cable/connection.rb
73
+ - test/dummy-rails/app/controllers/application_controller.rb
74
+ - test/dummy-rails/app/controllers/concerns/.keep
75
+ - test/dummy-rails/app/helpers/application_helper.rb
76
+ - test/dummy-rails/app/javascript/application.js
77
+ - test/dummy-rails/app/javascript/controllers/application.js
78
+ - test/dummy-rails/app/javascript/controllers/hello_controller.js
79
+ - test/dummy-rails/app/javascript/controllers/index.js
80
+ - test/dummy-rails/app/jobs/application_job.rb
81
+ - test/dummy-rails/app/mailers/application_mailer.rb
82
+ - test/dummy-rails/app/models/application_record.rb
83
+ - test/dummy-rails/app/models/concerns/.keep
84
+ - test/dummy-rails/app/views/layouts/application.html.erb
85
+ - test/dummy-rails/app/views/layouts/mailer.html.erb
86
+ - test/dummy-rails/app/views/layouts/mailer.text.erb
87
+ - test/dummy-rails/bin/bundle
88
+ - test/dummy-rails/bin/docker-entrypoint
89
+ - test/dummy-rails/bin/importmap
90
+ - test/dummy-rails/bin/rails
91
+ - test/dummy-rails/bin/rake
92
+ - test/dummy-rails/bin/setup
93
+ - test/dummy-rails/config.ru
94
+ - test/dummy-rails/config/application.rb
95
+ - test/dummy-rails/config/boot.rb
96
+ - test/dummy-rails/config/cable.yml
97
+ - test/dummy-rails/config/credentials.yml.enc
98
+ - test/dummy-rails/config/database.yml
99
+ - test/dummy-rails/config/environment.rb
100
+ - test/dummy-rails/config/environments/development.rb
101
+ - test/dummy-rails/config/environments/production.rb
102
+ - test/dummy-rails/config/environments/test.rb
103
+ - test/dummy-rails/config/importmap.rb
104
+ - test/dummy-rails/config/initializers/content_security_policy.rb
105
+ - test/dummy-rails/config/initializers/filter_parameter_logging.rb
106
+ - test/dummy-rails/config/initializers/inflections.rb
107
+ - test/dummy-rails/config/initializers/permissions_policy.rb
108
+ - test/dummy-rails/config/locales/en.yml
109
+ - test/dummy-rails/config/puma.rb
110
+ - test/dummy-rails/config/routes.rb
111
+ - test/dummy-rails/config/storage.yml
112
+ - test/dummy-rails/db/seeds.rb
113
+ - test/dummy-rails/test/application_system_test_case.rb
114
+ - test/dummy-rails/test/channels/application_cable/connection_test.rb
115
+ - test/dummy-rails/test/controllers/.keep
116
+ - test/dummy-rails/test/fixtures/files/.keep
117
+ - test/dummy-rails/test/helpers/.keep
118
+ - test/dummy-rails/test/integration/.keep
119
+ - test/dummy-rails/test/mailers/.keep
120
+ - test/dummy-rails/test/models/.keep
121
+ - test/dummy-rails/test/system/.keep
122
+ - test/dummy-rails/test/test_helper.rb
123
+ - test/dummy-rails/vendor/.keep
124
+ - test/dummy-rails/vendor/javascript/.keep
125
+ - test/test_helper.rb
126
+ - test/test_rails/test_rails-mermaid_erd_markdown.rb
127
+ - test/util/mock_ERD.md
40
128
  homepage: https://github.com/humzahkiani/rails-mermaid_erd_markdown
41
129
  licenses:
42
130
  - MIT