From 954cff4ea2309e4d10a872f8f345195afdc19941 Mon Sep 17 00:00:00 2001 From: Dlani Mendes Date: Thu, 28 Nov 2024 00:23:49 -0500 Subject: [PATCH] Support to ignore tables in config file --- lib/rails-mermaid_erd/builder.rb | 1 + lib/rails-mermaid_erd/configuration.rb | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/rails-mermaid_erd/builder.rb b/lib/rails-mermaid_erd/builder.rb index 918c519..13fc502 100644 --- a/lib/rails-mermaid_erd/builder.rb +++ b/lib/rails-mermaid_erd/builder.rb @@ -13,6 +13,7 @@ def model_data next unless defined_model.table_exists? next if defined_model.name.include?("HABTM_") next if defined_model.table_name.blank? + next if RailsMermaidErd.configuration.ignore.select { |i| Regexp.new(i).match(defined_model.table_name) }.present? table_name = defined_model.table_name model = { diff --git a/lib/rails-mermaid_erd/configuration.rb b/lib/rails-mermaid_erd/configuration.rb index 74fd25b..b4afac2 100644 --- a/lib/rails-mermaid_erd/configuration.rb +++ b/lib/rails-mermaid_erd/configuration.rb @@ -1,11 +1,12 @@ require "yaml" class RailsMermaidErd::Configuration - attr_accessor :result_path + attr_accessor :result_path, :ignore def initialize config = { - result_path: "mermaid_erd/index.html" + result_path: "mermaid_erd/index.html", + ignore: [] } config_file = Rails.root.join("config/mermaid_erd.yml") @@ -15,5 +16,6 @@ def initialize end @result_path = config[:result_path] + @ignore = config[:ignore] end end