debugbar 0.4.1 → 0.4.3

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: 8e785af28c739c6cc9e994f3b6d650f92301bb26ef35ed8b267229df4790c9e8
4
- data.tar.gz: 16224fff5dc65878d274e265b362f9779320482dad8ede2833a2b83bf13e9bcf
3
+ metadata.gz: 5baf46392ef6971651278629311c31ce702eff3c07cf85f1e46a0975f9535474
4
+ data.tar.gz: fce99f252cd68cfbd6d81b87276c6f3a0218371aa6069a6007a7def71b674769
5
5
  SHA512:
6
- metadata.gz: 45ceef2ea931c265152544862f2b13ac544cd76f8051bf60fb52027dede0c7e8dc7da70ab638c43442f711bb7c5a37247ada7b78c6b218be4994c0fb41f9beec
7
- data.tar.gz: 7961b48ce065f62e6aab4d02583b0ce30d76fcaafa856b5e383d4dc8b4c20ea4dac4ed7304ba837596344637a17a60b9de4376e715efba7f06956dd8372b2480
6
+ metadata.gz: 2f5f1f3108f0c6f5d2d5140f23c61aac35e79ba4e233d4c4c83978bd19b3e0b48acbe5d53b9dbf768d6e757e96ae8347101e128cc0a3dea513300f9967f70d82
7
+ data.tar.gz: ef27aa4a78e8f398ef2c8dc3bf30f5437b911f18913a0653b3b654e2e343854f052e374123fea5e478239f438c3b431c57ac7cd07d86069e223dec4d169695b1
data/CHANGELOG.md CHANGED
@@ -1,9 +1,27 @@
1
1
  # Changelog
2
2
 
3
- ## UNRELEASED
3
+ ## v0.4.3 - 2025-02-04
4
4
 
5
- * Use the debugbar in the browser dev tools 😎
5
+ * Small fixes - See [#54](https://github.com/julienbourdeau/debugbar/issues/54) and [#56](https://github.com/julienbourdeau/debugbar/issues/56)
6
6
 
7
+ ## v0.4.2 - 2025-01-11
8
+
9
+ * Mount `Debugbar::Engine` automatically from the gem to simplify setup - See [#51](https://github.com/julienbourdeau/debugbar/pull/51)
10
+ * Fix error if ActiveCable is not available - See [#53](https://github.com/julienbourdeau/debugbar/pull/53)
11
+
12
+ ### Attention needed
13
+
14
+ It's not breaking (yet) but if you have the following block in your `config/routes.rb`, please remove it!
15
+
16
+ ```diff
17
+ - if defined? Debugbar
18
+ - mount Debugbar::Engine => Debugbar.config.prefix
19
+ - end
20
+ ```
21
+
22
+ ## v0.4.1 - 2025-01-07
23
+
24
+ * Small fix when response is not set ([2227f4d7](https://github.com/julienbourdeau/debugbar/commit/2227f4d7e5d97ddb4b55cabd779d2bf46f9edf33))
7
25
 
8
26
  ## v0.4.0 - 2025-01-07
9
27
 
@@ -42,7 +60,7 @@
42
60
  In order to support Turbo Drive, I had to split the helper into two parts. Before the JavaScript file was loaded,
43
61
  directly in the body, but it has to be loaded in the head now.
44
62
 
45
- If you were passing configuation t `debugbar_javascript`, you must now pass it to `debugbar_body`.
63
+ If you were passing configuration t `debugbar_javascript`, you must now pass it to `debugbar_body`.
46
64
 
47
65
  ```diff
48
66
  <!DOCTYPE html>
@@ -3,6 +3,10 @@ module Debugbar
3
3
  protect_from_forgery with: :null_session
4
4
  before_action :cors_set_access_control_headers
5
5
 
6
+ def get
7
+ render json: RequestBuffer.get(params[:id])
8
+ end
9
+
6
10
  def poll
7
11
  render json: RequestBuffer.to_h
8
12
  end
@@ -1,8 +1,10 @@
1
1
  module Debugbar::TagHelpers
2
2
  def debugbar_head
3
- raw <<-HTML
3
+ html = <<-HTML
4
4
  <script defer src="#{Debugbar.config.prefix}/assets/script"></script>
5
5
  HTML
6
+
7
+ Debugbar.config.enabled? ? raw(html) : ""
6
8
  end
7
9
 
8
10
  def debugbar_body(opt = {})
@@ -27,7 +29,7 @@ module Debugbar::TagHelpers
27
29
  </script>
28
30
  HTML
29
31
 
30
- raw html
32
+ Debugbar.config.enabled? ? raw(html) : ""
31
33
  end
32
34
 
33
35
  def debugbar_javascript(opt = {})
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ rm public/extension.zip
4
+ cd client
5
+ npm run build:extension
6
+ cd dist-extension
7
+ rm .DS_Store
8
+ zip -r ../../extension.zip ./
data/config/routes.rb CHANGED
@@ -3,6 +3,8 @@ Debugbar::Engine.routes.draw do
3
3
  mount ActionCable.server => '/cable'
4
4
  end
5
5
 
6
+ get 'get/:id' => "polling#get"
7
+
6
8
  get 'poll' => "polling#poll"
7
9
  options 'poll/confirm' => "polling#confirm"
8
10
  post 'poll/confirm' => "polling#confirm"
data/debugbar.gemspec CHANGED
@@ -24,6 +24,8 @@ Gem::Specification.new do |spec|
24
24
  bin/ test/ spec/ features/ fixtures/
25
25
  client/
26
26
  .git .circleci appveyor Gemfile package.json package-lock.json .prettierrc
27
+ release.sh build_client.sh build_demo.sh build_fixtures.rb build_gem.sh
28
+ extension.zip
27
29
  ]
28
30
 
29
31
  spec.files = Dir.chdir(__dir__) do
@@ -1,5 +1,9 @@
1
1
  module Debugbar
2
2
  class CacheBuffer
3
+ def get(id)
4
+ get_collection[id].to_h
5
+ end
6
+
3
7
  def push(request)
4
8
  collection = get_collection
5
9
  collection[request.id] = request.to_h
@@ -4,6 +4,10 @@ module Debugbar
4
4
  @collection = {}
5
5
  end
6
6
 
7
+ def get(id)
8
+ @collection[id].to_h
9
+ end
10
+
7
11
  def push(request)
8
12
  @collection[request.id] = request
9
13
  end
@@ -1,5 +1,9 @@
1
1
  module Debugbar
2
2
  class NullBuffer
3
+ def get
4
+ {}
5
+ end
6
+
3
7
  def push(_request)
4
8
  end
5
9
 
@@ -5,6 +5,10 @@ module Debugbar
5
5
  @adapter = adapter
6
6
  end
7
7
 
8
+ def get(id)
9
+ @adapter.get(id)
10
+ end
11
+
8
12
  def push(request)
9
13
  @adapter.push(request)
10
14
  nil # Why not return self?
@@ -17,9 +17,14 @@ module Debugbar
17
17
  end
18
18
 
19
19
  initializer 'debugbar.override_config' do |app|
20
- unless app.config.action_cable.disable_request_forgery_protection
21
- app.config.action_cable.disable_request_forgery_protection = true
22
- log "Debugbar: Action Cable request forgery protection is enabled. This can cause issues with Debugbar. Overriding setting config.action_cable.disable_request_forgery_protection = true now. Update your configuration to get rid of this message."
20
+ if defined? ActionCable
21
+ next if app.config.action_cable.allowed_request_origins.is_a?(Array) && app.config.action_cable.allowed_request_origins.any?
22
+ next if app.config.action_cable.allowed_request_origins.is_a?(Regexp)
23
+
24
+ unless app.config.action_cable.disable_request_forgery_protection
25
+ app.config.action_cable.disable_request_forgery_protection = true
26
+ log "Debugbar: Action Cable request forgery protection is enabled. This can cause issues with Debugbar. Overriding setting config.action_cable.disable_request_forgery_protection = true now. Update your configuration to get rid of this message."
27
+ end
23
28
  end
24
29
 
25
30
  if defined? HttpLog
@@ -47,7 +52,7 @@ module Debugbar
47
52
  initializer 'debugbar.init' do |app|
48
53
  # Display error message if running in multi-process mode without proper configuration
49
54
  if ENV["WEB_CONCURRENCY"].to_i > 1
50
- cache_nok = %i[null_store memory_store].include?(Rails.configuration.cache_store.first.to_sym)
55
+ cache_nok = %i[null_store memory_store].include?(Rails.configuration.cache_store.to_sym)
51
56
  action_cable_nok = ActionCable.server.config.cable[:adapter].to_s == "async"
52
57
  adapter_nok = app.config.debugbar.buffer_adapter != :cache
53
58
 
@@ -84,6 +89,27 @@ module Debugbar
84
89
  Debugbar::RequestBuffer.init(adapter)
85
90
  end
86
91
 
92
+ initializer "debugbar.append_routes" do |app|
93
+ # Before 0.5.0, I asked people to mount the engine manually
94
+ # This will probably throw an error at some point to be ultimately removed
95
+ app.routes.append do
96
+ already_mounted = app.routes.routes.any? do |route|
97
+ route&.app&.app == ::Debugbar::Engine
98
+ end
99
+
100
+ if already_mounted
101
+ logger = Logger.new(STDOUT)
102
+ logger.warn 'Debugbar: The Debugbar engine is manually mounted in your `config/routes.rb`. The engine is now mounted automatically by the gem. Remove "mount Debugbar::Engine => Debugbar.config.prefix" from your routes to get rid of this message.'
103
+
104
+ unless Debugbar.config.enabled?
105
+ logger.warn "Debugbar: The Debugbar is disabled but the routes are loaded because the Debugbar::Engine is mounted manually in your `config/routes.rb`. It's recommended not to mount the engine manually since Debugbar 0.5.0"
106
+ end
107
+ else
108
+ mount Debugbar::Engine => Debugbar.config.prefix
109
+ end
110
+ end
111
+ end
112
+
87
113
  initializer 'debugbar.helper' do
88
114
  ActiveSupport.on_load(:action_controller) do
89
115
  ActionController::Base.helper(Debugbar::TagHelpers)
@@ -12,7 +12,8 @@ module Debugbar
12
12
 
13
13
  return @app.call(env) if Debugbar::Current.ignore?
14
14
 
15
- Debugbar::Current.new_request!(SecureRandom.uuid)
15
+ req_id = SecureRandom.uuid
16
+ Debugbar::Current.new_request!(req_id)
16
17
 
17
18
  status, headers, body = @app.call(env)
18
19
 
@@ -29,7 +30,9 @@ module Debugbar
29
30
  end
30
31
  end
31
32
 
32
- headers["X-Debugbar-On"] = "yes" # Used for the browser extension
33
+ # We can't use Rails.application.url_helper here because 1. we have to set up manually the hosts, 2. the route I
34
+ # want is inside the engine routes and I didn't manage to access them via the helper
35
+ headers["X-Debugbar-Url"] = "#{ActionDispatch::Request.new(env).base_url}#{Debugbar.config.prefix}/get/#{req_id}"
33
36
 
34
37
  [status, headers, body]
35
38
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Debugbar
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.3"
5
5
  end