erd_map 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b868db53c728786986ef918092b37608399f674c1e0a410fc5f3e9b67d707ad
4
- data.tar.gz: 55b585aead0da7727b75e90651ec06dd3636d032cd39078d488169ed20f1374b
3
+ metadata.gz: 58adf237a921795d41fbdb5d07acff7485b562ff812dd2ad19963bf101b4863f
4
+ data.tar.gz: 476ab911a73fc1bd22e26a76cb52cc2f105689bde65a7fa3f45720f12a600fe7
5
5
  SHA512:
6
- metadata.gz: 1ee3f5b8c5d70475d4a6567086c57be4c27e6a1f730f94fb314db64d965621189d43e729c364c08dfcfffde36ac5053513926572e84a295fdae4da2e0c3985ec
7
- data.tar.gz: 3067212a98992a87fe1f55787d6a5683a603e0b80a7372bae4456ad6daf332d02d466137aa3503f28b44eebc01cb23153ff53fe1a4fe3921dc2c1a4e3381f23e
6
+ metadata.gz: fd36888b949171467bc7356ab92c79df6d61dab4391d63d7cb9ec469fe1ca39e32887a16ac958d58b3a1373a4ee2d2a03ba96a914b0487d882ba72312b233fd7
7
+ data.tar.gz: 68d3802e9eca76475cc877d350c68b99a8a6cf2e428c8c23a015f5e7bd7f4b465a432b538e8115b0eaf30f96e9c73ec22e66169a081d4b7b17c45113d52717b2
data/README.md CHANGED
@@ -30,13 +30,15 @@ echo 'eval "$(pyenv init - zsh)"' >> ~/.zshrc
30
30
  # Install latest version of python
31
31
  pyenv install $(pyenv install --list | grep -E '^\s*[0-9]+\.[0-9]+\.[0-9]+$' | tail -n 1)
32
32
  pyenv global $(pyenv install --list | grep -E '^\s*[0-9]+\.[0-9]+\.[0-9]+$' | tail -n 1)
33
-
34
- # Install packages using pip
35
- pip install networkx bokeh scipy
36
33
  ```
37
34
 
38
35
  </details>
39
36
 
37
+ ```bash
38
+ # Install packages, for example with pip
39
+ pip install networkx bokeh scipy
40
+ ```
41
+
40
42
  ## Installation
41
43
 
42
44
  Add this line to your application's Gemfile:
@@ -4,6 +4,8 @@ module ErdMap
4
4
  class ErdMapController < ApplicationController
5
5
  FILE_PATH = Rails.root.join("tmp", "erd_map", "map.html")
6
6
 
7
+ skip_forgery_protection
8
+
7
9
  def index
8
10
  if File.exist?(FILE_PATH)
9
11
  render html: File.read(FILE_PATH).html_safe
data/lib/erd_map/graph.rb CHANGED
@@ -17,7 +17,7 @@ module ErdMap
17
17
  k = 1.0 / Math.sqrt(nodes_size) * 3.0
18
18
 
19
19
  subgraph = whole_graph.subgraph(display_nodes)
20
- layout = nx.spring_layout(subgraph, seed: 1, k: k)
20
+ layout = networkx.spring_layout(subgraph, seed: 1, k: k)
21
21
 
22
22
  layout_hash = {}
23
23
  layout.each do |node, xy|
@@ -34,7 +34,7 @@ module ErdMap
34
34
  def chunked_nodes
35
35
  return @chunked_nodes if @chunked_nodes
36
36
 
37
- centralities = nx.eigenvector_centrality(whole_graph) # { node_name => centrality }
37
+ centralities = networkx.eigenvector_centrality(whole_graph) # { node_name => centrality }
38
38
  sorted_nodes = centralities.sort_by { |_node, centrality| centrality }.reverse.map(&:first)
39
39
 
40
40
  chunk_sizes = []
@@ -133,12 +133,12 @@ module ErdMap
133
133
 
134
134
  private
135
135
 
136
- attr_reader :nx, :networkx_community
136
+ attr_reader :networkx, :networkx_community
137
137
  attr_reader :whole_graph
138
138
 
139
139
  def initialize
140
140
  import_modules = ErdMap.py_call_modules.imported_modules
141
- @nx = import_modules[:nx]
141
+ @networkx = import_modules[:networkx]
142
142
  @networkx_community = import_modules[:networkx_community]
143
143
  @whole_graph = build_whole_graph
144
144
  end
@@ -151,7 +151,7 @@ module ErdMap
151
151
  end
152
152
 
153
153
  def build_whole_graph
154
- whole_graph = nx.Graph.new
154
+ whole_graph = networkx.Graph.new
155
155
 
156
156
  whole_models.each do |model|
157
157
  whole_graph.add_node(model.name)
@@ -66,7 +66,7 @@ class GraphManager {
66
66
  return isConnectedNode ? HIGHLIGHT_NODE_COLOR : originalColors[i]
67
67
  })
68
68
  this.nodeSource.data["radius"] = this.#nodesIndex.map((nodeName, i) => {
69
- return nodeName === closestNodeName ? EMPTHASIS_NODE_SIZE : originalRadius[i]
69
+ return nodeName === closestNodeName ? EMPHASIS_NODE_SIZE : originalRadius[i]
70
70
  })
71
71
  this.edgeSource.data["line_color"] = this.#sourceNodes.map((start, i) => {
72
72
  return [start, this.#targetNodes[i]].includes(closestNodeName) ? HIGHLIGHT_EDGE_COLOR : BASIC_COLOR
@@ -293,8 +293,8 @@ class GraphManager {
293
293
  if (!candidateNodes.includes(nodeName)) { return }
294
294
 
295
295
  const xy = layout[nodeName] || this.#wholeLayout[nodeName]
296
- const dx = xy[0] + this.#shiftX - this.#mouseX
297
- const dy = xy[1] + this.#shiftY - this.#mouseY
296
+ const dx = xy[0] - this.#mouseX
297
+ const dy = xy[1] - this.#mouseY
298
298
  const distance = dx * dx + dy * dy
299
299
  if (distance < minmumDistance) {
300
300
  minmumDistance = distance
@@ -405,10 +405,10 @@ class GraphManager {
405
405
  this.#changeDisplayNodes(connectedNodes)
406
406
 
407
407
  const { selectedLayout } = this.#getShowingNodesAndSelectedLayout()
408
- this.#updateLayout(selectedLayout, tappedNode)
409
- this.#nodesIndex.forEach(nodeName => {
410
- selectedLayout[nodeName][0] += this.#shiftX
411
- selectedLayout[nodeName][1] += this.#shiftY
408
+ const [nodesX, nodesY] = this.#updateLayout(selectedLayout, tappedNode)
409
+ this.#nodesIndex.forEach((nodeName, i) => {
410
+ selectedLayout[nodeName][0] = nodesX[i]
411
+ selectedLayout[nodeName][1] = nodesY[i]
412
412
  })
413
413
  this.layoutProvider.graph_layout = selectedLayout
414
414
  this.layoutProvider.change.emit()
@@ -13,7 +13,7 @@ module ErdMap
13
13
  HIGHLIGHT_EDGE_COLOR = "orange"
14
14
  HIGHLIGHT_TEXT_COLOR = "white"
15
15
  BASIC_COLOR = "darkslategray"
16
- EMPTHASIS_NODE_SIZE = 80
16
+ EMPHASIS_NODE_SIZE = 80
17
17
 
18
18
  def renderers
19
19
  [circle_renderer, rect_renderer]
@@ -59,7 +59,7 @@ module ErdMap
59
59
  HIGHLIGHT_EDGE_COLOR: HIGHLIGHT_EDGE_COLOR,
60
60
  HIGHLIGHT_TEXT_COLOR: HIGHLIGHT_TEXT_COLOR,
61
61
  BASIC_COLOR: BASIC_COLOR,
62
- EMPTHASIS_NODE_SIZE: EMPTHASIS_NODE_SIZE,
62
+ EMPHASIS_NODE_SIZE: EMPHASIS_NODE_SIZE,
63
63
  }
64
64
  end
65
65
 
@@ -5,7 +5,7 @@ require "pycall"
5
5
  module ErdMap
6
6
  class PyCallModules
7
7
  def initialize
8
- @nx = PyCall.import_module("networkx")
8
+ @networkx = PyCall.import_module("networkx")
9
9
  @bokeh_io = PyCall.import_module("bokeh.io")
10
10
  @bokeh_models = PyCall.import_module("bokeh.models")
11
11
  @bokeh_plotting = PyCall.import_module("bokeh.plotting")
@@ -14,7 +14,7 @@ module ErdMap
14
14
 
15
15
  def imported_modules
16
16
  {
17
- nx: @nx,
17
+ networkx: @networkx,
18
18
  bokeh_io: @bokeh_io,
19
19
  bokeh_models: @bokeh_models,
20
20
  bokeh_plotting: @bokeh_plotting,
@@ -1,3 +1,3 @@
1
1
  module ErdMap
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erd_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - makicamel
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-15 00:00:00.000000000 Z
10
+ date: 2025-01-24 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails