rails-erd-d3 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -7
- data/lib/rails_erd_d3.rb +4 -2
- data/lib/templates/d3.html.erb +6 -4
- data/rails-erd-d3.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4178c1c94d8cc5755397c66b225aeae61b3fa7bd
|
4
|
+
data.tar.gz: 990f6173a7d1fd5be0e4dd5d9618260ca1fd3071
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17c022f2c635ea355ec63c87e89382218aa5ba214a4b75d630baf350a6de867d732873b1127d2a42d0c20a8cbf224285a22baa1191320c2f53abfd253ee2cb58
|
7
|
+
data.tar.gz: 60ee4618c0a9671c64af296292c50bed5caf1b5d3acc184ec6c3318a85c42d41e7b6465cddb6af59cd4a07b34103987e2ed8b9726c37bbebb4a2e0dbf2c8aaec
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Create entity–relationship diagram with D3.js for your Rails application.
|
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
15
|
-
Add
|
15
|
+
Add these lines to your application's Gemfile:
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
group :development do
|
@@ -20,14 +20,21 @@ group :development do
|
|
20
20
|
end
|
21
21
|
```
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
Install gem:
|
24
|
+
```shall
|
25
|
+
$ bundle install
|
26
|
+
```
|
27
27
|
|
28
|
-
|
28
|
+
And then execute for creating file erd.html:
|
29
|
+
```shall
|
30
|
+
$ bundle exec erd-d3
|
31
|
+
```
|
29
32
|
|
30
|
-
|
33
|
+
Or:
|
34
|
+
```shall
|
35
|
+
$ rails c
|
36
|
+
> RailsErdD3.create
|
37
|
+
```
|
31
38
|
|
32
39
|
## Todo
|
33
40
|
|
data/lib/rails_erd_d3.rb
CHANGED
@@ -45,9 +45,11 @@ class RailsErdD3
|
|
45
45
|
puts "Generate data for #{model.name}"
|
46
46
|
model.reflections.each do |refl_name, refl_data|
|
47
47
|
next if refl_data.options[:polymorphic]
|
48
|
-
|
49
|
-
|
48
|
+
|
49
|
+
refl_model = (refl_data.options[:class_name] || refl_name).underscore
|
50
|
+
association = refl_data.macro.to_s + (refl_data.options[:through] ? "_through" : "")
|
50
51
|
color_index = ASSOCIATIONS.index(association)
|
52
|
+
|
51
53
|
links << {
|
52
54
|
source: models_list[model.model_name.plural.capitalize],
|
53
55
|
target: models_list[refl_model.pluralize.capitalize],
|
data/lib/templates/d3.html.erb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
|
18
18
|
var simulation = d3.forceSimulation()
|
19
19
|
.force('link', d3.forceLink().id(function(d) { return d.index }))
|
20
|
-
.force('collide',d3.forceCollide(
|
20
|
+
.force('collide', d3.forceCollide(function(d) { return d.r + 20 }).iterations(30))
|
21
21
|
.force('charge', d3.forceManyBody())
|
22
22
|
.force('center', d3.forceCenter(width / 2, height / 2))
|
23
23
|
.force('y', d3.forceY(0))
|
@@ -29,7 +29,8 @@
|
|
29
29
|
.data(data.links)
|
30
30
|
.enter()
|
31
31
|
.append('line')
|
32
|
-
.attr('
|
32
|
+
.attr('class', function(d, i) { return d.nodes[i].label })
|
33
|
+
.attr('stroke', function(d) { return colorScale(d.color) });
|
33
34
|
|
34
35
|
var node = svg.selectAll('.node')
|
35
36
|
.data(data.nodes)
|
@@ -38,7 +39,8 @@
|
|
38
39
|
.classed('node', true)
|
39
40
|
.style('cursor', 'pointer')
|
40
41
|
.attr('data-toggle', 'modal')
|
41
|
-
.attr('data-target', function(d, i){ return '#' + data.nodes[i].label })
|
42
|
+
.attr('data-target', function(d, i) { return '#' + data.nodes[i].label })
|
43
|
+
.attr('class', function(d, i) { return d.nodes[i].label })
|
42
44
|
.call(d3.drag()
|
43
45
|
.on('start', dragstarted)
|
44
46
|
.on('drag', dragged)
|
@@ -47,7 +49,7 @@
|
|
47
49
|
node.append('circle')
|
48
50
|
.classed('circle', true)
|
49
51
|
.attr('r', function(d){ return d.r })
|
50
|
-
.attr('fill', function(d, i){ return colorScale(i) });
|
52
|
+
.attr('fill', function(d, i) { return colorScale(i) });
|
51
53
|
|
52
54
|
node.append('text')
|
53
55
|
.classed('text', true)
|
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.2.
|
9
|
+
spec.version = "0.2.5"
|
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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-erd-d3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Krasavtsev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.6.6
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: Entity–relationship diagram with D3.js for Rails application
|