rails-mermaid_erd_markdown 0.3.0 → 0.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67e66530c607079c622c67375de2af66f2e7622c10049a8972ee54daceced528
4
- data.tar.gz: 79d8cde31fdd334cc53bb43e8bc86088d1525561cd8c05ad523dfd36b287a57c
3
+ metadata.gz: 1fc2645eeda1d07ce73a989297a6de24e9a28e8dd2a812bf94dca1eb7d9d0dd8
4
+ data.tar.gz: 20534d950c4ab8109286bd708e133516ce4a4e3ce0e7ba8991a664e23e2c0222
5
5
  SHA512:
6
- metadata.gz: fb3657a451d92dc2520057b37c5fe75486ec1f6ecbfde168ae498e4b1213b40acca495cff3307aa704e99940b35069b1d9e61af8dd5d4b73dc92a489a4fb0c1d
7
- data.tar.gz: 58fd1f844c7b8c16645bcdd48f7532d9175e1d53b0ad90ddef9a05021cdd2fa7e00968140d9bace215b4545f8917226b2f788adb15b6ece53c58857896cf1b10
6
+ metadata.gz: 4f99bb71981c90be8d6f0c6ad6725133b8e39b2e48664e4bd0dfae24314a24b9dee3045b939e33f5101ce4fd607fb5d5e3768ecd0e85a9e5f8b745bb87ccc248
7
+ data.tar.gz: 6980b1b01319af831bfc2798949fae4b85d6dc152e73dcd9469e704a6805711c1ae98cbcea066ea4fb062c153d8d57d2f5580aeea27b2039771656d488563a93
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
3
  ## [0.1.0] - 2024-05-27
4
-
5
4
  - Initial release
5
+ - Create ERD mermaid markdown of all ActiveRecord models
6
+
7
+ ## [0.2.0] - 2024-05-28
8
+ - Fix issues with package
9
+ - Update gemspec
10
+
11
+ ## [0.3.0] - 2024-07-31
12
+ - Fix minor issues
13
+ - Add ability to optionally split into multiple ERDs
14
+ - Refactor classes to separate concerns
15
+
16
+ ## [0.3.1] - 2024-08-10
17
+ - Update docs
18
+ - Change rails-mermaid_erd version dependency to at least 0.4.2
data/Gemfile.lock CHANGED
@@ -1,92 +1,88 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-mermaid_erd_markdown (0.3.0)
4
+ rails-mermaid_erd_markdown (0.3.1)
5
5
  rails (>= 5.2)
6
- rails-mermaid_erd (~> 0.4.2)
6
+ rails-mermaid_erd (>= 0.4.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (7.1.3.4)
12
- actionpack (= 7.1.3.4)
13
- activesupport (= 7.1.3.4)
11
+ actioncable (7.2.0)
12
+ actionpack (= 7.2.0)
13
+ activesupport (= 7.2.0)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
16
  zeitwerk (~> 2.6)
17
- actionmailbox (7.1.3.4)
18
- actionpack (= 7.1.3.4)
19
- activejob (= 7.1.3.4)
20
- activerecord (= 7.1.3.4)
21
- activestorage (= 7.1.3.4)
22
- activesupport (= 7.1.3.4)
23
- mail (>= 2.7.1)
24
- net-imap
25
- net-pop
26
- net-smtp
27
- actionmailer (7.1.3.4)
28
- actionpack (= 7.1.3.4)
29
- actionview (= 7.1.3.4)
30
- activejob (= 7.1.3.4)
31
- activesupport (= 7.1.3.4)
32
- mail (~> 2.5, >= 2.5.4)
33
- net-imap
34
- net-pop
35
- net-smtp
17
+ actionmailbox (7.2.0)
18
+ actionpack (= 7.2.0)
19
+ activejob (= 7.2.0)
20
+ activerecord (= 7.2.0)
21
+ activestorage (= 7.2.0)
22
+ activesupport (= 7.2.0)
23
+ mail (>= 2.8.0)
24
+ actionmailer (7.2.0)
25
+ actionpack (= 7.2.0)
26
+ actionview (= 7.2.0)
27
+ activejob (= 7.2.0)
28
+ activesupport (= 7.2.0)
29
+ mail (>= 2.8.0)
36
30
  rails-dom-testing (~> 2.2)
37
- actionpack (7.1.3.4)
38
- actionview (= 7.1.3.4)
39
- activesupport (= 7.1.3.4)
31
+ actionpack (7.2.0)
32
+ actionview (= 7.2.0)
33
+ activesupport (= 7.2.0)
40
34
  nokogiri (>= 1.8.5)
41
35
  racc
42
- rack (>= 2.2.4)
36
+ rack (>= 2.2.4, < 3.2)
43
37
  rack-session (>= 1.0.1)
44
38
  rack-test (>= 0.6.3)
45
39
  rails-dom-testing (~> 2.2)
46
40
  rails-html-sanitizer (~> 1.6)
47
- actiontext (7.1.3.4)
48
- actionpack (= 7.1.3.4)
49
- activerecord (= 7.1.3.4)
50
- activestorage (= 7.1.3.4)
51
- activesupport (= 7.1.3.4)
41
+ useragent (~> 0.16)
42
+ actiontext (7.2.0)
43
+ actionpack (= 7.2.0)
44
+ activerecord (= 7.2.0)
45
+ activestorage (= 7.2.0)
46
+ activesupport (= 7.2.0)
52
47
  globalid (>= 0.6.0)
53
48
  nokogiri (>= 1.8.5)
54
- actionview (7.1.3.4)
55
- activesupport (= 7.1.3.4)
49
+ actionview (7.2.0)
50
+ activesupport (= 7.2.0)
56
51
  builder (~> 3.1)
57
52
  erubi (~> 1.11)
58
53
  rails-dom-testing (~> 2.2)
59
54
  rails-html-sanitizer (~> 1.6)
60
- activejob (7.1.3.4)
61
- activesupport (= 7.1.3.4)
55
+ activejob (7.2.0)
56
+ activesupport (= 7.2.0)
62
57
  globalid (>= 0.3.6)
63
- activemodel (7.1.3.4)
64
- activesupport (= 7.1.3.4)
65
- activerecord (7.1.3.4)
66
- activemodel (= 7.1.3.4)
67
- activesupport (= 7.1.3.4)
58
+ activemodel (7.2.0)
59
+ activesupport (= 7.2.0)
60
+ activerecord (7.2.0)
61
+ activemodel (= 7.2.0)
62
+ activesupport (= 7.2.0)
68
63
  timeout (>= 0.4.0)
69
- activestorage (7.1.3.4)
70
- actionpack (= 7.1.3.4)
71
- activejob (= 7.1.3.4)
72
- activerecord (= 7.1.3.4)
73
- activesupport (= 7.1.3.4)
64
+ activestorage (7.2.0)
65
+ actionpack (= 7.2.0)
66
+ activejob (= 7.2.0)
67
+ activerecord (= 7.2.0)
68
+ activesupport (= 7.2.0)
74
69
  marcel (~> 1.0)
75
- activesupport (7.1.3.4)
70
+ activesupport (7.2.0)
76
71
  base64
77
72
  bigdecimal
78
- concurrent-ruby (~> 1.0, >= 1.0.2)
73
+ concurrent-ruby (~> 1.0, >= 1.3.1)
79
74
  connection_pool (>= 2.2.5)
80
75
  drb
81
76
  i18n (>= 1.6, < 2)
77
+ logger (>= 1.4.2)
82
78
  minitest (>= 5.1)
83
- mutex_m
84
- tzinfo (~> 2.0)
79
+ securerandom (>= 0.3)
80
+ tzinfo (~> 2.0, >= 2.0.5)
85
81
  ast (2.4.2)
86
82
  base64 (0.2.0)
87
83
  bigdecimal (3.1.8)
88
84
  builder (3.3.0)
89
- concurrent-ruby (1.3.3)
85
+ concurrent-ruby (1.3.4)
90
86
  connection_pool (2.4.1)
91
87
  crass (1.0.6)
92
88
  date (3.3.4)
@@ -102,6 +98,7 @@ GEM
102
98
  reline (>= 0.4.2)
103
99
  json (2.7.2)
104
100
  language_server-protocol (3.17.0.3)
101
+ logger (1.6.0)
105
102
  loofah (2.22.0)
106
103
  crass (~> 1.0.2)
107
104
  nokogiri (>= 1.12.0)
@@ -112,8 +109,7 @@ GEM
112
109
  net-smtp
113
110
  marcel (1.0.4)
114
111
  mini_mime (1.1.5)
115
- minitest (5.23.1)
116
- mutex_m (0.2.0)
112
+ minitest (5.24.1)
117
113
  net-imap (0.4.14)
118
114
  date
119
115
  net-protocol
@@ -126,17 +122,13 @@ GEM
126
122
  nio4r (2.7.3)
127
123
  nokogiri (1.16.7-arm64-darwin)
128
124
  racc (~> 1.4)
129
- nokogiri (1.16.7-x86_64-darwin)
130
- racc (~> 1.4)
131
- nokogiri (1.16.7-x86_64-linux)
132
- racc (~> 1.4)
133
125
  parallel (1.24.0)
134
126
  parser (3.3.1.0)
135
127
  ast (~> 2.4.1)
136
128
  racc
137
129
  psych (5.1.2)
138
130
  stringio
139
- racc (1.8.0)
131
+ racc (1.8.1)
140
132
  rack (3.1.7)
141
133
  rack-session (2.0.0)
142
134
  rack (>= 3.0.0)
@@ -145,20 +137,20 @@ GEM
145
137
  rackup (2.1.0)
146
138
  rack (>= 3)
147
139
  webrick (~> 1.8)
148
- rails (7.1.3.4)
149
- actioncable (= 7.1.3.4)
150
- actionmailbox (= 7.1.3.4)
151
- actionmailer (= 7.1.3.4)
152
- actionpack (= 7.1.3.4)
153
- actiontext (= 7.1.3.4)
154
- actionview (= 7.1.3.4)
155
- activejob (= 7.1.3.4)
156
- activemodel (= 7.1.3.4)
157
- activerecord (= 7.1.3.4)
158
- activestorage (= 7.1.3.4)
159
- activesupport (= 7.1.3.4)
140
+ rails (7.2.0)
141
+ actioncable (= 7.2.0)
142
+ actionmailbox (= 7.2.0)
143
+ actionmailer (= 7.2.0)
144
+ actionpack (= 7.2.0)
145
+ actiontext (= 7.2.0)
146
+ actionview (= 7.2.0)
147
+ activejob (= 7.2.0)
148
+ activemodel (= 7.2.0)
149
+ activerecord (= 7.2.0)
150
+ activestorage (= 7.2.0)
151
+ activesupport (= 7.2.0)
160
152
  bundler (>= 1.15.0)
161
- railties (= 7.1.3.4)
153
+ railties (= 7.2.0)
162
154
  rails-dom-testing (2.2.0)
163
155
  activesupport (>= 5.0.0)
164
156
  minitest
@@ -166,12 +158,12 @@ GEM
166
158
  rails-html-sanitizer (1.6.0)
167
159
  loofah (~> 2.21)
168
160
  nokogiri (~> 1.14)
169
- rails-mermaid_erd (0.4.2)
161
+ rails-mermaid_erd (0.5.0)
170
162
  rails (>= 5.2)
171
- railties (7.1.3.4)
172
- actionpack (= 7.1.3.4)
173
- activesupport (= 7.1.3.4)
174
- irb
163
+ railties (7.2.0)
164
+ actionpack (= 7.2.0)
165
+ activesupport (= 7.2.0)
166
+ irb (~> 1.13)
175
167
  rackup (>= 1.0.0)
176
168
  rake (>= 12.2)
177
169
  thor (~> 1.0, >= 1.2.2)
@@ -199,6 +191,7 @@ GEM
199
191
  rubocop-ast (1.31.3)
200
192
  parser (>= 3.3.1.0)
201
193
  ruby-progressbar (1.13.0)
194
+ securerandom (0.3.1)
202
195
  sqlite3 (1.7.3-arm64-darwin)
203
196
  sqlite3 (1.7.3-x86_64-darwin)
204
197
  sqlite3 (1.7.3-x86_64-linux)
@@ -209,6 +202,7 @@ GEM
209
202
  tzinfo (2.0.6)
210
203
  concurrent-ruby (~> 1.0)
211
204
  unicode-display_width (2.5.0)
205
+ useragent (0.16.10)
212
206
  webrick (1.8.1)
213
207
  websocket-driver (0.7.6)
214
208
  websocket-extensions (>= 0.1.0)
data/README.md CHANGED
@@ -1,36 +1,6 @@
1
1
  # rails-mermaid_erd_markdown
2
2
 
3
- This is a rails gem that extends the rails-mermaid_erd gem to generate a mermaid ERD for Rails Models in markdown directly in source code. This avoids the need to download the ERD through a html page, which can be difficult for scenarios where one would like to programmatically generate an ERD.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'rails-mermaid_erd_markdown'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle install
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install rails-mermaid_erd_markdown
20
-
21
- ## Usage
22
-
23
- To generate a mermaid ERD in markdown, run `rails generate_erd` or `rake generate_erd` from the terminal
24
-
25
- The default path for the generated ERD is `app/models/ERD.md`. You can modify this by creating an `erd.yml` file in the root directory and modifying the `output_path` as seen in the example at `docs/examples/erd.yml`. Make sure to include the markdown file name you wish to generate in the path.
26
-
27
- If an ERD already exists at the path specified, it will be parsed to determine if it is up to date. If it is, nothing happens. If it is not up to date, the ERD will be updated.
28
-
29
- One can create self-updating, living documentation by integrating this rake task into their CI. This ensures that the ERD is always up to date and accurately describes the latest state of the models and their relationships.
30
-
31
- You can view the ERD by navigating to the file in Github, which supports rendering mermaid diagrams from code. If you are a Visual Studio Code user, you can use the [Markdown Preview Enhanced](https://marketplace.visualstudio.com/items?itemName=shd101wyy.markdown-preview-enhanced) extension to view the ERD directly in your IDE.
32
-
33
- If your entity diagram is too large to be displayed you can set a `split_output` configuration to `true` to generate multiple ERD files based on each model in your project. You can also set a `relationship_depth` configuration to include more than 1 level (the default) of associations in each document.
3
+ A Ruby on Rails gem that extends rails-mermaid_erd to generate mermaid Entity-Relationship Diagrams (ERD) for ActiveRecord Models. When combined with Continuous Integration (CI) pipelines, it enables one to generate living, self-updating documentation of their data.
34
4
 
35
5
  ## Example ERD
36
6
 
@@ -62,6 +32,103 @@ erDiagram
62
32
  Comment }o--|| Article : "BT:article"
63
33
  ```
64
34
 
35
+
36
+ ## Installation
37
+
38
+ Add this line to your application's Gemfile:
39
+
40
+ ```ruby
41
+ gem 'rails-mermaid_erd_markdown'
42
+ ```
43
+
44
+ Or install it yourself as:
45
+
46
+ $ gem install rails-mermaid_erd_markdown
47
+
48
+ ## Usage
49
+
50
+ ### Generating ERDs
51
+ To generate the comprehensive mermaid ERD in markdown, run one of the following:
52
+ ```
53
+ rails generate_erd
54
+ ```
55
+ OR
56
+ ```
57
+ rake generate_erd
58
+ ```
59
+ **If all of your models do not appear, be sure to eager load them first.**
60
+
61
+ ### Configuration
62
+ You can configure the ERD generation by creating a `erd.yml` file in your root, and modifying the following fields.
63
+
64
+ ```
65
+ # erd.yml
66
+ erd:
67
+ output_path: 'app/ERD.md' # Set output path of ERDs, default: 'app/ERD.md'
68
+ split_output: false, # Generates individual ERDs for each model with a specified depth, default: false
69
+ relationship_depth: 1 # Configured depth of individual ERD model generation, default: 1
70
+
71
+ ```
72
+
73
+ If your entity diagram is too large to be displayed you can set a `split_output` configuration to `true` to generate multiple ERD files based on each model in your project.
74
+
75
+ You can also set a `relationship_depth` configuration to include more than 1 level (the default) of associations in each document.
76
+
77
+
78
+ ### Viewing Diagrams
79
+
80
+ You can view the ERD by navigating to the file in Github, which supports rendering mermaid diagrams from code. If you are a Visual Studio Code user, you can use any markdown preview extension such as [Markdown Preview Enhanced](https://marketplace.visualstudio.com/items?itemName=shd101wyy.markdown-preview-enhanced) view the ERD directly in your IDE.
81
+
82
+
83
+ ### Integration with CI Pipeline
84
+ The most value of this gem comes with the integration of it's diagram generation into your CI. The amount of effort required to update documentation has always been the greatest deterrant to creating new documentation. By integrating this rake task into your CI, you can have the CI update the model for you anytime that it changes.
85
+
86
+ The following is a Github Actions job example for how one might do this for a Rails app that uses PostgreSQL:
87
+
88
+ ```yml
89
+ permissions:
90
+ contents: write
91
+ packages: read
92
+
93
+ jobs:
94
+ update-erd:
95
+ runs-on: ubuntu-latest
96
+ services:
97
+ postgres:
98
+ image: postgres
99
+ env:
100
+ POSTGRES_USER: postgres
101
+ POSTGRES_PASSWORD: postgres
102
+ ports:
103
+ - 5432:5432
104
+ options:
105
+ - --health-cmd="pg_is_ready" --health-interval=10s --health-timeout=5s --health-retries=3
106
+ steps:
107
+ - name: Install packages
108
+ run:
109
+ sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libvips postgresql-client libpq-dev
110
+ - name: Checkout code
111
+ uses: actions/checkout@v4
112
+ with:
113
+ ref: ${{ github.event.pull_request.head.ref }}
114
+ - name: Setup database
115
+ env:
116
+ RAILS_ENV: test
117
+ DATABASE_URL: postgres://postgres:postgres@localhost:5432
118
+ run: bin/rails db:setup
119
+ - name: Setup database
120
+ env:
121
+ RAILS_ENV: test
122
+ DATABASE_URL: postgres://postgres:postgres@localhost:5432
123
+ run: bin/rails generate_erd
124
+ - name: Commit and Push Updated ERD
125
+ run: |
126
+ git config --global user.name 'Github Actions Bot'
127
+ git config --global user.email 'actions/@users.noreply.github.com'
128
+ git add app/models/ERD.md
129
+ git commit -m "Update ERD" || echo "No changes to commit"
130
+ ```
131
+
65
132
  ## Development
66
133
 
67
134
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,4 +1,4 @@
1
- # This is the path and filename of the generated ERD. You can modify it to change where the ERD is stored/updated.
2
- # Default output path: 'app/models/ERD.md'
3
1
  erd:
4
- output_path: 'app/ERD.md'
2
+ output_path: 'app/ERD.md' # Set output path of ERDs, default: 'app/ERD.md'
3
+ split_output: false, # Generates individual ERDs for each model with a specified depth, default: false
4
+ relationship_depth: 1 # Configured depth of individual ERD model generation, default: 1
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MermaidErdMarkdown
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["humzahkiani"]
9
9
  spec.email = ["89326566+humzahkiani@users.noreply.github.com"]
10
10
 
11
- spec.summary = "This is a rails gem that extends the rails-mermaid_erd gem to generate a mermaid ERD for Rails " \
12
- "Models in markdown directly in source code."
11
+ spec.summary = "Extends the rails-mermaid_erd gem to generate mermaid ERDs in markdown " \
12
+ "for Ruby on Rails ActiveRecord Models"
13
13
  spec.homepage = "https://github.com/humzahkiani/rails-mermaid_erd_markdown"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 2.6.0"
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  # Runtime Dependencies
31
31
  spec.add_dependency "rails", ">= 5.2"
32
- spec.add_dependency "rails-mermaid_erd", "~> 0.4.2"
32
+ spec.add_dependency "rails-mermaid_erd", ">= 0.4.2"
33
33
 
34
34
  # For more information and examples about making a new gem, check out our
35
35
  # guide at: https://bundler.io/guides/creating_gem.html
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.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - humzahkiani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-31 00:00:00.000000000 Z
11
+ date: 2024-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: rails-mermaid_erd
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.4.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.4.2
41
41
  description:
@@ -106,6 +106,6 @@ requirements: []
106
106
  rubygems_version: 3.3.3
107
107
  signing_key:
108
108
  specification_version: 4
109
- summary: This is a rails gem that extends the rails-mermaid_erd gem to generate a
110
- mermaid ERD for Rails Models in markdown directly in source code.
109
+ summary: Extends the rails-mermaid_erd gem to generate mermaid ERDs in markdown for
110
+ Ruby on Rails ActiveRecord Models
111
111
  test_files: []