modaldiagrams 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
@@ -6,20 +6,6 @@ require 'modalsupport'
6
6
 
7
7
  module ModalDiagrams
8
8
 
9
- # Field type abbreviations
10
- TYPE = {
11
- :date=>'d',
12
- :datetime=>'dt',
13
- :timestamp=>'ts',
14
- :boolean=>'b',
15
- :integer=>'i',
16
- :string=>'s',
17
- :text=>'tx',
18
- :float=>'f',
19
- :decimal=>'d',
20
- :geometry=>'g'
21
- }
22
-
23
9
  class <<self
24
10
 
25
11
  def enable_clusters
@@ -57,7 +43,7 @@ module ModalDiagrams
57
43
  models.each do |cls|
58
44
  if cls.respond_to?(:reflect_on_all_associations) && ActiveRecord::Base.connection.table_exists?(cls.table_name)
59
45
  # Note: Don't use content_columns ignores columns ending with _id which I use for enum fields
60
- columns = cls.columns.reject { |c| c.primary || c.name =~ /(_count)$/ || c.name == cls.inheritance_column || c.name =~ /^(created_at|updated_at)$/ }.map{|c| "#{c.name} : #{TYPE[c.type]}"}
46
+ columns = cls.columns.reject { |c| c.primary || c.name =~ /(_count)$/ || c.name == cls.inheritance_column || c.name =~ /^(created_at|updated_at)$/ }.map{|c| field_spec(cfg, c)}
61
47
  columns_to_ignore = cls.reflect_on_all_associations.map{|a|
62
48
  cols = []
63
49
  if a.macro == :belongs_to
@@ -162,7 +148,7 @@ module ModalDiagrams
162
148
  cluster = ""
163
149
  end
164
150
  if cfg.sti_fields && sti_class.respond_to?(:fields_info) && sti_class.fields_info!=:omitted
165
- columns = sti_class.fields_info.map{|c| "#{c.name} : #{TYPE[c.type]}"}
151
+ columns = sti_class.fields_info.map{|c| field_spec(cfg, c)}
166
152
  columns = columns.to(cfg.max_attributes) + ['...'] if columns.size > cfg.max_attributes
167
153
  else
168
154
  columns = nil
@@ -330,6 +316,11 @@ module ModalDiagrams
330
316
  f.puts "}\n"
331
317
  end
332
318
 
319
+ def field_spec(cfg, c)
320
+ type = cfg.type_abbreviations[c.type] || c.type
321
+ "#{c.name} : #{type}"
322
+ end
323
+
333
324
  end
334
325
 
335
326
  end
@@ -14,7 +14,20 @@ module ModalDiagrams
14
14
  :sti_fields => true, # show fields of STI classes where declared if using modalfields
15
15
  :unified_polymorphic => false, # unify the circled end of polymorphic associations
16
16
  :no_association_labels=>false, # don't show association labels
17
- :output_tools => %w{dot fdp neato} # graphviz styles (tools) used whe generating output (ps/png/pdf)
17
+ :output_tools => %w{dot fdp neato}, # graphviz styles (tools) used whe generating output (ps/png/pdf)
18
+ :type_abbreviations => { # abbreviations used for field types
19
+ :date=>'d',
20
+ :datetime=>'dt',
21
+ :timestamp=>'ts',
22
+ :boolean=>'b',
23
+ :integer=>'i',
24
+ :string=>'s',
25
+ :text=>'tx',
26
+ :float=>'f',
27
+ :decimal=>'d',
28
+ :geometry=>'g',
29
+ :spatial=>'g'
30
+ }
18
31
  ].merge Settings.load(Rails.root.join('config','modal_diagrams.yml'))
19
32
  end
20
33
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "modaldiagrams"
8
- s.version = "1.1.1"
8
+ s.version = "1.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Javier Goizueta"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modaldiagrams
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -166,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  segments:
168
168
  - 0
169
- hash: -587444840250185935
169
+ hash: -1469969141258000337
170
170
  required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements: