rails-erd 1.3.1 → 1.4.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: 7e5205eb093cf7ca1ffd731eb201853c1b4134d3
4
- data.tar.gz: 04deb363195d35173242a3479176013eeb1b5402
3
+ metadata.gz: d754b17dc91d089d0e6bbccfce2bf4d269db3b7b
4
+ data.tar.gz: f87e6ed6a771e3956a44edb77aba932e626203a2
5
5
  SHA512:
6
- metadata.gz: b9e3a914f4eefec4a97304d2a621b0dd3105741401ab1438db75292ecfc50f968aeb6e7f36a0937088f6152ed355692ee53b5585f0090d97e5b800aa06c39dce
7
- data.tar.gz: 11b65a72efea78e56f6bf25d1363d3ef1fe94336f8556e266480216aa573d27784aae16784cef7f79d1860e34375fef6906f2a9c352ae2b4c73ec067db2dc904
6
+ metadata.gz: 278db5cb89bda7905a7ba8fda35cdfd5466fafd4231bbf86272a9463a088a015be01daee8033432bfe1a1fddad872e6728fe1b75e37ad7b9e78c433bd3974c91
7
+ data.tar.gz: c02232f93661c164eefdbc04289569e3a6579ec1146271e5ce94ece1cbdcecb8dacc3b2f86f2c67ea2c0a05210a052869a70c09a6fc7c71138ef9e7916382223
data/README.md CHANGED
@@ -1,7 +1,8 @@
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
4
 
4
- [Rails ERD](http://voormedia.github.io/rails-erd/) is a Rails plugin that allows you to easily generate a diagram based on your 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.
5
+ [Rails ERD](http://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.
5
6
 
6
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.
7
8
 
@@ -26,11 +26,11 @@ module RailsERD
26
26
  if use_os_x_fonts?
27
27
  { normal: "ArialMT",
28
28
  bold: "Arial BoldMT",
29
- italic: "Arail ItalicMT" }
29
+ italic: "Arial ItalicMT" }
30
30
  else
31
31
  { normal: "Arial",
32
32
  bold: "Arial Bold",
33
- italic: "Arail Italic" }
33
+ italic: "Arial Italic" }
34
34
  end
35
35
  end
36
36
 
@@ -194,9 +194,10 @@ module RailsERD
194
194
 
195
195
  save do
196
196
  raise "Saving diagram failed!\nOutput directory '#{File.dirname(filename)}' does not exist." unless File.directory?(File.dirname(filename))
197
+
197
198
  begin
198
199
  # GraphViz doesn't like spaces in the filename
199
- graph.output(filetype => filename.gsub(/\s/,"\\ "))
200
+ graph.output(filetype => filename.gsub(/\s/,"_"))
200
201
  filename
201
202
  rescue RuntimeError => e
202
203
  raise "Saving diagram failed!\nGraphviz produced errors. Verify it " +
@@ -63,17 +63,10 @@ module RailsERD
63
63
 
64
64
  def initialize(domain, associations) # @private :nodoc:
65
65
  @domain = domain
66
- @reverse_associations, @forward_associations = *unless any_habtm?(associations)
67
- associations.partition(&:belongs_to?)
68
- else
69
- # Many-to-many associations don't have a clearly defined direction.
70
- # We sort by name and use the first model as the source.
71
- source = associations.map(&:active_record).sort_by(&:name).first
72
- associations.partition { |association| association.active_record != source }
73
- end
66
+ @reverse_associations, @forward_associations = partition_associations(associations)
74
67
 
75
68
  assoc = @forward_associations.first || @reverse_associations.first
76
- @source = @domain.entity_by_name(self.class.send(:association_owner, assoc))
69
+ @source = @domain.entity_by_name(self.class.send(:association_owner, assoc))
77
70
  @destination = @domain.entity_by_name(self.class.send(:association_target, assoc))
78
71
  @source, @destination = @destination, @source if assoc.belongs_to?
79
72
  end
@@ -152,6 +145,17 @@ module RailsERD
152
145
 
153
146
  private
154
147
 
148
+ def partition_associations(associations)
149
+ if any_habtm?(associations)
150
+ # Many-to-many associations don't have a clearly defined direction.
151
+ # We sort by name and use the first model as the source.
152
+ source = associations.map(&:active_record).sort_by(&:name).first
153
+ associations.partition { |association| association.active_record != source }
154
+ else
155
+ associations.partition(&:belongs_to?)
156
+ end
157
+ end
158
+
155
159
  def associations_range(associations, absolute_max)
156
160
  # The minimum of the range is the maximum value of each association
157
161
  # minimum. If there is none, it is zero by definition. The reasoning is
@@ -73,12 +73,18 @@ module RailsERD
73
73
  def name
74
74
  ""
75
75
  end
76
+ def generalized?
77
+ false
78
+ end
76
79
  end
77
80
 
78
81
  class NullGeneralized
79
82
  def name
80
83
  ""
81
84
  end
85
+ def generalized?
86
+ true
87
+ end
82
88
  end
83
89
  end
84
90
  end
@@ -1,4 +1,4 @@
1
1
  module RailsERD
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  BANNER = "RailsERD #{VERSION}"
4
4
  end
data/test/test_helper.rb CHANGED
@@ -34,7 +34,7 @@ class ActiveSupport::TestCase
34
34
  def add_column(*args)
35
35
  ActiveRecord::Schema.instance_eval do
36
36
  suppress_messages do
37
- add_column *args
37
+ add_column(*args)
38
38
  end
39
39
  end
40
40
  ActiveRecord::Base.clear_cache!
@@ -94,7 +94,7 @@ class GraphvizTest < ActiveSupport::TestCase
94
94
  test "create should create output for filenames that have spaces" do
95
95
  create_simple_domain
96
96
  Diagram::Graphviz.create :filename => "erd with spaces"
97
- assert File.exists?("erd with spaces.png")
97
+ assert File.exists?("erd_with_spaces.png")
98
98
  end
99
99
 
100
100
  test "create should write to file with dot extension without requiring graphviz" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-erd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.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: 2015-03-03 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.4
47
+ version: '1.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.0.4
54
+ version: '1.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: choice
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.6
61
+ version: 0.2.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.6
68
+ version: 0.2.0
69
69
  description: Automatically generate an entity-relationship diagram (ERD) for your
70
70
  Rails models.
71
71
  email:
@@ -121,15 +121,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 1.9.3
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - ">="
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubyforge_project: rails-erd
132
- rubygems_version: 2.4.5
131
+ rubyforge_project:
132
+ rubygems_version: 2.4.6
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: Entity-relationship diagram for your Rails models.