rails-erd 1.5.0 → 1.5.1
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 +15 -9
- data/lib/generators/erd/templates/auto_generate_diagram.rake +1 -1
- data/lib/rails_erd.rb +10 -0
- data/lib/rails_erd/cli.rb +9 -1
- data/lib/rails_erd/diagram.rb +5 -6
- data/lib/rails_erd/diagram/graphviz.rb +5 -1
- data/lib/rails_erd/diagram/templates/node.html.erb +2 -2
- data/lib/rails_erd/diagram/templates/node.record.erb +2 -2
- data/lib/rails_erd/domain/entity.rb +1 -1
- data/lib/rails_erd/tasks.rake +15 -1
- data/lib/rails_erd/version.rb +1 -1
- data/test/test_helper.rb +56 -2
- data/test/unit/attribute_test.rb +8 -8
- data/test/unit/domain_test.rb +4 -4
- data/test/unit/entity_test.rb +26 -0
- data/test/unit/graphviz_test.rb +22 -12
- data/test/unit/rake_task_test.rb +3 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 908b423dba1519fc2769f64ec4d9cb80ec81e9e2
|
4
|
+
data.tar.gz: c360f615b7ab66d757aaadfa79cef2877a756008
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b0195f4c8f8c9119bfeb00a8fd6ae929d4ac1023509f06bccd20316aaba51a907d080ea2f720866231168252092f139b727d705452029739a0548bef2bb1d09
|
7
|
+
data.tar.gz: 6c64ed31acdda5d1b3983641f4c02f5d434ab562930e8905a1ca5e5a4d8ade1aa0721f1e50de06cbd1e2161e099e08e87a0710ba2e71c7e9f51d97f6c3b36c57
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@ Rails ERD - Generate Entity-Relationship Diagrams for Rails applications
|
|
2
2
|
========================================================================
|
3
3
|
[](https://travis-ci.org/voormedia/rails-erd) [](https://codeclimate.com/github/voormedia/rails-erd)
|
4
4
|
|
5
|
-
[Rails ERD](
|
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
|
|
7
7
|
The second goal of Rails ERD is to provide you with a tool to inspect your application's domain model. If you don't like the default output, it is very easy to use the API to build your own diagrams.
|
8
8
|
|
@@ -14,23 +14,23 @@ Preview
|
|
14
14
|
|
15
15
|
Here's an example entity-relationship diagram that was generated by Rails ERD:
|
16
16
|
|
17
|
-

|
18
18
|
|
19
|
-
Browse the [gallery](
|
19
|
+
Browse the [gallery](https://voormedia.github.io/rails-erd/gallery.html) for more example diagrams.
|
20
20
|
|
21
21
|
|
22
22
|
Requirements
|
23
23
|
---------------
|
24
24
|
|
25
25
|
* Ruby 1.9.3+
|
26
|
-
* ActiveRecord 3.x
|
26
|
+
* ActiveRecord 3.x - 5.0.x
|
27
27
|
|
28
28
|
Getting started
|
29
29
|
---------------
|
30
30
|
|
31
|
-
See the [installation instructions](
|
31
|
+
See the [installation instructions](https://voormedia.github.io/rails-erd/install.html) for a complete description of how to install Rails ERD. Here's a summary:
|
32
32
|
|
33
|
-
* Install Graphviz 2.22+ ([how?](
|
33
|
+
* Install Graphviz 2.22+ ([how?](https://voormedia.github.io/rails-erd/install.html))
|
34
34
|
|
35
35
|
* Add <tt>gem "rails-erd"</tt> to your application's Gemfile
|
36
36
|
|
@@ -39,9 +39,9 @@ See the [installation instructions](http://voormedia.github.io/rails-erd/install
|
|
39
39
|
### Configuration
|
40
40
|
|
41
41
|
|
42
|
-
Rails ERD has the ability to be configured via the command line or through the use of a YAML file with configuration options set. It will look for this file first at `~/.erdconfig` and then `./.erdconfig` (which will override any settings in `~/.erdconfig`). The format of the file is as follows (shown here with the default settings used if no `.erdconfig` is found). More information on [customization options](
|
42
|
+
Rails ERD has the ability to be configured via the command line or through the use of a YAML file with configuration options set. It will look for this file first at `~/.erdconfig` and then `./.erdconfig` (which will override any settings in `~/.erdconfig`). The format of the file is as follows (shown here with the default settings used if no `.erdconfig` is found). More information on [customization options](https://voormedia.github.io/rails-erd/customise.html) can be found in Rails ERD's project documentation.
|
43
43
|
|
44
|
-
```
|
44
|
+
```yaml
|
45
45
|
attributes:
|
46
46
|
- content
|
47
47
|
- foreign_key
|
@@ -63,13 +63,19 @@ only: null
|
|
63
63
|
only_recursion_depth: null
|
64
64
|
prepend_primary: false
|
65
65
|
cluster: false
|
66
|
+
splines: spline
|
66
67
|
```
|
67
68
|
|
69
|
+
Auto generation
|
70
|
+
---------------
|
71
|
+
|
72
|
+
* Run <tt>rails generate erd:install</tt>
|
73
|
+
* Run <tt>rails db:migrate</tt>, then the diagram is generated
|
68
74
|
|
69
75
|
Learn more
|
70
76
|
----------
|
71
77
|
|
72
|
-
More information can be found on [Rails ERD's project homepage](
|
78
|
+
More information can be found on [Rails ERD's project homepage](https://voormedia.github.io/rails-erd/).
|
73
79
|
|
74
80
|
If you wish to extend or customise Rails ERD, take a look at the [API documentation](http://rubydoc.info/github/voormedia/rails-erd/frames).
|
75
81
|
|
data/lib/rails_erd.rb
CHANGED
@@ -56,6 +56,16 @@ module RailsERD
|
|
56
56
|
:cluster, false,
|
57
57
|
]
|
58
58
|
end
|
59
|
+
|
60
|
+
def loaded_tasks=(val); @loaded_tasks = val; end
|
61
|
+
def loaded_tasks; return @loaded_tasks; end
|
62
|
+
|
63
|
+
def load_tasks
|
64
|
+
return if(self.loaded_tasks)
|
65
|
+
self.loaded_tasks = true
|
66
|
+
|
67
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
|
68
|
+
end
|
59
69
|
end
|
60
70
|
|
61
71
|
module Inspectable # @private :nodoc:
|
data/lib/rails_erd/cli.rb
CHANGED
@@ -74,6 +74,11 @@ Choice.options do
|
|
74
74
|
desc "Display models in subgraphs based on their namespace."
|
75
75
|
end
|
76
76
|
|
77
|
+
option :splines do
|
78
|
+
long "--splines=SPLINE_TYPE"
|
79
|
+
desc "Control how edges are represented. See http://www.graphviz.org/doc/info/attrs.html#d:splines for values."
|
80
|
+
end
|
81
|
+
|
77
82
|
separator ""
|
78
83
|
separator "Output options:"
|
79
84
|
|
@@ -166,7 +171,10 @@ module RailsERD
|
|
166
171
|
puts "Please create a file in '#{environment_path}' that loads your application environment."
|
167
172
|
raise
|
168
173
|
end
|
169
|
-
|
174
|
+
if defined? Rails
|
175
|
+
Rails.application.eager_load!
|
176
|
+
Rails.application.config.eager_load_namespaces.each(&:eager_load!)
|
177
|
+
end
|
170
178
|
rescue TypeError
|
171
179
|
end
|
172
180
|
|
data/lib/rails_erd/diagram.rb
CHANGED
@@ -7,7 +7,7 @@ module RailsERD
|
|
7
7
|
# and (optionally) +save+.
|
8
8
|
#
|
9
9
|
# As an example, a diagram class that generates code that can be used with
|
10
|
-
# yUML (
|
10
|
+
# yUML (https://yuml.me) can be as simple as:
|
11
11
|
#
|
12
12
|
# require "rails_erd/diagram"
|
13
13
|
#
|
@@ -124,13 +124,12 @@ module RailsERD
|
|
124
124
|
# internally by Diagram#create.
|
125
125
|
def generate
|
126
126
|
instance_eval(&callbacks[:setup])
|
127
|
-
|
128
127
|
if options.only_recursion_depth.present?
|
129
128
|
depth = options.only_recursion_depth.to_i
|
130
|
-
options
|
131
|
-
options
|
129
|
+
options[:only].dup.each do |class_name|
|
130
|
+
options[:only]+= recurse_into_relationships(@domain.entity_by_name(class_name), depth)
|
132
131
|
end
|
133
|
-
options
|
132
|
+
options[:only].uniq!
|
134
133
|
end
|
135
134
|
|
136
135
|
filtered_entities.each do |entity|
|
@@ -179,7 +178,7 @@ module RailsERD
|
|
179
178
|
def filtered_entities
|
180
179
|
@domain.entities.reject { |entity|
|
181
180
|
options.exclude.present? && entity.model && [options.exclude].flatten.map(&:to_sym).include?(entity.name.to_sym) or
|
182
|
-
options
|
181
|
+
options[:only].present? && entity.model && ![options[:only]].flatten.map(&:to_sym).include?(entity.name.to_sym) or
|
183
182
|
!options.inheritance && entity.specialized? or
|
184
183
|
!options.polymorphism && entity.generalized? or
|
185
184
|
!options.disconnected && entity.disconnected?
|
@@ -62,7 +62,8 @@ module RailsERD
|
|
62
62
|
concentrate: true,
|
63
63
|
labelloc: :t,
|
64
64
|
fontsize: 13,
|
65
|
-
fontname: FONTS[:bold]
|
65
|
+
fontname: FONTS[:bold],
|
66
|
+
splines: 'spline'
|
66
67
|
}
|
67
68
|
|
68
69
|
# Default node attributes.
|
@@ -188,6 +189,9 @@ module RailsERD
|
|
188
189
|
# Title of the graph itself.
|
189
190
|
graph[:label] = "#{title}\\n\\n" if title
|
190
191
|
|
192
|
+
# Style of splines
|
193
|
+
graph[:splines] = options.splines unless options.splines.nil?
|
194
|
+
|
191
195
|
# Setup notation options.
|
192
196
|
extend self.class.const_get(options.notation.to_s.capitalize.to_sym)
|
193
197
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if options.orientation == :
|
1
|
+
<% if options.orientation == :horizontal %>{<% end %>
|
2
2
|
<table border="0" align="center" cellspacing="0.5" cellpadding="0" width="<%= NODE_WIDTH + 4 %>">
|
3
3
|
<tr><td align="center" valign="bottom" width="<%= NODE_WIDTH %>"><font face="<%= FONTS[:bold] %>" point-size="11"><%= entity.name %></font></td></tr>
|
4
4
|
</table>
|
@@ -11,4 +11,4 @@
|
|
11
11
|
</table>
|
12
12
|
<% else %>
|
13
13
|
<% end %>
|
14
|
-
<% if options.orientation == :
|
14
|
+
<% if options.orientation == :horizontal %>}<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if options.orientation == :
|
1
|
+
<% if options.orientation == :horizontal %>{<% end %><%= entity.name %><% if attributes.any? %>
|
2
2
|
|<% attributes.each do |attribute| %><%=
|
3
3
|
attribute %> (<%= attribute.type_description %>)
|
4
|
-
<% end %><% end %><% if options.orientation == :
|
4
|
+
<% end %><% end %><% if options.orientation == :horizontal %>}<% end %>
|
data/lib/rails_erd/tasks.rake
CHANGED
@@ -1,8 +1,18 @@
|
|
1
|
+
require 'graphviz/utils'
|
2
|
+
|
1
3
|
def say(message)
|
2
4
|
puts message unless Rake.application.options.silent
|
3
5
|
end
|
4
6
|
|
5
7
|
namespace :erd do
|
8
|
+
task :check_dependencies do
|
9
|
+
include GraphViz::Utils
|
10
|
+
unless find_executable("dot", nil)
|
11
|
+
raise "Unable to find GraphViz's \"dot\" executable. Please " \
|
12
|
+
"visit https://voormedia.github.io/rails-erd/install.html for installation instructions."
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
6
16
|
task :options do
|
7
17
|
(RailsERD.options.keys.map(&:to_s) & ENV.keys).each do |option|
|
8
18
|
RailsERD.options[option.to_sym] = case ENV[option]
|
@@ -21,6 +31,10 @@ namespace :erd do
|
|
21
31
|
say "Loading code in search of Active Record models..."
|
22
32
|
begin
|
23
33
|
Rails.application.eager_load!
|
34
|
+
|
35
|
+
if Rails.application.respond_to?(:config) && !Rails.application.config.nil?
|
36
|
+
Rails.application.config.eager_load_namespaces.each(&:eager_load!)
|
37
|
+
end
|
24
38
|
rescue Exception => err
|
25
39
|
if Rake.application.options.trace
|
26
40
|
raise
|
@@ -34,7 +48,7 @@ namespace :erd do
|
|
34
48
|
raise "Active Record was not loaded." unless defined? ActiveRecord
|
35
49
|
end
|
36
50
|
|
37
|
-
task :generate => [:options, :load_models] do
|
51
|
+
task :generate => [:check_dependencies, :options, :load_models] do
|
38
52
|
say "Generating Entity-Relationship Diagram for #{ActiveRecord::Base.descendants.length} models..."
|
39
53
|
|
40
54
|
require "rails_erd/diagram/graphviz"
|
data/lib/rails_erd/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -48,6 +48,29 @@ class ActiveSupport::TestCase
|
|
48
48
|
ActiveRecord::Base.clear_cache!
|
49
49
|
end
|
50
50
|
|
51
|
+
def create_module_model(full_name,*args,&block)
|
52
|
+
superklass = args.first.kind_of?(Class) ? args.shift : ActiveRecord::Base
|
53
|
+
|
54
|
+
names = full_name.split('::')
|
55
|
+
|
56
|
+
parent_module = names[0..-1].inject(Object) do |parent,child|
|
57
|
+
parent = parent.const_set(child.to_sym, Module.new)
|
58
|
+
end
|
59
|
+
|
60
|
+
parent_module ||= Object
|
61
|
+
name = names.last
|
62
|
+
|
63
|
+
columns = args.first || {}
|
64
|
+
klass = parent_module.const_set name.to_sym, Class.new(superklass)
|
65
|
+
konstant = parent_module.const_get(name.to_sym)
|
66
|
+
|
67
|
+
if superklass == ActiveRecord::Base || superklass.abstract_class?
|
68
|
+
create_table konstant.table_name, columns, konstant.primary_key rescue nil
|
69
|
+
end
|
70
|
+
klass.class_eval(&block) if block_given?
|
71
|
+
konstant
|
72
|
+
end
|
73
|
+
|
51
74
|
def create_model(name, *args, &block)
|
52
75
|
superklass = args.first.kind_of?(Class) ? args.shift : ActiveRecord::Base
|
53
76
|
columns = args.first || {}
|
@@ -143,14 +166,37 @@ class ActiveSupport::TestCase
|
|
143
166
|
RailsERD.options = RailsERD.default_options.merge(Config.load)
|
144
167
|
end
|
145
168
|
|
169
|
+
def name_to_object_symbol_pairs(name)
|
170
|
+
parts = name.to_s.split('::')
|
171
|
+
|
172
|
+
return [] if parts.first == '' || parts.count == 0
|
173
|
+
|
174
|
+
parts[1..-1].inject([[Object, parts.first.to_sym]]) do |pairs,string|
|
175
|
+
last_parent, last_child = pairs.last
|
176
|
+
|
177
|
+
break pairs unless last_parent.const_defined?(last_child)
|
178
|
+
|
179
|
+
next_parent = last_parent.const_get(last_child)
|
180
|
+
next_child = string.to_sym
|
181
|
+
pairs << [next_parent, next_child]
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def remove_fully_qualified_constant(name)
|
186
|
+
pairs = name_to_object_symbol_pairs(name)
|
187
|
+
pairs.reverse.each do |parent, child|
|
188
|
+
parent.send(:remove_const,child) if parent.const_defined?(child)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
146
192
|
def reset_domain
|
147
193
|
if defined? ActiveRecord
|
148
194
|
ActiveRecord::Base.descendants.each do |model|
|
149
195
|
next if model.name == "ActiveRecord::InternalMetadata"
|
150
196
|
model.reset_column_information
|
151
|
-
|
197
|
+
remove_fully_qualified_constant(model.name)
|
152
198
|
end
|
153
|
-
|
199
|
+
tables_and_views.each do |table|
|
154
200
|
ActiveRecord::Base.connection.drop_table table
|
155
201
|
end
|
156
202
|
ActiveRecord::Base.direct_descendants.clear
|
@@ -158,4 +204,12 @@ class ActiveSupport::TestCase
|
|
158
204
|
ActiveRecord::Base.clear_cache!
|
159
205
|
end
|
160
206
|
end
|
207
|
+
|
208
|
+
def tables_and_views
|
209
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
210
|
+
ActiveRecord::Base.connection.data_sources
|
211
|
+
else
|
212
|
+
ActiveRecord::Base.connection.tables
|
213
|
+
end
|
214
|
+
end
|
161
215
|
end
|
data/test/unit/attribute_test.rb
CHANGED
@@ -224,14 +224,14 @@ class AttributeTest < ActiveSupport::TestCase
|
|
224
224
|
test "limit should return nil if there is no limit" do
|
225
225
|
create_model "Foo"
|
226
226
|
add_column :foos, :my_txt, :text
|
227
|
-
|
227
|
+
assert_nil create_attribute(Foo, "my_txt").limit
|
228
228
|
end
|
229
229
|
|
230
230
|
test "limit should return nil if equal to standard database limit" do
|
231
231
|
with_native_limit :string, 456 do
|
232
232
|
create_model "Foo"
|
233
233
|
add_column :foos, :my_str, :string, :limit => 456
|
234
|
-
|
234
|
+
assert_nil create_attribute(Foo, "my_str").limit
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
@@ -252,7 +252,7 @@ class AttributeTest < ActiveSupport::TestCase
|
|
252
252
|
test "limit should return nil for decimal columns if equal to standard database limit" do
|
253
253
|
create_model "Foo"
|
254
254
|
add_column :foos, :num, :decimal
|
255
|
-
|
255
|
+
assert_nil create_attribute(Foo, "num").limit
|
256
256
|
end
|
257
257
|
|
258
258
|
test "limit should return nil if type is unsupported by rails" do
|
@@ -262,7 +262,7 @@ class AttributeTest < ActiveSupport::TestCase
|
|
262
262
|
add_column "foos", "a", "REAL"
|
263
263
|
end
|
264
264
|
end
|
265
|
-
|
265
|
+
assert_nil create_attribute(Foo, "a").limit
|
266
266
|
end
|
267
267
|
|
268
268
|
test "limit should return nil for oddball column types that misuse the limit attribute" do
|
@@ -274,7 +274,7 @@ class AttributeTest < ActiveSupport::TestCase
|
|
274
274
|
{ :srid => 4326, :type => "point", :geographic => true }
|
275
275
|
end
|
276
276
|
end
|
277
|
-
|
277
|
+
assert_nil attribute.limit
|
278
278
|
end
|
279
279
|
|
280
280
|
test "scale should return scale for decimal columns if nonstandard" do
|
@@ -286,7 +286,7 @@ class AttributeTest < ActiveSupport::TestCase
|
|
286
286
|
test "scale should return nil for decimal columns if equal to standard database limit" do
|
287
287
|
create_model "Foo"
|
288
288
|
add_column :foos, :num, :decimal
|
289
|
-
|
289
|
+
assert_nil create_attribute(Foo, "num").scale
|
290
290
|
end
|
291
291
|
|
292
292
|
test "scale should return zero for decimal columns if left to default setting when specifying precision" do
|
@@ -302,7 +302,7 @@ class AttributeTest < ActiveSupport::TestCase
|
|
302
302
|
add_column "foos", "a", "REAL"
|
303
303
|
end
|
304
304
|
end
|
305
|
-
|
305
|
+
assert_nil create_attribute(Foo, "a").scale
|
306
306
|
end
|
307
307
|
|
308
308
|
test "scale should return nil for oddball column types that misuse the scale attribute" do
|
@@ -313,6 +313,6 @@ class AttributeTest < ActiveSupport::TestCase
|
|
313
313
|
1..5
|
314
314
|
end
|
315
315
|
end
|
316
|
-
|
316
|
+
assert_nil attribute.scale
|
317
317
|
end
|
318
318
|
end
|
data/test/unit/domain_test.rb
CHANGED
@@ -225,7 +225,7 @@ class DomainTest < ActiveSupport::TestCase
|
|
225
225
|
output = collect_stdout do
|
226
226
|
Domain.generate.relationships
|
227
227
|
end
|
228
|
-
assert_match
|
228
|
+
assert_match(/Ignoring invalid association :flabs on Foo/, output)
|
229
229
|
end
|
230
230
|
|
231
231
|
test "relationships should output a warning when an association to model outside domain is encountered" do
|
@@ -236,7 +236,7 @@ class DomainTest < ActiveSupport::TestCase
|
|
236
236
|
output = collect_stdout do
|
237
237
|
Domain.new([Foo]).relationships
|
238
238
|
end
|
239
|
-
assert_match
|
239
|
+
assert_match(/model Bar exists, but is not included in domain/, output)
|
240
240
|
end
|
241
241
|
|
242
242
|
test "relationships should output a warning when an association to a non existent generalization is encountered" do
|
@@ -249,7 +249,7 @@ class DomainTest < ActiveSupport::TestCase
|
|
249
249
|
output = collect_stdout do
|
250
250
|
Domain.generate.relationships
|
251
251
|
end
|
252
|
-
assert_match
|
252
|
+
assert_match(/polymorphic interface FooBar does not exist/, output)
|
253
253
|
end
|
254
254
|
|
255
255
|
test "relationships should not warn when a bad association is encountered if warnings are disabled" do
|
@@ -273,6 +273,6 @@ class DomainTest < ActiveSupport::TestCase
|
|
273
273
|
output = collect_stdout do
|
274
274
|
Domain.generate.entities
|
275
275
|
end
|
276
|
-
assert_match
|
276
|
+
assert_match(/Ignoring invalid model Foo \(table foos does not exist\)/, output)
|
277
277
|
end
|
278
278
|
end
|
data/test/unit/entity_test.rb
CHANGED
@@ -249,4 +249,30 @@ class EntityTest < ActiveSupport::TestCase
|
|
249
249
|
assert_equal [domain.entity_by_name("Galleon"), domain.entity_by_name("Stronghold")],
|
250
250
|
domain.entity_by_name("Defensible").children
|
251
251
|
end
|
252
|
+
|
253
|
+
# Namespace ===================================================================
|
254
|
+
test "namespace should return nil for models outside modules" do
|
255
|
+
create_module_model "Plane"
|
256
|
+
assert_nil create_entity(Plane).namespace
|
257
|
+
end
|
258
|
+
|
259
|
+
test "namespace should return the module name for single-module models" do
|
260
|
+
create_module_model "Saw::Plane"
|
261
|
+
assert_equal "Saw", create_entity(Saw::Plane).namespace
|
262
|
+
end
|
263
|
+
|
264
|
+
test "namespace should return the module path if more than one module" do
|
265
|
+
create_module_model "Augur::Chisel::Saw::Plane"
|
266
|
+
assert_equal "Augur::Chisel::Saw", create_entity(Augur::Chisel::Saw::Plane).namespace
|
267
|
+
end
|
268
|
+
|
269
|
+
test "namespace defaults to nil" do
|
270
|
+
create_model "Foo"
|
271
|
+
assert_nil create_entity(Foo).namespace
|
272
|
+
end
|
273
|
+
|
274
|
+
test "namespace returns appropriate modules" do
|
275
|
+
entity = Domain::Entity.new(Domain.new, "Foo::Bar::Qux")
|
276
|
+
assert_equal "Foo::Bar", entity.namespace
|
277
|
+
end
|
252
278
|
end
|
data/test/unit/graphviz_test.rb
CHANGED
@@ -149,7 +149,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
149
149
|
rescue => e
|
150
150
|
message = e.message
|
151
151
|
end
|
152
|
-
assert_match
|
152
|
+
assert_match(/No entities found/, message)
|
153
153
|
end
|
154
154
|
|
155
155
|
test "create should abort and complain if output directory does not exist" do
|
@@ -162,7 +162,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
162
162
|
message = e.message
|
163
163
|
end
|
164
164
|
|
165
|
-
assert_match
|
165
|
+
assert_match(/Output directory 'does_not_exist' does not exist/, message)
|
166
166
|
end
|
167
167
|
|
168
168
|
test "create should not fail when reserved words are used as node names" do
|
@@ -186,6 +186,16 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
186
186
|
assert_equal '"Domain model\n\n"', diagram.graph.graph[:label].to_s
|
187
187
|
end
|
188
188
|
|
189
|
+
test "generate should add default value for splines attribute" do
|
190
|
+
create_simple_domain
|
191
|
+
assert_equal '"spline"', diagram.graph.graph[:splines].to_s
|
192
|
+
end
|
193
|
+
|
194
|
+
test "generate should add set value for splines attribute" do
|
195
|
+
create_simple_domain
|
196
|
+
assert_equal '"ortho"', diagram(splines: 'ortho').graph.graph[:splines].to_s
|
197
|
+
end
|
198
|
+
|
189
199
|
test "generate should add title with application name to graph" do
|
190
200
|
begin
|
191
201
|
Object::Quux = Module.new
|
@@ -228,7 +238,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
228
238
|
belongs_to :bar
|
229
239
|
end
|
230
240
|
create_model "Bar"
|
231
|
-
assert_equal %Q("Bar"), find_dot_node(diagram, "m_Bar")[:label].to_gv
|
241
|
+
assert_equal %Q("{Bar}"), find_dot_node(diagram, "m_Bar")[:label].to_gv
|
232
242
|
end
|
233
243
|
|
234
244
|
test "generate should add attributes to entity html labels" do
|
@@ -246,7 +256,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
246
256
|
belongs_to :bar
|
247
257
|
end
|
248
258
|
create_model "Bar", :column => :string, :column_two => :boolean
|
249
|
-
assert_equal %Q("Bar|column (string)\\ncolumn_two (boolean)\\n"), find_dot_node(diagram, "m_Bar")[:label].to_gv
|
259
|
+
assert_equal %Q("{Bar|column (string)\\ncolumn_two (boolean)\\n}"), find_dot_node(diagram, "m_Bar")[:label].to_gv
|
250
260
|
end
|
251
261
|
|
252
262
|
test "generate should not add any attributes to entity labels if attributes is set to false" do
|
@@ -257,40 +267,40 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
257
267
|
assert_no_match %r{contents}, find_dot_node(diagram(:attributes => false), "m_Jar")[:label].to_gv
|
258
268
|
end
|
259
269
|
|
260
|
-
test "node html labels should have direction reversing braces for
|
270
|
+
test "node html labels should have direction reversing braces for horizontal orientation" do
|
261
271
|
RailsERD.options.markup = true
|
262
272
|
create_model "Book", :author => :references do
|
263
273
|
belongs_to :author
|
264
274
|
end
|
265
275
|
create_model "Author", :name => :string
|
266
|
-
assert_match %r(\A<\{\s*<.*\|.*>\s*\}>\Z)m, find_dot_node(diagram(:orientation => :
|
276
|
+
assert_match %r(\A<\{\s*<.*\|.*>\s*\}>\Z)m, find_dot_node(diagram(:orientation => :horizontal), "m_Author")[:label].to_gv
|
267
277
|
end
|
268
278
|
|
269
|
-
test "node html labels should not have direction reversing braces for
|
279
|
+
test "node html labels should not have direction reversing braces for vertical orientation" do
|
270
280
|
RailsERD.options.markup = true
|
271
281
|
create_model "Book", :author => :references do
|
272
282
|
belongs_to :author
|
273
283
|
end
|
274
284
|
create_model "Author", :name => :string
|
275
|
-
assert_match %r(\A<\s*<.*\|.*>\s*>\Z)m, find_dot_node(diagram(:orientation => :
|
285
|
+
assert_match %r(\A<\s*<.*\|.*>\s*>\Z)m, find_dot_node(diagram(:orientation => :vertical), "m_Author")[:label].to_gv
|
276
286
|
end
|
277
287
|
|
278
|
-
test "node record labels should have direction reversing braces for
|
288
|
+
test "node record labels should have direction reversing braces for horizontal orientation" do
|
279
289
|
RailsERD.options.markup = false
|
280
290
|
create_model "Book", :author => :references do
|
281
291
|
belongs_to :author
|
282
292
|
end
|
283
293
|
create_model "Author", :name => :string
|
284
|
-
assert_match %r(\A"\{\w
|
294
|
+
assert_match %r(\A"\{\w+\|.*\}"\Z)m, find_dot_node(diagram(:orientation => :horizontal), "m_Author")[:label].to_gv
|
285
295
|
end
|
286
296
|
|
287
|
-
test "node record labels should not have direction reversing braces for
|
297
|
+
test "node record labels should not have direction reversing braces for vertical orientation" do
|
288
298
|
RailsERD.options.markup = false
|
289
299
|
create_model "Book", :author => :references do
|
290
300
|
belongs_to :author
|
291
301
|
end
|
292
302
|
create_model "Author", :name => :string
|
293
|
-
assert_match %r(\A"\w
|
303
|
+
assert_match %r(\A"\w+\|.*"\Z)m, find_dot_node(diagram(:orientation => :vertical), "m_Author")[:label].to_gv
|
294
304
|
end
|
295
305
|
|
296
306
|
test "generate should create edge for each relationship" do
|
data/test/unit/rake_task_test.rb
CHANGED
@@ -20,6 +20,7 @@ class RakeTaskTest < ActiveSupport::TestCase
|
|
20
20
|
Object::Quux = Module.new
|
21
21
|
Object::Quux::Application = Class.new
|
22
22
|
Object::Rails = Struct.new(:application).new(Object::Quux::Application.new)
|
23
|
+
|
23
24
|
Rails.class_eval do
|
24
25
|
define_method :backtrace_cleaner do
|
25
26
|
ActiveSupport::BacktraceCleaner.new.tap do |cleaner|
|
@@ -100,12 +101,13 @@ class RakeTaskTest < ActiveSupport::TestCase
|
|
100
101
|
rescue => e
|
101
102
|
message = e.message
|
102
103
|
end
|
103
|
-
assert_match
|
104
|
+
assert_match(/#{Regexp.escape(<<-MSG.strip).gsub("xxx", ".*?")}/, message
|
104
105
|
Loading models failed!
|
105
106
|
Error occurred while loading application: FooBar (RuntimeError)
|
106
107
|
test/unit/rake_task_test.rb:#{l1}:in `xxx'
|
107
108
|
test/unit/rake_task_test.rb:#{l2}:in `xxx'
|
108
109
|
MSG
|
110
|
+
)
|
109
111
|
end
|
110
112
|
|
111
113
|
test "generate task should reraise if application could not be loaded and trace option is enabled" do
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-erd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rolf Timmermans
|
8
|
+
- Kerri Miller
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2017-05-15 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activerecord
|
@@ -70,6 +71,7 @@ description: Automatically generate an entity-relationship diagram (ERD) for you
|
|
70
71
|
Rails models.
|
71
72
|
email:
|
72
73
|
- r.timmermans@voormedia.com
|
74
|
+
- kerrizor@kerrizor.com
|
73
75
|
executables:
|
74
76
|
- erd
|
75
77
|
extensions: []
|
@@ -133,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
135
|
version: '0'
|
134
136
|
requirements: []
|
135
137
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.6.10
|
137
139
|
signing_key:
|
138
140
|
specification_version: 4
|
139
141
|
summary: Entity-relationship diagram for your Rails models.
|
@@ -152,4 +154,3 @@ test_files:
|
|
152
154
|
- test/unit/rake_task_test.rb
|
153
155
|
- test/unit/relationship_test.rb
|
154
156
|
- test/unit/specialization_test.rb
|
155
|
-
has_rdoc:
|