rom_sql_graph 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/rom_sql_graph.rb +1 -0
- data/lib/rom_sql_graph/base.rb +4 -0
- data/lib/rom_sql_graph/html_generation.rb +16 -0
- data/lib/rom_sql_graph/templates/graph.erb +38 -0
- data/lib/rom_sql_graph/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cfe5522d127bfa11debffa5ce03723607f1727e
|
4
|
+
data.tar.gz: c8f3ad787df57df393108a2f6b372e4459af97bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18eddd25b3517aeb2603367889ab61c3d58192a762cbec749ee6db72d0490d5cbd0307207c52b9687a838ec7621422b142b852e5f9e84913297dd1a0e2803045
|
7
|
+
data.tar.gz: f9b3a059d269f6f219462bf5ab94a4a9b0cd4d7cdba3f89bca8bfa34b8be39024608354871d188049e26d1dbffc8b3ae87ad7f0f260ccf9d9f095eaf2d92ded1
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# RomSqlGraph
|
2
2
|
|
3
|
-
Rom-rb and hanami tool for generating db (sql) association graph.
|
3
|
+
[Rom-rb](http://rom-rb.org) and [hanami](http://hanamirb.org) tool for generating db (sql) association graph.
|
4
4
|
|
5
5
|
**For generating image you need to install graphviz tool (http://www.graphviz.org)**
|
6
6
|
|
@@ -45,7 +45,7 @@ graph.to_json
|
|
45
45
|
|
46
46
|
## TODO:
|
47
47
|
- [ ] add tests
|
48
|
-
- [
|
48
|
+
- [x] generate html
|
49
49
|
- [ ] generate json
|
50
50
|
|
51
51
|
## Contributing
|
data/lib/rom_sql_graph.rb
CHANGED
data/lib/rom_sql_graph/base.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module RomSqlGraph
|
4
|
+
class HtmlGeneration
|
5
|
+
attr_reader :edges
|
6
|
+
|
7
|
+
def initialize(edges)
|
8
|
+
@edges = edges
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
html = ERB.new(File.read("#{File.dirname(__FILE__)}/templates/graph.erb")).result binding
|
13
|
+
File.open("#{Dir.pwd}/graph.html", 'w') { |file| file.write(html) }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Association graph</title>
|
5
|
+
<script type="text/javascript" src="https://www.graphdracula.net/js/raphael-min.js"></script>
|
6
|
+
<script type="text/javascript" src="https://www.graphdracula.net/js/graffle.js"></script>
|
7
|
+
<script type="text/javascript" src="https://www.graphdracula.net/js/graph.js"></script>
|
8
|
+
<script type="text/javascript">
|
9
|
+
var redraw;
|
10
|
+
var height = 600;
|
11
|
+
var width = 1000;
|
12
|
+
|
13
|
+
window.onload = function() {
|
14
|
+
|
15
|
+
var g = new Graph();
|
16
|
+
|
17
|
+
<% @edges.each do |edge| %>
|
18
|
+
g.addEdge('<%= edge.first %>', '<%= edge.last %>');
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
var layouter = new Graph.Layout.Spring(g);
|
22
|
+
layouter.layout();
|
23
|
+
|
24
|
+
var renderer = new Graph.Renderer.Raphael('canvas', g, width, height);
|
25
|
+
renderer.draw();
|
26
|
+
|
27
|
+
redraw = function() {
|
28
|
+
layouter.layout();
|
29
|
+
renderer.draw();
|
30
|
+
};
|
31
|
+
};
|
32
|
+
|
33
|
+
</script>
|
34
|
+
</head>
|
35
|
+
<body>
|
36
|
+
<div id="canvas"></div>
|
37
|
+
</body>
|
38
|
+
</html>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom_sql_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Davydov
|
@@ -100,6 +100,8 @@ files:
|
|
100
100
|
- lib/rom_sql_graph.rb
|
101
101
|
- lib/rom_sql_graph/base.rb
|
102
102
|
- lib/rom_sql_graph/edges.rb
|
103
|
+
- lib/rom_sql_graph/html_generation.rb
|
104
|
+
- lib/rom_sql_graph/templates/graph.erb
|
103
105
|
- lib/rom_sql_graph/version.rb
|
104
106
|
- rom_sql_graph.gemspec
|
105
107
|
homepage: https://github.com/davydovanton/rom-sql-graph
|