rails-erd 1.2.2 → 1.3.0

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
  SHA1:
3
- metadata.gz: 4ab56fc63661711b90e26347a430db4ade715904
4
- data.tar.gz: 33656498d2b249fe4f8ab7cf462f70e9e85b3fed
3
+ metadata.gz: 7ada96cc38a16ade059a334c1b0c228f1d950799
4
+ data.tar.gz: 4ce8b31b96b63dd9da6651d932787d78067fbc74
5
5
  SHA512:
6
- metadata.gz: aec8e77aa5ba7c424ae2f3322d35c944b5f20f41e07aadeff9da0c606414dddc0d70f05457b0863d2c9c6693db25dce68573b7e7a2fe65194e3e3a9c07bb1c47
7
- data.tar.gz: 09ebb3782261d1ce42e628116288ccfc6360e2e2fd348a298e4490bc615175e022b7d9df7d6363dd41f1a306b43cfc54282772b24315f5b5bb97b0382ab1c254
6
+ metadata.gz: 05bebbfc35caa2f8db94a5fd444de5342d8fa1ebae29f5d954b7858b2a61ab9dccd7c48093e19dbac693584de9e41e0c50c1030fbd4b30e59e44e58a73838a0f
7
+ data.tar.gz: 8b6d762b352f2638e482deb1f8e2330af32a040a651264b70cee13d1bfbfce7dc594ede091d8a3df66954be5dc3b0c798e289c0eb64f2979a1f68b946aa6d110
data/README.md CHANGED
@@ -18,6 +18,12 @@ Here's an example entity-relationship diagram that was generated by Rails ERD:
18
18
  Browse the [gallery](http://voormedia.github.io/rails-erd/gallery.html) for more example diagrams.
19
19
 
20
20
 
21
+ Requirements
22
+ ---------------
23
+
24
+ * Ruby 1.9.3+
25
+ * ActiveRecord 3.x
26
+
21
27
  Getting started
22
28
  ---------------
23
29
 
@@ -67,7 +73,7 @@ About Rails ERD
67
73
 
68
74
  Rails ERD was created by Rolf Timmermans (r.timmermans *at* voormedia.com)
69
75
 
70
- Copyright 2010-2014 Voormedia - [www.voormedia.com](http://www.voormedia.com/)
76
+ Copyright 2010-2015 Voormedia - [www.voormedia.com](http://www.voormedia.com/)
71
77
 
72
78
 
73
79
  License
@@ -1,3 +1,5 @@
1
+ require "yaml"
2
+
1
3
  module RailsERD
2
4
  class Config
3
5
  USER_WIDE_CONFIG_FILE = File.expand_path(".erdconfig", ENV["HOME"])
@@ -43,7 +43,10 @@ module RailsERD
43
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
- NODE_LABEL_TEMPLATES = { :html => "node.html.erb", :record => "node.record.erb" } # @private :nodoc:
46
+ NODE_LABEL_TEMPLATES = {
47
+ html: "node.html.erb",
48
+ record: "node.record.erb"
49
+ } # @private :nodoc:
47
50
 
48
51
  NODE_WIDTH = 130 # @private :nodoc:
49
52
 
@@ -51,36 +54,35 @@ module RailsERD
51
54
 
52
55
  # Default graph attributes.
53
56
  GRAPH_ATTRIBUTES = {
54
- :rankdir => :LR,
55
- :ranksep => 0.5,
56
- :nodesep => 0.4,
57
- :pad => "0.4,0.4",
58
- :margin => "0,0",
59
- :concentrate => true,
60
- :labelloc => :t,
61
- :fontsize => 13,
62
- :fontname => FONTS[:bold]
57
+ rankdir: :LR,
58
+ ranksep: 0.5,
59
+ nodesep: 0.4,
60
+ pad: "0.4,0.4",
61
+ margin: "0,0",
62
+ concentrate: true,
63
+ labelloc: :t,
64
+ fontsize: 13,
65
+ fontname: FONTS[:bold]
63
66
  }
64
67
 
65
68
  # Default node attributes.
66
69
  NODE_ATTRIBUTES = {
67
- :shape => "Mrecord",
68
- :fontsize => 10,
69
- :fontname => FONTS[:normal],
70
- :margin => "0.07,0.05",
71
- :penwidth => 1.0
70
+ shape: "Mrecord",
71
+ fontsize: 10,
72
+ fontname: FONTS[:normal],
73
+ margin: "0.07,0.05",
74
+ penwidth: 1.0
72
75
  }
73
76
 
74
77
  # Default edge attributes.
75
78
  EDGE_ATTRIBUTES = {
76
- :fontname => FONTS[:normal],
77
- :fontsize => 8,
78
- :dir => :both,
79
- :arrowsize => 0.9,
80
- :penwidth => 1.0,
81
- :labelangle => 32,
82
- :labeldistance => 1.8,
83
- :fontsize => 7
79
+ fontname: FONTS[:normal],
80
+ fontsize: 7,
81
+ dir: :both,
82
+ arrowsize: 0.9,
83
+ penwidth: 1.0,
84
+ labelangle: 32,
85
+ labeldistance: 1.8,
84
86
  }
85
87
 
86
88
  module Simple
@@ -101,7 +103,10 @@ module RailsERD
101
103
  end
102
104
 
103
105
  def specialization_style(specialization)
104
- { :color => :grey60, :arrowtail => :onormal, :arrowhead => :none, :arrowsize => 1.2 }
106
+ { color: :grey60,
107
+ arrowtail: :onormal,
108
+ arrowhead: :none,
109
+ arrowsize: 1.2 }
105
110
  end
106
111
  end
107
112
 
@@ -194,10 +199,12 @@ module RailsERD
194
199
  graph.output(filetype => filename.gsub(/\s/,"\\ "))
195
200
  filename
196
201
  rescue RuntimeError => e
197
- raise "Saving diagram failed!\nGraphviz produced errors. Verify it has support for filetype=#{options.filetype}, or use filetype=dot." <<
198
- "\nOriginal error: #{e.message.split("\n").last}"
202
+ raise "Saving diagram failed!\nGraphviz produced errors. Verify it " +
203
+ "has support for filetype=#{options.filetype}, or use " +
204
+ "filetype=dot.\nOriginal error: #{e.message.split("\n").last}"
199
205
  rescue StandardError => e
200
- raise "Saving diagram failed!\nVerify that Graphviz is installed and in your path, or use filetype=dot."
206
+ raise "Saving diagram failed!\nVerify that Graphviz is installed " +
207
+ "and in your path, or use filetype=dot."
201
208
  end
202
209
  end
203
210
 
@@ -267,7 +274,7 @@ module RailsERD
267
274
 
268
275
  def relationship_options(relationship)
269
276
  relationship_style(relationship).tap do |options|
270
- # Edges with a higher weight are optimised to be shorter and straighter.
277
+ # Edges with a higher weight are optimized to be shorter and straighter.
271
278
  options[:weight] = relationship.strength
272
279
 
273
280
  # Indirect relationships should not influence node ranks.
@@ -114,7 +114,7 @@ module RailsERD
114
114
  end
115
115
 
116
116
  def models
117
- @models ||= @source_models.select { |model| check_model_validity(model) }
117
+ @models ||= @source_models.select { |model| check_model_validity(model) }.reject { |model| check_habtm_model(model) }
118
118
  end
119
119
 
120
120
  def associations
@@ -145,5 +145,9 @@ module RailsERD
145
145
  def association_description(association)
146
146
  "#{association.name.inspect} on #{association.active_record}"
147
147
  end
148
+
149
+ def check_habtm_model(model)
150
+ model.name.start_with?("HABTM_")
151
+ end
148
152
  end
149
153
  end
@@ -49,7 +49,7 @@ module RailsERD
49
49
 
50
50
  # Returns +true+ if this attribute is the primary key of the entity.
51
51
  def primary_key?
52
- column.primary
52
+ @model.primary_key.to_s == name.to_s
53
53
  end
54
54
 
55
55
  # Returns +true+ if this attribute is used as a foreign key for any
@@ -100,12 +100,14 @@ module RailsERD
100
100
  # Returns any non-standard limit for this attribute. If a column has no
101
101
  # limit or uses a default database limit, this method returns +nil+.
102
102
  def limit
103
- column.limit.to_i if column.limit != native_type[:limit] and column.limit.respond_to?(:to_i)
103
+ return column.limit.to_i if column.limit != native_type[:limit] and column.limit.respond_to?(:to_i)
104
+ column.precision.to_i if column.precision != native_type[:precision] and column.precision.respond_to?(:to_i)
104
105
  end
105
106
 
106
107
  # Returns any non-standard scale for this attribute (decimal types only).
107
108
  def scale
108
- column.scale.to_i if column.scale != native_type[:scale] and column.scale.respond_to?(:to_i)
109
+ return column.scale.to_i if column.scale != native_type[:scale] and column.scale.respond_to?(:to_i)
110
+ 0 if column.precision
109
111
  end
110
112
 
111
113
  # Returns a string that describes the limit for this attribute, such as
@@ -1,4 +1,4 @@
1
1
  module RailsERD
2
- VERSION = "1.2.2"
2
+ VERSION = "1.3.0"
3
3
  BANNER = "RailsERD #{VERSION}"
4
4
  end
data/test/test_helper.rb CHANGED
@@ -2,7 +2,11 @@ require "rubygems"
2
2
  require "bundler/setup"
3
3
 
4
4
  require "active_record"
5
- require "test/unit"
5
+ if ActiveSupport::VERSION::MAJOR >= 4
6
+ require "minitest/autorun"
7
+ else
8
+ require "test/unit"
9
+ end
6
10
  require "rails_erd/domain"
7
11
 
8
12
  ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => ":memory:"
@@ -127,13 +131,15 @@ class ActiveSupport::TestCase
127
131
  RailsERD::Config.send :remove_const, :CURRENT_CONFIG_FILE
128
132
  RailsERD::Config.send :const_set, :CURRENT_CONFIG_FILE,
129
133
  File.expand_path("../../examples/erdconfig.not_exists", __FILE__)
134
+
135
+ RailsERD.options = RailsERD.default_options.merge(Config.load)
130
136
  end
131
137
 
132
138
  def reset_domain
133
139
  if defined? ActiveRecord
134
140
  ActiveRecord::Base.descendants.each do |model|
135
141
  model.reset_column_information
136
- Object.send :remove_const, model.name.to_sym
142
+ Object.send :remove_const, model.name.to_sym if Object.const_defined? model.name.to_sym
137
143
  end
138
144
  ActiveRecord::Base.connection.tables.each do |table|
139
145
  ActiveRecord::Base.connection.drop_table table
@@ -1,14 +1,7 @@
1
1
  require File.expand_path("../test_helper", File.dirname(__FILE__))
2
+ require "rails_erd/diagram"
2
3
 
3
4
  class DiagramTest < ActiveSupport::TestCase
4
- def setup
5
- load "rails_erd/diagram.rb"
6
- end
7
-
8
- def teardown
9
- RailsERD.send :remove_const, :Diagram
10
- end
11
-
12
5
  def retrieve_entities(options = {})
13
6
  klass = Class.new(Diagram)
14
7
  [].tap do |entities|
@@ -1,15 +1,14 @@
1
1
  require File.expand_path("../test_helper", File.dirname(__FILE__))
2
+ require "rails_erd/diagram/graphviz"
2
3
 
3
4
  class GraphvizTest < ActiveSupport::TestCase
4
5
  def setup
5
6
  RailsERD.options.filetype = :png
6
7
  RailsERD.options.warn = false
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
- RailsERD::Diagram.send :remove_const, :Graphviz rescue nil
13
12
  end
14
13
 
15
14
  def diagram(options = {})
@@ -14,7 +14,6 @@ class RakeTaskTest < ActiveSupport::TestCase
14
14
 
15
15
  def teardown
16
16
  FileUtils.rm "erd.dot" rescue nil
17
- RailsERD::Diagram.send :remove_const, :Graphviz rescue nil
18
17
  end
19
18
 
20
19
  define_method :create_app do
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-erd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rolf Timmermans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-20 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.2'
41
41
  - !ruby/object:Gem::Dependency