rails-erd 1.4.0 → 1.4.1

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: d754b17dc91d089d0e6bbccfce2bf4d269db3b7b
4
- data.tar.gz: f87e6ed6a771e3956a44edb77aba932e626203a2
3
+ metadata.gz: 537ccea2a689d7fc5eafcf6879b4f72f9a143c63
4
+ data.tar.gz: 22934779369b6203496dc48792b5442697131bfd
5
5
  SHA512:
6
- metadata.gz: 278db5cb89bda7905a7ba8fda35cdfd5466fafd4231bbf86272a9463a088a015be01daee8033432bfe1a1fddad872e6728fe1b75e37ad7b9e78c433bd3974c91
7
- data.tar.gz: c02232f93661c164eefdbc04289569e3a6579ec1146271e5ce94ece1cbdcecb8dacc3b2f86f2c67ea2c0a05210a052869a70c09a6fc7c71138ef9e7916382223
6
+ metadata.gz: 1539881900c1f05e0dbafbfba086dd4bcfee51a323c608b5f7d02b362d69818e9c7543a93e4a6d40f18443a243fefe2518fe944507983c466f7ca8724f1e01c3
7
+ data.tar.gz: 91502bc3daa15a4aff18bdd0cfd1b6993b1b8607f5aed5f5a224d4c36dfd99b5f1fc7d755a29242cdd9c14f726b2aff6fbc55eefcf8d402ee6a04de51cd37a6d
@@ -150,8 +150,8 @@ module RailsERD
150
150
 
151
151
  def filtered_entities
152
152
  @domain.entities.reject { |entity|
153
- options.exclude && entity.model && [options.exclude].flatten.include?(entity.name.to_s) or
154
- options.only && entity.model && ![options.only].flatten.include?(entity.name.to_s) or
153
+ options.exclude && entity.model && [options.exclude].flatten.include?(entity.name.to_sym) or
154
+ options.only && entity.model && ![options.only].flatten.include?(entity.name.to_sym) or
155
155
  !options.inheritance && entity.specialized? or
156
156
  !options.polymorphism && entity.generalized? or
157
157
  !options.disconnected && entity.disconnected?
@@ -14,13 +14,18 @@ module RailsERD
14
14
  attributes.sort! if RailsERD.options[:sort]
15
15
 
16
16
  if RailsERD.options[:prepend_primary]
17
- primary_key = ActiveRecord::Base.get_primary_key(model)
18
- primary = attributes.detect{ |column| column.name == primary_key }
17
+ attributes = prepend_primary(model, attributes)
18
+ end
19
+
20
+ attributes
21
+ end
22
+
23
+ def prepend_primary(model, attributes)
24
+ primary_key = ActiveRecord::Base.get_primary_key(model)
25
+ primary = attributes.index { |column| column.name == primary_key }
19
26
 
20
- if primary
21
- attributes.delete(primary)
22
- attributes.unshift(primary)
23
- end
27
+ if primary
28
+ attributes[primary], attributes[0] = attributes[0], attributes[primary]
24
29
  end
25
30
 
26
31
  attributes
@@ -8,7 +8,7 @@ namespace :erd do
8
8
  RailsERD.options[option.to_sym] = case ENV[option]
9
9
  when "true", "yes" then true
10
10
  when "false", "no" then false
11
- when /,/ then ENV[option].split(/\s*,\s*/).map(&:to_sym)
11
+ when /,/ then ENV[option].split(/\s*,\s*/)
12
12
  else ENV[option].to_sym
13
13
  end
14
14
  end
@@ -1,4 +1,4 @@
1
1
  module RailsERD
2
- VERSION = "1.4.0"
3
- BANNER = "RailsERD #{VERSION}"
2
+ VERSION = "1.4.1"
3
+ BANNER = "RailsERD #{VERSION}"
4
4
  end
data/test/test_helper.rb CHANGED
@@ -11,6 +11,10 @@ require "rails_erd/domain"
11
11
 
12
12
  ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => ":memory:"
13
13
 
14
+ if ActiveSupport::TestCase.respond_to?(:test_order=)
15
+ ActiveSupport::TestCase.test_order = :random
16
+ end
17
+
14
18
  class ActiveSupport::TestCase
15
19
  include RailsERD
16
20
 
@@ -44,8 +44,8 @@ class AttributeTest < ActiveSupport::TestCase
44
44
  assert_equal %w{id a}, Domain::Attribute.from_model(Domain.new, Foo).map(&:name)
45
45
  end
46
46
 
47
- test "from_model should return attributes with PK first if sort is false and prepend_primary is true" do
48
- RailsERD.options[:sort] = false
47
+ test "from_model should return attributes with PK first if prepend_primary is true" do
48
+ RailsERD.options[:sort] = true
49
49
  RailsERD.options[:prepend_primary] = true
50
50
 
51
51
  create_model "Foo"
@@ -126,27 +126,27 @@ class DiagramTest < ActiveSupport::TestCase
126
126
  test "generate should filter excluded entity" do
127
127
  create_model "Book"
128
128
  create_model "Author"
129
- assert_equal [Book], retrieve_entities(:exclude => ['Author']).map(&:model)
129
+ assert_equal [Book], retrieve_entities(:exclude => [:Author]).map(&:model)
130
130
  end
131
131
 
132
132
  test "generate should filter excluded entities" do
133
133
  create_model "Book"
134
134
  create_model "Author"
135
135
  create_model "Editor"
136
- assert_equal [Book], retrieve_entities(:exclude => ['Author', 'Editor']).map(&:model)
136
+ assert_equal [Book], retrieve_entities(:exclude => [:Author, :Editor]).map(&:model)
137
137
  end
138
138
 
139
139
  test "generate should include only specified entity" do
140
140
  create_model "Book"
141
141
  create_model "Author"
142
- assert_equal [Book], retrieve_entities(:only => ['Book']).map(&:model)
142
+ assert_equal [Book], retrieve_entities(:only => [:Book]).map(&:model)
143
143
  end
144
144
 
145
145
  test "generate should include only specified entities" do
146
146
  create_model "Book"
147
147
  create_model "Author"
148
148
  create_model "Editor"
149
- assert_equal [Author, Editor], retrieve_entities(:only => ['Author', 'Editor']).map(&:model)
149
+ assert_equal [Author, Editor], retrieve_entities(:only => [:Author, :Editor]).map(&:model)
150
150
  end
151
151
 
152
152
  test "generate should filter disconnected entities if disconnected is false" do
@@ -160,6 +160,6 @@ Error occurred while loading application: FooBar (RuntimeError)
160
160
  test "options task should set known array command line options" do
161
161
  ENV["attributes"] = "content,timestamps"
162
162
  Rake::Task["erd:options"].execute
163
- assert_equal [:content, :timestamps], RailsERD.options.attributes
163
+ assert_equal %w[content timestamps], RailsERD.options.attributes
164
164
  end
165
165
  end
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.0
4
+ version: 1.4.1
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-05-14 00:00:00.000000000 Z
11
+ date: 2015-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord