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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d085ed2dc932a137c3e195530cf1eba2beb8907
4
- data.tar.gz: d8ac0ae301303b4d882c2ea0a22b6ea0757049df
3
+ metadata.gz: 7cfe5522d127bfa11debffa5ce03723607f1727e
4
+ data.tar.gz: c8f3ad787df57df393108a2f6b372e4459af97bb
5
5
  SHA512:
6
- metadata.gz: deeef6a35ac8bf86cac4cedce876c56f930b7d8e68b816949ced33f4d556477bec296b197c1c2dd89d6f47f5179d1059b5999f6e5bfb514337bd52e0675b82bc
7
- data.tar.gz: bee087332aeb298b2936c45abc4b94cccb629082ecee298885135bc52279cc9c7ac2a79611bbdafcd4592587ea56b70a36c380e097533b80249909c4ab055a9f
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
- - [ ] generate html
48
+ - [x] generate html
49
49
  - [ ] generate json
50
50
 
51
51
  ## Contributing
data/lib/rom_sql_graph.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "rom_sql_graph/base"
2
+ require "rom_sql_graph/html_generation"
2
3
  require "rom_sql_graph/edges"
3
4
  require "rom_sql_graph/version"
4
5
 
@@ -18,6 +18,10 @@ module RomSqlGraph
18
18
  graph.write_to_graphic_file('jpg')
19
19
  end
20
20
 
21
+ def generate_html
22
+ HtmlGeneration.new(edges).call
23
+ end
24
+
21
25
  def to_s
22
26
  graph.edges.sort.to_s
23
27
  end
@@ -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>
@@ -1,3 +1,3 @@
1
1
  module RomSqlGraph
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.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