rails-erd 1.7.1 → 1.7.2
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 +4 -4
- data/README.md +2 -2
- data/lib/rails_erd/cli.rb +1 -1
- data/lib/rails_erd/domain/attribute.rb +2 -2
- data/lib/rails_erd/domain.rb +26 -1
- data/lib/rails_erd/version.rb +1 -1
- data/test/unit/domain_test.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b58372ac1652af1b21bd00ea88b434bb2d303247eca241f57efd84210bc9367
|
4
|
+
data.tar.gz: aecdcd4cfdb25ed3ef1713da019b456512d2b7bc965ebe0d7acea86e56b4f586
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
[](https://github.com/voormedia/rails-erd/actions/workflows/test.yml) [](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
|
-
-
|
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
|
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.
|
data/lib/rails_erd/domain.rb
CHANGED
@@ -120,7 +120,32 @@ module RailsERD
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def models
|
123
|
-
@models ||= @source_models
|
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
|
data/lib/rails_erd/version.rb
CHANGED
data/test/unit/domain_test.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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.
|