dev_toolbar 1.2.0 → 2.0.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
  SHA256:
3
- metadata.gz: 2c3346cbc6911631a8ab5f783fd8c3f1cce6aee3ff8347f8f733327fc2cdf2f5
4
- data.tar.gz: dc5718868ec6d26a22f4c6c1dae9cbd7981afb3ea96b20f309b86f54106fd253
3
+ metadata.gz: 6a7c9be1b47e2a68f0571b7a9f0bcc808eb8d0d48669f866112c03c7eb2a1283
4
+ data.tar.gz: 0b16561e3b9c74b77d4a1ced86fb5e8599e5bb735dd70647d227a66b59f4c3ee
5
5
  SHA512:
6
- metadata.gz: e9248fce47ce7b823952f317c51634012df65d95e05f62f897c06771a969e2b374f4fcc8f337e7f5bacce69868976b44af561abff46086da1ead1e946ef50f36
7
- data.tar.gz: 858c55b8fab494d9a6d60f928d28bdc3eb0bb44f51888ea25edde8af8a88631f1abbad6088b1932111d3e5b8474f7cd1a1998d822616d21a148004461a5ed8a9
6
+ metadata.gz: 87e7710e2564db6cf007098623f335d21ffdf904bd3653223cd33d0ceb28320aee601e1a2560972cf6dad0d82bfb5d3139eced7bc1f27711152ec345812ffced
7
+ data.tar.gz: a8dea90ceab903d1432f6d35b8af9504b32ead4cba856a76c1d9cf7765d441c4e09a86508e47e94963048e6a8fdb1d76c87afaea30a8d5c88e175d14251d7a27
@@ -0,0 +1,10 @@
1
+ module DevToolbar
2
+ class ErdController < ActionController::Base
3
+ layout false
4
+
5
+ def show
6
+ @erd_path = Rails.root.join("erd.png")
7
+ render :show
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Entity Relationship Diagram</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+
7
+ <style>
8
+ body {
9
+ width: 95%;
10
+ max-width: 33em;
11
+ margin: 4em auto 0;
12
+ text-align: center;
13
+ font-family: arial, sans-serif;
14
+ line-height: 1.5em;
15
+ color: #808080;
16
+ }
17
+
18
+ img {
19
+ max-width: 100%;
20
+ height: auto;
21
+ }
22
+ </style>
23
+ </head>
24
+
25
+ <body>
26
+ <h1>Entity Relationship Diagram</h1>
27
+ <p>To update this diagram after changes to your database or models (e.g. adding association accessors), open a terminal and run the command:</p>
28
+ <div>
29
+ <code>rake erd</code>
30
+ </div>
31
+ <p>Then refresh this page.</p>
32
+ <div>
33
+ <% if File.exist?(@erd_path) %>
34
+ <img src="data:image/png;base64,<%= Base64.strict_encode64(File.read(@erd_path)) %>" alt="Entity Relationship Diagram">
35
+ <% else %>
36
+ <p>Entity Relationship Diagram not found. If this project has a database, you can generate the ERD with the command above.</p>
37
+ <% end %>
38
+ </div>
39
+ </body>
40
+ </html>
@@ -0,0 +1,14 @@
1
+ module DevToolbar
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace DevToolbar
4
+
5
+ config.autoload_paths << File.expand_path("../app/controllers", __FILE__)
6
+ config.paths["app/views"] << File.expand_path("../app/views", __FILE__)
7
+
8
+ initializer "dev_toolbar.add_routes", after: :add_routing_paths do |app|
9
+ app.routes.append do
10
+ get "/erd", to: "dev_toolbar/erd#show"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -82,7 +82,7 @@ module DevToolbar
82
82
  def toolbar_links
83
83
  DevToolbar.configuration.links.map do |link|
84
84
  # if the erd.png file does not exist in /public, don't show the link
85
- if link[:name] == "Data Model" && !File.exist?(Rails.public_path.join("erd.png"))
85
+ if link[:name] == "ERD" && !File.exist?(Rails.root.join("erd.png"))
86
86
  next
87
87
  else
88
88
  "<a href='#{link[:path]}' target='_blank' class='dev-toolbar-link'>#{link[:name]}</a>"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DevToolbar
4
- VERSION = "1.2.0"
4
+ VERSION = "2.0.0"
5
5
  end
data/lib/dev_toolbar.rb CHANGED
@@ -4,6 +4,7 @@ require_relative "dev_toolbar/version"
4
4
  require_relative "dev_toolbar/railtie"
5
5
  require_relative "dev_toolbar/middleware"
6
6
  require_relative "dev_toolbar/configuration"
7
+ require_relative "dev_toolbar/engine"
7
8
 
8
9
  module DevToolbar
9
10
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev_toolbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Purinton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-21 00:00:00.000000000 Z
11
+ date: 2024-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -60,7 +60,10 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - lib/dev_toolbar.rb
63
+ - lib/dev_toolbar/app/controllers/dev_toolbar/erd_controller.rb
64
+ - lib/dev_toolbar/app/views/dev_toolbar/erd/show.html.erb
63
65
  - lib/dev_toolbar/configuration.rb
66
+ - lib/dev_toolbar/engine.rb
64
67
  - lib/dev_toolbar/middleware.rb
65
68
  - lib/dev_toolbar/railtie.rb
66
69
  - lib/dev_toolbar/version.rb