rails-erd 0.4.3 → 0.4.4
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.
- data/.gemtest +0 -0
- data/CHANGES.rdoc +11 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +7 -9
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/rails_erd.rb +4 -3
- data/lib/rails_erd/diagram/graphviz.rb +40 -28
- data/lib/rails_erd/diagram/templates/{node.erb → node.html.erb} +0 -0
- data/lib/rails_erd/diagram/templates/node.record.erb +4 -0
- data/lib/rails_erd/tasks.rake +3 -3
- data/rails-erd.gemspec +6 -11
- data/test/unit/graphviz_test.rb +85 -35
- metadata +17 -73
data/.gemtest
ADDED
File without changes
|
data/CHANGES.rdoc
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 0.4.4:
|
2
|
+
|
3
|
+
* Added the ability to disable HTML markup in node labels (markup=false). This
|
4
|
+
causes .dot files to be compatible with OmniGraffle, which otherwise fails
|
5
|
+
to import graphs with HTML node labels (issue reported by Lucas Florio,
|
6
|
+
implementation based on template by Troy Anderson).
|
7
|
+
* Prevent models named after Graphviz reserved words (Node, Edge) from causing
|
8
|
+
errors in .dot files (reported by gguthrie).
|
9
|
+
* Improved error messages when Graphviz is throwing errors (reported by
|
10
|
+
Michael Irwin).
|
11
|
+
|
1
12
|
=== 0.4.3:
|
2
13
|
|
3
14
|
* Display the scale of decimal attributes when set. A decimal attribute with
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activemodel (3.0.
|
5
|
-
activesupport (= 3.0.
|
4
|
+
activemodel (3.0.4)
|
5
|
+
activesupport (= 3.0.4)
|
6
6
|
builder (~> 2.1.2)
|
7
7
|
i18n (~> 0.4)
|
8
|
-
activerecord (3.0.
|
9
|
-
activemodel (= 3.0.
|
10
|
-
activesupport (= 3.0.
|
8
|
+
activerecord (3.0.4)
|
9
|
+
activemodel (= 3.0.4)
|
10
|
+
activesupport (= 3.0.4)
|
11
11
|
arel (~> 2.0.2)
|
12
12
|
tzinfo (~> 0.3.23)
|
13
13
|
activerecord-jdbc-adapter (1.1.1)
|
14
|
-
activesupport (3.0.
|
15
|
-
arel (2.0.
|
14
|
+
activesupport (3.0.4)
|
15
|
+
arel (2.0.8)
|
16
16
|
bouncy-castle-java (1.5.0145.2)
|
17
17
|
builder (2.1.2)
|
18
18
|
git (1.2.5)
|
@@ -37,10 +37,8 @@ DEPENDENCIES
|
|
37
37
|
activerecord (~> 3.0)
|
38
38
|
activerecord-jdbc-adapter
|
39
39
|
activesupport (~> 3.0)
|
40
|
-
bundler (~> 1.0.0)
|
41
40
|
jdbc-sqlite3
|
42
41
|
jeweler (~> 1.5.2)
|
43
42
|
jruby-openssl
|
44
|
-
rake
|
45
43
|
ruby-graphviz (~> 0.9.18)
|
46
44
|
sqlite3
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -51,7 +51,7 @@ About Rails ERD
|
|
51
51
|
|
52
52
|
Rails ERD was created by Rolf Timmermans (r.timmermans *at* voormedia.com)
|
53
53
|
|
54
|
-
Copyright 2010 Voormedia - [www.voormedia.com](http://www.voormedia.com/)
|
54
|
+
Copyright 2010-2011 Voormedia - [www.voormedia.com](http://www.voormedia.com/)
|
55
55
|
|
56
56
|
|
57
57
|
License
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.4
|
data/lib/rails_erd.rb
CHANGED
@@ -4,9 +4,9 @@ require "rails_erd/railtie" if defined? Rails
|
|
4
4
|
# Welcome to the API documentation of Rails ERD. If you wish to extend or
|
5
5
|
# customise the output that is generated by Rails ERD, you have come to the
|
6
6
|
# right place.
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# == Creating custom output
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# If you want to create your own kind of diagrams, or some other output, a
|
11
11
|
# good starting point is the RailsERD::Diagram class. It can serve as the base
|
12
12
|
# of your output generation code.
|
@@ -33,7 +33,7 @@ module RailsERD
|
|
33
33
|
# RailsERD::Diagram will use these options unless overridden.
|
34
34
|
attr_accessor :options
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
module Inspectable # @private :nodoc:
|
38
38
|
def inspection_attributes(*attributes)
|
39
39
|
attribute_inspection = attributes.collect { |attribute|
|
@@ -54,6 +54,7 @@ module RailsERD
|
|
54
54
|
:filetype, :pdf,
|
55
55
|
:indirect, true,
|
56
56
|
:inheritance, false,
|
57
|
+
:markup, true,
|
57
58
|
:notation, :simple,
|
58
59
|
:orientation, :horizontal,
|
59
60
|
:polymorphism, false,
|
@@ -40,13 +40,13 @@ module RailsERD
|
|
40
40
|
# or +:vertical+. Defaults to +horizontal+. The orientation of the
|
41
41
|
# PDF that is generated depends on the amount of hierarchy
|
42
42
|
# in your models.
|
43
|
-
# title:: The title to add at the top of the diagram. Defaults to
|
43
|
+
# title:: The title to add at the top of the diagram. Defaults to
|
44
44
|
# <tt>"YourApplication domain model"</tt>.
|
45
45
|
class Graphviz < Diagram
|
46
|
-
|
46
|
+
NODE_LABEL_TEMPLATES = { :html => "node.html.erb", :record => "node.record.erb" } # @private :nodoc:
|
47
47
|
|
48
48
|
NODE_WIDTH = 130 # @private :nodoc:
|
49
|
-
|
49
|
+
|
50
50
|
# Default graph attributes.
|
51
51
|
GRAPH_ATTRIBUTES = {
|
52
52
|
:rankdir => :LR,
|
@@ -78,16 +78,16 @@ module RailsERD
|
|
78
78
|
:penwidth => 1.0,
|
79
79
|
:labelangle => 32,
|
80
80
|
:labeldistance => 1.8,
|
81
|
-
:fontsize => 7
|
81
|
+
:fontsize => 7
|
82
82
|
}
|
83
|
-
|
83
|
+
|
84
84
|
module Simple
|
85
85
|
def entity_style(entity, attributes)
|
86
86
|
{}.tap do |options|
|
87
87
|
options[:fontcolor] = options[:color] = :grey60 if entity.abstract?
|
88
88
|
end
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
def relationship_style(relationship)
|
92
92
|
{}.tap do |options|
|
93
93
|
options[:style] = :dotted if relationship.indirect?
|
@@ -102,7 +102,7 @@ module RailsERD
|
|
102
102
|
{ :color => :grey60, :arrowtail => :onormal, :arrowhead => :none, :arrowsize => 1.2 }
|
103
103
|
end
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
module Bachman
|
107
107
|
include Simple
|
108
108
|
def relationship_style(relationship)
|
@@ -121,7 +121,7 @@ module RailsERD
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
module Uml
|
126
126
|
include Simple
|
127
127
|
def relationship_style(relationship)
|
@@ -143,7 +143,7 @@ module RailsERD
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
attr_accessor :graph
|
148
148
|
|
149
149
|
setup do
|
@@ -156,33 +156,36 @@ module RailsERD
|
|
156
156
|
|
157
157
|
# Switch rank direction if we're creating a vertically oriented graph.
|
158
158
|
graph[:rankdir] = :TB if options.orientation == :vertical
|
159
|
-
|
159
|
+
|
160
160
|
# Title of the graph itself.
|
161
161
|
graph[:label] = "#{title}\\n\\n" if title
|
162
|
-
|
162
|
+
|
163
163
|
# Setup notation options.
|
164
164
|
extend self.class.const_get(options.notation.to_s.capitalize.to_sym)
|
165
165
|
end
|
166
|
-
|
166
|
+
|
167
167
|
save do
|
168
|
-
raise "Saving diagram failed
|
168
|
+
raise "Saving diagram failed!\nOutput directory '#{File.dirname(filename)}' does not exist." unless File.directory?(File.dirname(filename))
|
169
169
|
begin
|
170
170
|
graph.output(filetype => filename)
|
171
171
|
filename
|
172
|
+
rescue RuntimeError => e
|
173
|
+
raise "Saving diagram failed!\nGraphviz produced errors. Verify it has support for filetype=#{options.filetype}, or use filetype=dot." <<
|
174
|
+
"\nOriginal error: #{e.message.split("\n").last}"
|
172
175
|
rescue StandardError => e
|
173
|
-
raise "Saving diagram failed
|
176
|
+
raise "Saving diagram failed!\nVerify that Graphviz is installed and in your path, or use filetype=dot."
|
174
177
|
end
|
175
178
|
end
|
176
179
|
|
177
180
|
each_entity do |entity, attributes|
|
178
181
|
draw_node entity.name, entity_options(entity, attributes)
|
179
182
|
end
|
180
|
-
|
183
|
+
|
181
184
|
each_specialization do |specialization|
|
182
185
|
from, to = specialization.generalized, specialization.specialized
|
183
186
|
draw_edge from.name, to.name, specialization_options(specialization)
|
184
187
|
end
|
185
|
-
|
188
|
+
|
186
189
|
each_relationship do |relationship|
|
187
190
|
from, to = relationship.source, relationship.destination
|
188
191
|
unless draw_edge from.name, to.name, relationship_options(relationship)
|
@@ -193,19 +196,23 @@ module RailsERD
|
|
193
196
|
end
|
194
197
|
end
|
195
198
|
end
|
196
|
-
|
199
|
+
|
197
200
|
private
|
198
|
-
|
201
|
+
|
199
202
|
def node_exists?(name)
|
200
|
-
!!graph.get_node(name)
|
203
|
+
!!graph.get_node(escape_name(name))
|
201
204
|
end
|
202
|
-
|
205
|
+
|
203
206
|
def draw_node(name, options)
|
204
|
-
graph.add_node name, options
|
207
|
+
graph.add_node escape_name(name), options
|
205
208
|
end
|
206
|
-
|
209
|
+
|
207
210
|
def draw_edge(from, to, options)
|
208
|
-
graph.add_edge graph.get_node(from), graph.get_node(to), options if node_exists?(from) and node_exists?(to)
|
211
|
+
graph.add_edge graph.get_node(escape_name(from)), graph.get_node(escape_name(to)), options if node_exists?(from) and node_exists?(to)
|
212
|
+
end
|
213
|
+
|
214
|
+
def escape_name(name)
|
215
|
+
"m_#{name}"
|
209
216
|
end
|
210
217
|
|
211
218
|
# Returns the title to be used for the graph.
|
@@ -217,26 +224,27 @@ module RailsERD
|
|
217
224
|
else options.title
|
218
225
|
end
|
219
226
|
end
|
220
|
-
|
227
|
+
|
221
228
|
# Returns the file name that will be used when saving the diagram.
|
222
229
|
def filename
|
223
230
|
"#{options.filename}.#{options.filetype}"
|
224
231
|
end
|
225
|
-
|
232
|
+
|
226
233
|
# Returns the default file extension to be used when saving the diagram.
|
227
234
|
def filetype
|
228
235
|
if options.filetype.to_sym == :dot then :none else options.filetype.to_sym end
|
229
236
|
end
|
230
237
|
|
231
238
|
def entity_options(entity, attributes)
|
232
|
-
|
239
|
+
label = options[:markup] ? "<#{read_template(:html).result(binding)}>" : "#{read_template(:record).result(binding)}"
|
240
|
+
entity_style(entity, attributes).merge :label => label
|
233
241
|
end
|
234
|
-
|
242
|
+
|
235
243
|
def relationship_options(relationship)
|
236
244
|
relationship_style(relationship).tap do |options|
|
237
245
|
# Edges with a higher weight are optimised to be shorter and straighter.
|
238
246
|
options[:weight] = relationship.strength
|
239
|
-
|
247
|
+
|
240
248
|
# Indirect relationships should not influence node ranks.
|
241
249
|
options[:constraint] = false if relationship.indirect?
|
242
250
|
end
|
@@ -245,6 +253,10 @@ module RailsERD
|
|
245
253
|
def specialization_options(specialization)
|
246
254
|
specialization_style(specialization)
|
247
255
|
end
|
256
|
+
|
257
|
+
def read_template(type)
|
258
|
+
ERB.new(File.read(File.expand_path("templates/#{NODE_LABEL_TEMPLATES[type]}", File.dirname(__FILE__))), nil, "<>")
|
259
|
+
end
|
248
260
|
end
|
249
261
|
end
|
250
262
|
end
|
File without changes
|
data/lib/rails_erd/tasks.rake
CHANGED
@@ -13,17 +13,17 @@ namespace :erd do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
task :load_models do
|
18
18
|
say "Loading application environment..."
|
19
19
|
Rake::Task[:environment].invoke
|
20
20
|
|
21
21
|
say "Loading code in search of Active Record models..."
|
22
22
|
Rails.application.eager_load!
|
23
|
-
|
23
|
+
|
24
24
|
raise "Active Record was not loaded." unless defined? ActiveRecord
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
task :generate => [:options, :load_models] do
|
28
28
|
say "Generating Entity-Relationship Diagram for #{ActiveRecord::Base.descendants.length} models..."
|
29
29
|
|
data/rails-erd.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rails-erd}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rolf Timmermans"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-03-22}
|
13
13
|
s.description = %q{Automatically generate an entity-relationship diagram (ERD) for your Rails models.}
|
14
14
|
s.email = %q{r.timmermans@voormedia.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
+
".gemtest",
|
20
21
|
"CHANGES.rdoc",
|
21
22
|
"Gemfile",
|
22
23
|
"Gemfile.lock",
|
@@ -28,7 +29,8 @@ Gem::Specification.new do |s|
|
|
28
29
|
"lib/rails_erd.rb",
|
29
30
|
"lib/rails_erd/diagram.rb",
|
30
31
|
"lib/rails_erd/diagram/graphviz.rb",
|
31
|
-
"lib/rails_erd/diagram/templates/node.erb",
|
32
|
+
"lib/rails_erd/diagram/templates/node.html.erb",
|
33
|
+
"lib/rails_erd/diagram/templates/node.record.erb",
|
32
34
|
"lib/rails_erd/domain.rb",
|
33
35
|
"lib/rails_erd/domain/attribute.rb",
|
34
36
|
"lib/rails_erd/domain/entity.rb",
|
@@ -52,7 +54,7 @@ Gem::Specification.new do |s|
|
|
52
54
|
s.homepage = %q{http://rails-erd.rubyforge.org/}
|
53
55
|
s.require_paths = ["lib"]
|
54
56
|
s.rubyforge_project = %q{rails-erd}
|
55
|
-
s.rubygems_version = %q{1.
|
57
|
+
s.rubygems_version = %q{1.5.2}
|
56
58
|
s.summary = %q{Entity-relationship diagram for your Rails models.}
|
57
59
|
s.test_files = [
|
58
60
|
"test/test_helper.rb",
|
@@ -68,15 +70,12 @@ Gem::Specification.new do |s|
|
|
68
70
|
]
|
69
71
|
|
70
72
|
if s.respond_to? :specification_version then
|
71
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
72
73
|
s.specification_version = 3
|
73
74
|
|
74
75
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
75
76
|
s.add_runtime_dependency(%q<activerecord>, ["~> 3.0"])
|
76
77
|
s.add_runtime_dependency(%q<activesupport>, ["~> 3.0"])
|
77
78
|
s.add_runtime_dependency(%q<ruby-graphviz>, ["~> 0.9.18"])
|
78
|
-
s.add_development_dependency(%q<rake>, [">= 0"])
|
79
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
80
79
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
81
80
|
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
82
81
|
s.add_development_dependency(%q<jdbc-sqlite3>, [">= 0"])
|
@@ -86,8 +85,6 @@ Gem::Specification.new do |s|
|
|
86
85
|
s.add_dependency(%q<activerecord>, ["~> 3.0"])
|
87
86
|
s.add_dependency(%q<activesupport>, ["~> 3.0"])
|
88
87
|
s.add_dependency(%q<ruby-graphviz>, ["~> 0.9.18"])
|
89
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
90
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
91
88
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
92
89
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
93
90
|
s.add_dependency(%q<jdbc-sqlite3>, [">= 0"])
|
@@ -98,8 +95,6 @@ Gem::Specification.new do |s|
|
|
98
95
|
s.add_dependency(%q<activerecord>, ["~> 3.0"])
|
99
96
|
s.add_dependency(%q<activesupport>, ["~> 3.0"])
|
100
97
|
s.add_dependency(%q<ruby-graphviz>, ["~> 0.9.18"])
|
101
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
102
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
103
98
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
104
99
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
105
100
|
s.add_dependency(%q<jdbc-sqlite3>, [">= 0"])
|
data/test/unit/graphviz_test.rb
CHANGED
@@ -6,18 +6,18 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
6
6
|
RailsERD.options.warn = false
|
7
7
|
load "rails_erd/diagram/graphviz.rb"
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def teardown
|
11
11
|
FileUtils.rm Dir["ERD.*"] rescue nil
|
12
12
|
RailsERD::Diagram.send :remove_const, :Graphviz rescue nil
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def diagram(options = {})
|
16
16
|
@diagram ||= Diagram::Graphviz.new(Domain.generate(options), options).tap do |diagram|
|
17
17
|
diagram.generate
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def find_dot_nodes(diagram)
|
22
22
|
[].tap do |nodes|
|
23
23
|
diagram.graph.each_node do |name, node|
|
@@ -37,7 +37,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def find_dot_edges(diagram)
|
42
42
|
[].tap do |edges|
|
43
43
|
diagram.graph.each_edge do |edge|
|
@@ -45,7 +45,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def find_dot_edge_styles(diagram)
|
50
50
|
find_dot_edges(diagram).map { |e| [e[:arrowtail].to_s.tr('"', ''), e[:arrowhead].to_s.tr('"', '')] }
|
51
51
|
end
|
@@ -59,7 +59,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
59
59
|
FileUtils.rm "ERD.svg" rescue nil
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
test "rank direction should be lr for horizontal orientation" do
|
64
64
|
create_simple_domain
|
65
65
|
assert_equal '"LR"', diagram(:orientation => :horizontal).graph[:rankdir].to_s
|
@@ -69,7 +69,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
69
69
|
create_simple_domain
|
70
70
|
assert_equal '"TB"', diagram(:orientation => :vertical).graph[:rankdir].to_s
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
# Diagram generation =======================================================
|
74
74
|
test "create should create output for domain with attributes" do
|
75
75
|
create_model "Foo", :bar => :references, :column => :string do
|
@@ -85,7 +85,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
85
85
|
Diagram::Graphviz.create
|
86
86
|
assert File.exists?("ERD.png")
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
test "create should write to file with dot extension if type is dot" do
|
90
90
|
create_simple_domain
|
91
91
|
Diagram::Graphviz.create :filetype => :dot
|
@@ -108,7 +108,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
test "create should create output for domain with attributes if orientation is vertical" do
|
113
113
|
create_model "Foo", :bar => :references, :column => :string do
|
114
114
|
belongs_to :bar
|
@@ -138,7 +138,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
138
138
|
end
|
139
139
|
assert_match /No entities found/, message
|
140
140
|
end
|
141
|
-
|
141
|
+
|
142
142
|
test "create should write to given file name plus extension if present" do
|
143
143
|
begin
|
144
144
|
create_simple_domain
|
@@ -148,7 +148,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
148
148
|
FileUtils.rm "foobar.png" rescue nil
|
149
149
|
end
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
test "create should abort and complain if output directory does not exist" do
|
153
153
|
message = nil
|
154
154
|
begin
|
@@ -160,12 +160,22 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
160
160
|
assert_match /Output directory 'does_not_exist' does not exist/, message
|
161
161
|
end
|
162
162
|
|
163
|
+
test "create should not fail when reserved words are used as node names" do
|
164
|
+
create_model "Node", :name => :string
|
165
|
+
create_model "Edge", :node => :references do
|
166
|
+
belongs_to :node
|
167
|
+
end
|
168
|
+
assert_nothing_raised do
|
169
|
+
Diagram::Graphviz.create
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
163
173
|
# Graphviz output ==========================================================
|
164
174
|
test "generate should create directed graph" do
|
165
175
|
create_simple_domain
|
166
176
|
assert_equal "digraph", diagram.graph.type
|
167
177
|
end
|
168
|
-
|
178
|
+
|
169
179
|
test "generate should add title to graph" do
|
170
180
|
create_simple_domain
|
171
181
|
assert_equal '"Domain model\n\n"', diagram.graph.graph[:label].to_s
|
@@ -189,29 +199,49 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
189
199
|
create_simple_domain
|
190
200
|
assert_equal "", diagram(:title => false).graph.graph[:label].to_s
|
191
201
|
end
|
192
|
-
|
202
|
+
|
193
203
|
test "generate should create node for each entity" do
|
194
204
|
create_model "Foo", :bar => :references do
|
195
205
|
belongs_to :bar
|
196
206
|
end
|
197
207
|
create_model "Bar"
|
198
|
-
assert_equal ["
|
208
|
+
assert_equal ["m_Bar", "m_Foo"], find_dot_nodes(diagram).map(&:id).sort
|
209
|
+
end
|
210
|
+
|
211
|
+
test "generate should add html label for entities" do
|
212
|
+
RailsERD.options.markup = true
|
213
|
+
create_model "Foo", :bar => :references do
|
214
|
+
belongs_to :bar
|
215
|
+
end
|
216
|
+
create_model "Bar"
|
217
|
+
assert_match %r{<\w+.*?>Bar</\w+>}, find_dot_node(diagram, "m_Bar")[:label].to_gv
|
199
218
|
end
|
200
|
-
|
201
|
-
test "generate should add label for entities" do
|
219
|
+
|
220
|
+
test "generate should add record label for entities" do
|
221
|
+
RailsERD.options.markup = false
|
202
222
|
create_model "Foo", :bar => :references do
|
203
223
|
belongs_to :bar
|
204
224
|
end
|
205
225
|
create_model "Bar"
|
206
|
-
|
226
|
+
assert_equal %Q("Bar"), find_dot_node(diagram, "m_Bar")[:label].to_gv
|
207
227
|
end
|
208
228
|
|
209
|
-
test "generate should add attributes to entity labels" do
|
229
|
+
test "generate should add attributes to entity html labels" do
|
230
|
+
RailsERD.options.markup = true
|
210
231
|
create_model "Foo", :bar => :references do
|
211
232
|
belongs_to :bar
|
212
233
|
end
|
213
234
|
create_model "Bar", :column => :string
|
214
|
-
assert_match %r{<\w+.*?>column <\w+.*?>string</\w+.*?>}, find_dot_node(diagram, "
|
235
|
+
assert_match %r{<\w+.*?>column <\w+.*?>string</\w+.*?>}, find_dot_node(diagram, "m_Bar")[:label].to_gv
|
236
|
+
end
|
237
|
+
|
238
|
+
test "generate should add attributes to entity record labels" do
|
239
|
+
RailsERD.options.markup = false
|
240
|
+
create_model "Foo", :bar => :references do
|
241
|
+
belongs_to :bar
|
242
|
+
end
|
243
|
+
create_model "Bar", :column => :string, :column_two => :boolean
|
244
|
+
assert_equal %Q("Bar|column (string)\\ncolumn_two (boolean)\\n"), find_dot_node(diagram, "m_Bar")[:label].to_gv
|
215
245
|
end
|
216
246
|
|
217
247
|
test "generate should not add any attributes to entity labels if attributes is set to false" do
|
@@ -219,35 +249,55 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
219
249
|
create_model "Lid", :jar => :references do
|
220
250
|
belongs_to :jar
|
221
251
|
end
|
222
|
-
assert_no_match %r{contents}, find_dot_node(diagram(:attributes => false), "
|
252
|
+
assert_no_match %r{contents}, find_dot_node(diagram(:attributes => false), "m_Jar")[:label].to_gv
|
223
253
|
end
|
224
254
|
|
225
|
-
test "
|
226
|
-
|
227
|
-
|
255
|
+
test "node html labels should have direction reversing braces for vertical orientation" do
|
256
|
+
RailsERD.options.markup = true
|
257
|
+
create_model "Book", :author => :references do
|
258
|
+
belongs_to :author
|
228
259
|
end
|
229
|
-
create_model "
|
230
|
-
|
260
|
+
create_model "Author", :name => :string
|
261
|
+
assert_match %r(\A<\{\s*<.*\|.*>\s*\}>\Z)m, find_dot_node(diagram(:orientation => :vertical), "m_Author")[:label].to_gv
|
262
|
+
end
|
263
|
+
|
264
|
+
test "node html labels should not have direction reversing braces for horizontal orientation" do
|
265
|
+
RailsERD.options.markup = true
|
266
|
+
create_model "Book", :author => :references do
|
267
|
+
belongs_to :author
|
231
268
|
end
|
232
|
-
|
269
|
+
create_model "Author", :name => :string
|
270
|
+
assert_match %r(\A<\s*<.*\|.*>\s*>\Z)m, find_dot_node(diagram(:orientation => :horizontal), "m_Author")[:label].to_gv
|
233
271
|
end
|
234
|
-
|
235
|
-
test "node
|
272
|
+
|
273
|
+
test "node record labels should have direction reversing braces for vertical orientation" do
|
274
|
+
RailsERD.options.markup = false
|
236
275
|
create_model "Book", :author => :references do
|
237
276
|
belongs_to :author
|
238
277
|
end
|
239
278
|
create_model "Author", :name => :string
|
240
|
-
assert_match %r(\A
|
279
|
+
assert_match %r(\A"\{\w+|.*\}"\Z)m, find_dot_node(diagram(:orientation => :vertical), "m_Author")[:label].to_gv
|
241
280
|
end
|
242
281
|
|
243
|
-
test "node
|
282
|
+
test "node record labels should not have direction reversing braces for horizontal orientation" do
|
283
|
+
RailsERD.options.markup = false
|
244
284
|
create_model "Book", :author => :references do
|
245
285
|
belongs_to :author
|
246
286
|
end
|
247
287
|
create_model "Author", :name => :string
|
248
|
-
assert_match %r(\A
|
288
|
+
assert_match %r(\A"\w+|.*"\Z)m, find_dot_node(diagram(:orientation => :horizontal), "m_Author")[:label].to_gv
|
249
289
|
end
|
250
|
-
|
290
|
+
|
291
|
+
test "generate should create edge for each relationship" do
|
292
|
+
create_model "Foo", :bar => :references do
|
293
|
+
belongs_to :bar
|
294
|
+
end
|
295
|
+
create_model "Bar", :foo => :references do
|
296
|
+
belongs_to :foo
|
297
|
+
end
|
298
|
+
assert_equal [["m_Bar", "m_Foo"], ["m_Foo", "m_Bar"]], find_dot_node_pairs(diagram).sort
|
299
|
+
end
|
300
|
+
|
251
301
|
test "generate should create edge to generalized entity if polymorphism is true" do
|
252
302
|
create_model "Cannon", :defensible => :references do
|
253
303
|
belongs_to :defensible, :polymorphic => true
|
@@ -258,7 +308,7 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
258
308
|
create_model "Galleon" do
|
259
309
|
has_many :cannons, :as => :defensible
|
260
310
|
end
|
261
|
-
assert_equal [["
|
311
|
+
assert_equal [["m_Defensible", "m_Cannon"], ["m_Defensible", "m_Galleon"], ["m_Defensible", "m_Stronghold"]],
|
262
312
|
find_dot_node_pairs(diagram(:polymorphism => true)).sort
|
263
313
|
end
|
264
314
|
|
@@ -272,9 +322,9 @@ class GraphvizTest < ActiveSupport::TestCase
|
|
272
322
|
create_model "Galleon" do
|
273
323
|
has_many :cannons, :as => :defensible
|
274
324
|
end
|
275
|
-
assert_equal [["
|
325
|
+
assert_equal [["m_Galleon", "m_Cannon"], ["m_Stronghold", "m_Cannon"]], find_dot_node_pairs(diagram).sort
|
276
326
|
end
|
277
|
-
|
327
|
+
|
278
328
|
# Simple notation style ====================================================
|
279
329
|
test "generate should use no style for one to one cardinalities with simple notation" do
|
280
330
|
create_one_to_one_assoc_domain
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-erd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 4
|
8
|
-
- 3
|
9
|
-
version: 0.4.3
|
4
|
+
prerelease:
|
5
|
+
version: 0.4.4
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Rolf Timmermans
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-03-22 00:00:00 +01:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -24,9 +20,6 @@ dependencies:
|
|
24
20
|
requirements:
|
25
21
|
- - ~>
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 3
|
29
|
-
- 0
|
30
23
|
version: "3.0"
|
31
24
|
type: :runtime
|
32
25
|
prerelease: false
|
@@ -38,9 +31,6 @@ dependencies:
|
|
38
31
|
requirements:
|
39
32
|
- - ~>
|
40
33
|
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 3
|
43
|
-
- 0
|
44
34
|
version: "3.0"
|
45
35
|
type: :runtime
|
46
36
|
prerelease: false
|
@@ -52,109 +42,65 @@ dependencies:
|
|
52
42
|
requirements:
|
53
43
|
- - ~>
|
54
44
|
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 0
|
57
|
-
- 9
|
58
|
-
- 18
|
59
45
|
version: 0.9.18
|
60
46
|
type: :runtime
|
61
47
|
prerelease: false
|
62
48
|
version_requirements: *id003
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: rake
|
65
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
|
-
requirements:
|
68
|
-
- - ">="
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
segments:
|
71
|
-
- 0
|
72
|
-
version: "0"
|
73
|
-
type: :development
|
74
|
-
prerelease: false
|
75
|
-
version_requirements: *id004
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
name: bundler
|
78
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
|
-
requirements:
|
81
|
-
- - ~>
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
segments:
|
84
|
-
- 1
|
85
|
-
- 0
|
86
|
-
- 0
|
87
|
-
version: 1.0.0
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: *id005
|
91
49
|
- !ruby/object:Gem::Dependency
|
92
50
|
name: jeweler
|
93
|
-
requirement: &
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
94
52
|
none: false
|
95
53
|
requirements:
|
96
54
|
- - ~>
|
97
55
|
- !ruby/object:Gem::Version
|
98
|
-
segments:
|
99
|
-
- 1
|
100
|
-
- 5
|
101
|
-
- 2
|
102
56
|
version: 1.5.2
|
103
57
|
type: :development
|
104
58
|
prerelease: false
|
105
|
-
version_requirements: *
|
59
|
+
version_requirements: *id004
|
106
60
|
- !ruby/object:Gem::Dependency
|
107
61
|
name: sqlite3
|
108
|
-
requirement: &
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
109
63
|
none: false
|
110
64
|
requirements:
|
111
65
|
- - ">="
|
112
66
|
- !ruby/object:Gem::Version
|
113
|
-
segments:
|
114
|
-
- 0
|
115
67
|
version: "0"
|
116
68
|
type: :development
|
117
69
|
prerelease: false
|
118
|
-
version_requirements: *
|
70
|
+
version_requirements: *id005
|
119
71
|
- !ruby/object:Gem::Dependency
|
120
72
|
name: jdbc-sqlite3
|
121
|
-
requirement: &
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
122
74
|
none: false
|
123
75
|
requirements:
|
124
76
|
- - ">="
|
125
77
|
- !ruby/object:Gem::Version
|
126
|
-
segments:
|
127
|
-
- 0
|
128
78
|
version: "0"
|
129
79
|
type: :development
|
130
80
|
prerelease: false
|
131
|
-
version_requirements: *
|
81
|
+
version_requirements: *id006
|
132
82
|
- !ruby/object:Gem::Dependency
|
133
83
|
name: activerecord-jdbc-adapter
|
134
|
-
requirement: &
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
135
85
|
none: false
|
136
86
|
requirements:
|
137
87
|
- - ">="
|
138
88
|
- !ruby/object:Gem::Version
|
139
|
-
segments:
|
140
|
-
- 0
|
141
89
|
version: "0"
|
142
90
|
type: :development
|
143
91
|
prerelease: false
|
144
|
-
version_requirements: *
|
92
|
+
version_requirements: *id007
|
145
93
|
- !ruby/object:Gem::Dependency
|
146
94
|
name: jruby-openssl
|
147
|
-
requirement: &
|
95
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
148
96
|
none: false
|
149
97
|
requirements:
|
150
98
|
- - ">="
|
151
99
|
- !ruby/object:Gem::Version
|
152
|
-
segments:
|
153
|
-
- 0
|
154
100
|
version: "0"
|
155
101
|
type: :development
|
156
102
|
prerelease: false
|
157
|
-
version_requirements: *
|
103
|
+
version_requirements: *id008
|
158
104
|
description: Automatically generate an entity-relationship diagram (ERD) for your Rails models.
|
159
105
|
email: r.timmermans@voormedia.com
|
160
106
|
executables: []
|
@@ -165,6 +111,7 @@ extra_rdoc_files:
|
|
165
111
|
- LICENSE
|
166
112
|
- README.md
|
167
113
|
files:
|
114
|
+
- .gemtest
|
168
115
|
- CHANGES.rdoc
|
169
116
|
- Gemfile
|
170
117
|
- Gemfile.lock
|
@@ -176,7 +123,8 @@ files:
|
|
176
123
|
- lib/rails_erd.rb
|
177
124
|
- lib/rails_erd/diagram.rb
|
178
125
|
- lib/rails_erd/diagram/graphviz.rb
|
179
|
-
- lib/rails_erd/diagram/templates/node.erb
|
126
|
+
- lib/rails_erd/diagram/templates/node.html.erb
|
127
|
+
- lib/rails_erd/diagram/templates/node.record.erb
|
180
128
|
- lib/rails_erd/domain.rb
|
181
129
|
- lib/rails_erd/domain/attribute.rb
|
182
130
|
- lib/rails_erd/domain/entity.rb
|
@@ -210,21 +158,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
210
158
|
requirements:
|
211
159
|
- - ">="
|
212
160
|
- !ruby/object:Gem::Version
|
213
|
-
segments:
|
214
|
-
- 0
|
215
161
|
version: "0"
|
216
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
163
|
none: false
|
218
164
|
requirements:
|
219
165
|
- - ">="
|
220
166
|
- !ruby/object:Gem::Version
|
221
|
-
segments:
|
222
|
-
- 0
|
223
167
|
version: "0"
|
224
168
|
requirements: []
|
225
169
|
|
226
170
|
rubyforge_project: rails-erd
|
227
|
-
rubygems_version: 1.
|
171
|
+
rubygems_version: 1.5.2
|
228
172
|
signing_key:
|
229
173
|
specification_version: 3
|
230
174
|
summary: Entity-relationship diagram for your Rails models.
|