Merge pull request #9670 from dacook/generate-erd

Script to generate ERD
This commit is contained in:
jibees
2022-09-26 10:33:06 +02:00
committed by GitHub
5 changed files with 20 additions and 2 deletions

View File

@@ -169,6 +169,7 @@ end
group :development do
gem 'debugger-linecache'
gem 'rails-erd'
gem 'foreman'
gem 'listen'
gem 'pry', '~> 0.13.0'

View File

@@ -203,6 +203,7 @@ GEM
marcel (~> 1.0)
nokogiri (~> 1.10, >= 1.10.4)
rubyzip (>= 1.3.0, < 3)
choice (0.2.0)
chronic (0.10.2)
cliver (0.3.2)
coderay (1.1.3)
@@ -471,6 +472,11 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-erd (1.7.2)
activerecord (>= 4.2)
activesupport (>= 4.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
rails-i18n (7.0.5)
@@ -564,6 +570,8 @@ GEM
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
ruby-graphviz (1.2.5)
rexml
ruby-progressbar (1.11.0)
ruby-rc4 (0.1.5)
ruby-vips (2.1.4)
@@ -765,6 +773,7 @@ DEPENDENCIES
rack-timeout
rails (>= 6.1.4)
rails-controller-testing
rails-erd
rails-i18n
rails_safe_tasks (~> 1.0)
ransack (= 2.4.2)

BIN
doc/erd.pdf Normal file

Binary file not shown.

8
script/erd Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
# * [Pre-requisites](https://voormedia.github.io/rails-erd/install.html).
# * [Usage](https://voormedia.github.io/rails-erd/customise.html)
TITLE="Openfoodnetwork domain model - generated `date +%Y-%m-%d`"
rake erd title="$TITLE" filename="doc/erd"

View File

@@ -14,12 +14,12 @@
# Fail if a single command fails.
set -e
# `grep -m 1`: find the first occurrence of "BUNDLED WITH"
# `grep`: find the occurrences of "BUNDLED WITH" (-m is unnecessary and behaves different on macOS)
# `-A`: print the next line after "BUNDLED WITH" as well
# `-x -F`: find exactly that string without interpreting regex
# `tail -n 1`: take the last line, the version line
# `tr -d`: delete all spaces, the indent before the version
version="$(grep -m 1 -A 1 -x -F "BUNDLED WITH" Gemfile.lock | tail -n 1 | tr -d '[:space:]')"
version="$(grep -A 1 -x -F "BUNDLED WITH" Gemfile.lock | tail -n 1 | tr -d '[:space:]')"
# if the length of $version is zero
if [ -z "$version" ]; then