rails-erd 1.4.4 → 1.4.5

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: f023a0096d3737d00670e9d713e766855426f578
4
- data.tar.gz: ebb61ceddc34a6d03ebb7157688335a41321ecc5
3
+ metadata.gz: e936dc2f84cd3264efc39a2835403813003e1422
4
+ data.tar.gz: e1da2f8dbdbcc4da4a13826242db83c27bcfbf1c
5
5
  SHA512:
6
- metadata.gz: 297d5f2899e0fbe308fe461c7304480efd00c10f904d58f5af14ee01b5ce2708167f49e4f366ff93ee9ac5e21b316da34d7b118c36a107965af07d0a3d404774
7
- data.tar.gz: e757d823c41be9a73cf83b7e4485c6e596ece8874ac3e80de697a7536db6eab14906ac8a434936c99b94f83c515c2e0e2e16b0906870fd0a69185dcce75a679b
6
+ metadata.gz: 9a4d0f1753d7411500afdf241d6941b042f92a40c012ac7b75362cd8710bd7a4755ccb4fad41aec1d4ce93399474eec875293779a6596ced807f9f25452a3d4a
7
+ data.tar.gz: 7190fca96730605ae0a8f3fe2aefd9c21a6d4818722d388d8ba3fa278f89bdc29db93bbbb849f6cacb1e0af218eb0bbf58489cfc46696a4bfd996519917b90ce
data/README.md CHANGED
@@ -38,7 +38,8 @@ See the [installation instructions](http://voormedia.github.io/rails-erd/install
38
38
 
39
39
  ### Configuration
40
40
 
41
- 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):
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](http://voormedia.github.io/rails-erd/customise.html) can be found in Rails ERD's project documentation.
42
43
 
43
44
  ```
44
45
  attributes:
@@ -2,5 +2,5 @@
2
2
  # NOTE: are sensitive to local FS writes, and besides -- it's just not proper
3
3
  # NOTE: to have a dev-mode tool do its thing in production.
4
4
  if Rails.env.development?
5
- Erd.load_tasks
5
+ RailsERD::Engine.load_tasks
6
6
  end
@@ -1,5 +1,6 @@
1
1
  require "active_support/ordered_options"
2
2
  require "rails_erd/railtie" if defined? Rails
3
+ require "rails_erd/engine" if defined? Rails
3
4
  require "rails_erd/config"
4
5
 
5
6
  # Welcome to the API documentation of Rails ERD. If you wish to extend or
@@ -16,7 +16,7 @@ Choice.options do
16
16
 
17
17
  option :attributes do
18
18
  long "--attributes=TYPE,..."
19
- desc "Attribute groups to display: content, primary_keys, foreign_keys, timestamps and/or inheritance."
19
+ desc "Attribute groups to display: false, content, primary_keys, foreign_keys, timestamps and/or inheritance."
20
20
  end
21
21
 
22
22
  option :orientation do
@@ -122,7 +122,15 @@ module RailsERD
122
122
  end
123
123
 
124
124
  def check_model_validity(model)
125
- model.abstract_class? or model.table_exists? or raise "table #{model.table_name} does not exist"
125
+ if model.abstract_class? || model.table_exists?
126
+ if model.name.nil?
127
+ raise "is anonymous class"
128
+ else
129
+ true
130
+ end
131
+ else
132
+ raise "table #{model.table_name} does not exist"
133
+ end
126
134
  rescue => e
127
135
  warn "Ignoring invalid model #{model.name} (#{e.message})"
128
136
  end
@@ -88,6 +88,12 @@ module RailsERD
88
88
  @model.inheritance_column == name
89
89
  end
90
90
 
91
+ # Method allows false to be set as an attributes option when making custom graphs.
92
+ # It rejects all attributes when called from Diagram#filtered_attributes method
93
+ def false?
94
+ false
95
+ end
96
+
91
97
  # Returns +true+ if this attribute is one of the standard 'magic' Rails
92
98
  # timestamp columns, being +created_at+, +updated_at+, +created_on+ or
93
99
  # +updated_on+.
@@ -0,0 +1,4 @@
1
+ module RailsERD
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -1,4 +1,4 @@
1
1
  module RailsERD
2
- VERSION = "1.4.4"
2
+ VERSION = "1.4.5"
3
3
  BANNER = "RailsERD #{VERSION}"
4
4
  end
@@ -2,6 +2,7 @@ attributes:
2
2
  - content
3
3
  - foreign_key
4
4
  - inheritance
5
+ - false
5
6
  disconnected: true
6
7
  filename: erd
7
8
  filetype: pdf
@@ -2,6 +2,7 @@ attributes:
2
2
  - content
3
3
  - foreign_key
4
4
  - inheritance
5
+ - false
5
6
  disconnected: true
6
7
  filename: erd
7
8
  filetype: pdf
@@ -12,7 +12,7 @@ class ConfigTest < ActiveSupport::TestCase
12
12
  set_user_config_file_to("erdconfig.example")
13
13
 
14
14
  expected_hash = {
15
- attributes: [:content, :foreign_key, :inheritance],
15
+ attributes: [:content, :foreign_key, :inheritance, :false],
16
16
  disconnected: true,
17
17
  filename: "erd",
18
18
  filetype: :pdf,
@@ -34,7 +34,7 @@ class ConfigTest < ActiveSupport::TestCase
34
34
  set_user_config_file_to("erdconfig.exclude.example")
35
35
 
36
36
  expected_hash = {
37
- attributes: [:content, :foreign_key, :inheritance],
37
+ attributes: [:content, :foreign_key, :inheritance, :false],
38
38
  disconnected: true,
39
39
  filename: "erd",
40
40
  filetype: :pdf,
@@ -310,6 +310,14 @@ class DiagramTest < ActiveSupport::TestCase
310
310
  assert_equal %w{id}, retrieve_attribute_lists(:attributes => [:primary_keys])[Book].map(&:name)
311
311
  end
312
312
 
313
+ test "generate should yield [] if attributes = false" do
314
+ create_model "Book", :title => :string
315
+ create_model "Page", :book => :references do
316
+ belongs_to :book
317
+ end
318
+ assert_equal [], retrieve_attribute_lists(:attributes => [:false])[Book].map(&:name)
319
+ end
320
+
313
321
  test "generate should yield foreign key attributes if included" do
314
322
  create_model "Book", :author => :references do
315
323
  belongs_to :author
@@ -72,6 +72,17 @@ class DomainTest < ActiveSupport::TestCase
72
72
  assert_equal ["Palace", "Structure"], Domain.generate.entities.collect(&:name)
73
73
  end
74
74
 
75
+ test "entities should exclude models without a class name" do
76
+ create_models "Foo", "Bar"
77
+ Foo.stubs(:name).returns(nil)
78
+
79
+ begin
80
+ assert_equal ["Bar"], Domain.generate.entities.collect(&:name)
81
+ ensure
82
+ Foo.unstub(:name) # required so `reset_domain` works
83
+ end
84
+ end
85
+
75
86
  # Relationship processing ==================================================
76
87
  test "relationships should return empty array for empty domain" do
77
88
  assert_equal [], Domain.generate.relationships
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.4.4
4
+ version: 1.4.5
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-10-15 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -95,6 +95,7 @@ files:
95
95
  - lib/rails_erd/domain/relationship.rb
96
96
  - lib/rails_erd/domain/relationship/cardinality.rb
97
97
  - lib/rails_erd/domain/specialization.rb
98
+ - lib/rails_erd/engine.rb
98
99
  - lib/rails_erd/railtie.rb
99
100
  - lib/rails_erd/tasks.rake
100
101
  - lib/rails_erd/version.rb