rails-erd 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9aa7b34b79755fba7b09da0d9bd34d02496df7813c2a31c58b6b93c5d5575f25
4
- data.tar.gz: c85abffb05d82382d8e32593176f4f377d1e9116128caa29b91a8c621bb67620
3
+ metadata.gz: 8b58372ac1652af1b21bd00ea88b434bb2d303247eca241f57efd84210bc9367
4
+ data.tar.gz: aecdcd4cfdb25ed3ef1713da019b456512d2b7bc965ebe0d7acea86e56b4f586
5
5
  SHA512:
6
- metadata.gz: 2f16c8591f2997b9e4fa59d1c10a4e677a5f7c4588e5ee04605e7a517b64278caf391778dcd2f3b56aa38d33055e4deaa9a09aad9ebf9571ab809ede2efed47d
7
- data.tar.gz: 700a4ada1bdcae0b32d173f9d0e8b70e24f5cabc5c747d6a3580c1c8cf00d403261239b5fbdc544eb0c1b55b510aad407964854beb6ef4a384114a17c235d28a
6
+ metadata.gz: 1d8c7c596bf41d7753c0c34a468c142021ed66e7b7168dab70f68e57cf587640b5d5c35693b14c4a4c7778cf55b30f5740393454773901720f29c71f16e91c73
7
+ data.tar.gz: 733fe6e3c637a1f31f750621af09b9803102663b8d5cb611f978c600bc0940856e491a853325f57b4c126cf6e1ec50d55a4d0425ed573f1b722f144333ff4cf9
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  Rails ERD - Generate Entity-Relationship Diagrams for Rails applications
2
2
  ========================================================================
3
- [![Build Status](https://travis-ci.org/voormedia/rails-erd.svg?branch=master)](https://travis-ci.org/voormedia/rails-erd) [![Code Climate](https://codeclimate.com/github/voormedia/rails-erd/badges/gpa.svg)](https://codeclimate.com/github/voormedia/rails-erd)
3
+ [![Tests](https://github.com/voormedia/rails-erd/actions/workflows/test.yml/badge.svg)](https://github.com/voormedia/rails-erd/actions/workflows/test.yml) [![Code Climate](https://codeclimate.com/github/voormedia/rails-erd/badges/gpa.svg)](https://codeclimate.com/github/voormedia/rails-erd)
4
4
 
5
5
  [Rails ERD](https://voormedia.github.io/rails-erd/) is a gem that allows you to easily generate a diagram based on your application's Active Record models. The diagram gives an overview of how your models are related. Having a diagram that describes your models is perfect documentation for your application.
6
6
 
@@ -46,7 +46,7 @@ Rails ERD has the ability to be configured via the command line or through the u
46
46
  ```yaml
47
47
  attributes:
48
48
  - content
49
- - foreign_key
49
+ - foreign_keys
50
50
  - inheritance
51
51
  disconnected: true
52
52
  filename: erd
data/lib/rails_erd/cli.rb CHANGED
@@ -184,7 +184,7 @@ module RailsERD
184
184
  rescue ::LoadError
185
185
  error_message = <<~EOS
186
186
  Tried to load your application environment from '#{environment_path}' but the file was not present.
187
- This means that your models might not get loaded fully when the diagram gets buiilt. This can
187
+ This means that your models might not get loaded fully when the diagram gets built. This can
188
188
  make your entity diagram incomplete.
189
189
 
190
190
  However, if you are using ActiveRecord without Rails just make sure your models get
@@ -78,8 +78,8 @@ module RailsERD
78
78
  # relationship.
79
79
  def foreign_key?
80
80
  @domain.relationships_by_entity_name(@model.name).map(&:associations).flatten.map { |associaton|
81
- associaton.send(Domain.foreign_key_method_name)
82
- }.include?(name)
81
+ associaton.send(Domain.foreign_key_method_name).to_sym
82
+ }.include?(name.to_sym)
83
83
  end
84
84
 
85
85
  # Returns +true+ if this attribute is used for single table inheritance.
@@ -120,7 +120,32 @@ module RailsERD
120
120
  end
121
121
 
122
122
  def models
123
- @models ||= @source_models.select { |model| check_model_validity(model) }.reject { |model| check_habtm_model(model) }
123
+ @models ||= @source_models
124
+ .reject { |model| tableless_rails_models.include?(model) }
125
+ .select { |model| check_model_validity(model) }
126
+ .reject { |model| check_habtm_model(model) }
127
+ end
128
+
129
+ # Returns Rails model classes defined in the app
130
+ def rails_models
131
+ %w(
132
+ ActionMailbox::InboundEmail
133
+ ActiveStorage::Attachment
134
+ ActiveStorage::Blob
135
+ ActiveStorage::VariantRecord
136
+ ActionText::RichText
137
+ ActionText::EncryptedRichText
138
+ ).map{ |model| Object.const_get(model) rescue nil }.compact
139
+ end
140
+
141
+ def tableless_rails_models
142
+ @tableless_rails_models ||= begin
143
+ if defined? Rails
144
+ rails_models.reject{ |model| model.table_exists? }
145
+ else
146
+ []
147
+ end
148
+ end
124
149
  end
125
150
 
126
151
  def associations
@@ -1,4 +1,4 @@
1
1
  module RailsERD
2
- VERSION = "1.7.1"
2
+ VERSION = "1.7.2"
3
3
  BANNER = "RailsERD #{VERSION}"
4
4
  end
@@ -283,4 +283,14 @@ class DomainTest < ActiveSupport::TestCase
283
283
  end
284
284
  assert_match(/Ignoring invalid model Foo \(table foos does not exist\)/, output)
285
285
  end
286
+
287
+ test "entities should not output a warning when a Rails model table does not exist" do
288
+ module ActionMailbox; end
289
+
290
+ Object.const_set :InboundEmail, ActionMailbox
291
+ output = collect_stdout do
292
+ Domain.generate.entities
293
+ end
294
+ assert_equal "", output
295
+ end
286
296
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-erd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rolf Timmermans
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-12 00:00:00.000000000 Z
12
+ date: 2022-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  requirements: []
165
- rubygems_version: 3.2.22
165
+ rubygems_version: 3.3.15
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: Entity-relationship diagram for your Rails models.