diff --git a/Gemfile b/Gemfile index 5e84b5cb31..01d2252f5d 100644 --- a/Gemfile +++ b/Gemfile @@ -169,6 +169,7 @@ end group :development do gem 'debugger-linecache' + gem 'rails-erd' gem 'foreman' gem 'listen' gem 'pry', '~> 0.13.0' diff --git a/Gemfile.lock b/Gemfile.lock index 9e1322f15d..ee8528624c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/doc/erd.pdf b/doc/erd.pdf new file mode 100644 index 0000000000..4b4299cc51 Binary files /dev/null and b/doc/erd.pdf differ diff --git a/script/erd b/script/erd new file mode 100755 index 0000000000..ded7311b3f --- /dev/null +++ b/script/erd @@ -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" diff --git a/script/install-bundler b/script/install-bundler index a5c994c311..f018f7c734 100755 --- a/script/install-bundler +++ b/script/install-bundler @@ -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