rails-erd-d3 0.9.2 → 0.9.3

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: 35ce42e5c0fe86c5f104145eb3f50890ae5fca71
4
- data.tar.gz: 4d67532f68b8d3f5a50245c231872fb493daaf55
3
+ metadata.gz: 542b6427e59b1bbb3e1042ebb41e942879a68d65
4
+ data.tar.gz: 526b783214b37465688b996bd15e675a23a78c00
5
5
  SHA512:
6
- metadata.gz: 5c92b90f152224886d1462c20273eb25a7cb09902f4778c806d797aad0a2bba94c15e4e88c9a1f9ff03568562847a59daca9b8b692afa862f021d54971056444
7
- data.tar.gz: ebd43de7bc05afce55a1623b58aa17990597736045d46b9ba2cdb540f3e6178069968ce048c8dae7c65ddff9a8da05f2fc5ec477c596f39a7a74841be79cc723
6
+ metadata.gz: 781dc9c87f46d2403a767ac472d50fdd9f0eff6d12b8b61ca6b898feb21115bb7c52f7363c700942ec1932372fe329d3337ae081614014a2ae4232b42a5bbcd7
7
+ data.tar.gz: 670ced49a9380d4ef88b8309041016e8c886a8ae80dfd44bb02b026d813f857ef2a851776ba7fab5d265183de704a3458c9deb7fed58731df2baabc80b2ddf71
data/lib/rails_erd_d3.rb CHANGED
@@ -43,24 +43,24 @@ class RailsErdD3
43
43
  nodes = []
44
44
  links = []
45
45
  @@models.each do |model|
46
- nodes << { label: model.name, r: 30 }
46
+ nodes << { table_name: model.table_name, label: model.name, r: 30 }
47
47
 
48
48
  puts " - #{model.name}"
49
49
  model.reflections.each do |name, reflection|
50
50
  next if reflection.options[:polymorphic]
51
51
 
52
- unless models_list[reflection.table_name]
53
- puts "Model does not exist #{reflection.class_name}!"
52
+ begin
53
+ association = reflection.macro.to_s + (reflection.options[:through] ? "_through" : "")
54
+
55
+ links << {
56
+ source: models_list[model.table_name],
57
+ target: models_list[reflection.table_name],
58
+ color: ASSOCIATIONS.index(association)
59
+ }
60
+ rescue
61
+ puts "Please ensure that association #{name} sets properly!"
54
62
  next
55
63
  end
56
-
57
- association = reflection.macro.to_s + (reflection.options[:through] ? "_through" : "")
58
-
59
- links << {
60
- source: models_list[model.table_name],
61
- target: models_list[reflection.table_name],
62
- color: ASSOCIATIONS.index(association)
63
- }
64
64
  end
65
65
  end
66
66
  puts "Data were successfully generated."
@@ -53,7 +53,7 @@
53
53
  .classed('node', true)
54
54
  .style('cursor', 'pointer')
55
55
  .attr('data-toggle', 'modal')
56
- .attr('data-target', function(d) { return '#' + d.label })
56
+ .attr('data-target', function(d) { return '#' + d.table_name })
57
57
  .attr('class', function(d) { return d.label })
58
58
  .call(d3.drag()
59
59
  .on('start', dragstarted)
@@ -1,5 +1,5 @@
1
1
  <% @@models.each do |model| %>
2
- <div class="modal fade" id="<%= model.name %>" tabindex="-1" role="dialog">
2
+ <div class="modal fade" id="<%= model.table_name %>" tabindex="-1" role="dialog">
3
3
  <div class="modal-dialog" role="document">
4
4
  <div class="modal-content">
5
5
  <div class="modal-header">
data/rails-erd-d3.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.name = "rails-erd-d3"
7
7
  spec.authors = ["Roman Krasavtsev"]
8
8
  spec.email = ["mr.krasavtsev@gmail.com"]
9
- spec.version = "0.9.2"
9
+ spec.version = "0.9.3"
10
10
  spec.summary = "Entity–relationship diagram with D3.js for Rails application"
11
11
  spec.description = "This gem creates entity–relationship diagram with D3.js for your Rails application"
12
12
  spec.homepage = "https://github.com/RomanKrasavtsev/rails-erd-d3"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-erd-d3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Krasavtsev