dev_toolbar 1.1.0 → 2.0.0

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: 8b5f82f64e412b3c84ead79dd80b612f52af3e45bb590fba94f24aafd148b1ef
4
- data.tar.gz: f6ad406e103b96573194853a79cb89f5b3dc4ed78e48bfd692112c8203168d7b
3
+ metadata.gz: 6a7c9be1b47e2a68f0571b7a9f0bcc808eb8d0d48669f866112c03c7eb2a1283
4
+ data.tar.gz: 0b16561e3b9c74b77d4a1ced86fb5e8599e5bb735dd70647d227a66b59f4c3ee
5
5
  SHA512:
6
- metadata.gz: 0f4289abfef772cad1b0ef858dfa760a77e3071e8fad8aa42e8ce348477fabb0575cd52d710388808e7ccfc3d24d504d43d21baee46fc540265aaa50e2de8c4d
7
- data.tar.gz: 70cbbfce13c9fa7c67edd150e4b429ef0d9a03477a47979553e2eabe48518181549888d234feb7d38c0ac2047fcf81b7000328a42fc3e96a0cf1f915791f0729
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
@@ -81,8 +81,13 @@ module DevToolbar
81
81
 
82
82
  def toolbar_links
83
83
  DevToolbar.configuration.links.map do |link|
84
- "<a href='#{link[:path]}' target='_blank' class='dev-toolbar-link'>#{link[:name]}</a>"
85
- end.join(' ')
84
+ # if the erd.png file does not exist in /public, don't show the link
85
+ if link[:name] == "ERD" && !File.exist?(Rails.root.join("erd.png"))
86
+ next
87
+ else
88
+ "<a href='#{link[:path]}' target='_blank' class='dev-toolbar-link'>#{link[:name]}</a>"
89
+ end
90
+ end.compact.join(" ")
86
91
  end
87
92
  end
88
93
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DevToolbar
4
- VERSION = "1.1.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.1.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-06-11 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