debugbar 0.4.0 → 0.4.2

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: 6aba562e1aed30badc070345aa43832a4446332e7106ec29fd8cb3b8ceffdcba
4
- data.tar.gz: 5bdc9a1ffe211db11e665f5fa07eb0a526da894b529ba091b78195e2dc6bafdf
3
+ metadata.gz: cc75f60be93ef95e8b51a8dcb4a7682c801fef9ba4790828a26f8ec8c4c37f63
4
+ data.tar.gz: 7ef69e8c41cf2dddb68ad2d6e5ac2b2e8d4702ab9d97d89363d6f38b0fbae8ec
5
5
  SHA512:
6
- metadata.gz: bce8023b7873a7d6975e7da731dbcdc67b29b1333d5995988c50b209ae0616e23dafa2201d6854fd5298fa738b85e34a89a4f7ee2439f25863dcb24a95061c02
7
- data.tar.gz: 47cf338f0bad77e1fa45e6d85f26cc25456adf592d10ee9ea8affe427d7c9a5fb0b74cd39b3f1e367070f43736ed14cfa7afd3ea24b36355255be258d5140327
6
+ metadata.gz: 9d6e2fbef45e447717b91e9e92c53884e15684bd8fdfa9363b99f4ea35da766dc9b82b71340b61063832e5149ff7564c0cafd4dddfee52b74fe93805516a87e1
7
+ data.tar.gz: e35d17f833d1566a4c87b3a875ed496751622fd078386e10474eb09dbe739a193d67c481255813c3b3551b269935b08c0095ba0a37e8b2e709c28f90dfb2fb06
data/CHANGELOG.md CHANGED
@@ -1,9 +1,23 @@
1
1
  # Changelog
2
2
 
3
- ## UNRELEASED
3
+ ## v0.4.2 - 2025-01-11
4
4
 
5
- * Use the debugbar in the browser dev tools 😎
5
+ * Mount `Debugbar::Engine` automatically from the gem to simplify setup - See [#51](https://github.com/julienbourdeau/debugbar/pull/51)
6
+ * Fix error if ActiveCable is not available - See [#53](https://github.com/julienbourdeau/debugbar/pull/53)
6
7
 
8
+ ### Attention needed
9
+
10
+ It's not breaking (yet) but if you have the following block in your `config/routes.rb`, please remove it!
11
+
12
+ ```diff
13
+ - if defined? Debugbar
14
+ - mount Debugbar::Engine => Debugbar.config.prefix
15
+ - end
16
+ ```
17
+
18
+ ## v0.4.1 - 2025-01-07
19
+
20
+ * Small fix when response is not set ([2227f4d7](https://github.com/julienbourdeau/debugbar/commit/2227f4d7e5d97ddb4b55cabd779d2bf46f9edf33))
7
21
 
8
22
  ## v0.4.0 - 2025-01-07
9
23
 
@@ -42,7 +56,7 @@
42
56
  In order to support Turbo Drive, I had to split the helper into two parts. Before the JavaScript file was loaded,
43
57
  directly in the body, but it has to be loaded in the head now.
44
58
 
45
- If you were passing configuation t `debugbar_javascript`, you must now pass it to `debugbar_body`.
59
+ If you were passing configuration t `debugbar_javascript`, you must now pass it to `debugbar_body`.
46
60
 
47
61
  ```diff
48
62
  <!DOCTYPE html>
@@ -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 = {})
data/build_fixtures.rb CHANGED
@@ -25,7 +25,8 @@ Net::HTTP.start('127.0.0.1', 3000) do |http|
25
25
  response = http.request Net::HTTP::Get.new('/_debugbar/poll')
26
26
  data = JSON.parse(response.body)
27
27
  data.each_with_index do |item, idx|
28
- name = ("%03d" % (idx +1)) + '-' + item['meta']['controller'] + '-' + item['meta']['action']
29
- File.write("#{fixtures_dir}/#{name}.json", JSON.pretty_generate(item))
28
+ filename = ("%03d" % (idx +1)) + '-' + item['meta']['controller'] + '-' + item['meta']['action'] + '.json'
29
+ puts "Writing #{filename}"
30
+ File.write("#{fixtures_dir}/#{filename}", JSON.pretty_generate(item))
30
31
  end
31
32
  end
@@ -17,9 +17,11 @@ 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
+ unless app.config.action_cable.disable_request_forgery_protection
22
+ app.config.action_cable.disable_request_forgery_protection = true
23
+ 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."
24
+ end
23
25
  end
24
26
 
25
27
  if defined? HttpLog
@@ -84,6 +86,27 @@ module Debugbar
84
86
  Debugbar::RequestBuffer.init(adapter)
85
87
  end
86
88
 
89
+ initializer "debugbar.append_routes" do |app|
90
+ # Before 0.5.0, I asked people to mount the engine manually
91
+ # This will probably throw an error at some point to be ultimately removed
92
+ app.routes.append do
93
+ already_mounted = app.routes.routes.any? do |route|
94
+ route&.app&.app == ::Debugbar::Engine
95
+ end
96
+
97
+ if already_mounted
98
+ logger = Logger.new(STDOUT)
99
+ 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.'
100
+
101
+ unless Debugbar.config.enabled?
102
+ 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"
103
+ end
104
+ else
105
+ mount Debugbar::Engine => Debugbar.config.prefix
106
+ end
107
+ end
108
+ end
109
+
87
110
  initializer 'debugbar.helper' do
88
111
  ActiveSupport.on_load(:action_controller) do
89
112
  ActionController::Base.helper(Debugbar::TagHelpers)
@@ -32,6 +32,8 @@ module Debugbar
32
32
  end
33
33
 
34
34
  def self.from_rack(rack_res)
35
+ return nil if rack_res.nil?
36
+
35
37
  headers = rack_res.headers.to_h.transform_keys { |s| s.split('-').map(&:capitalize).join('-') }
36
38
 
37
39
  new(rack_res.status, headers, rack_res.body)
@@ -14,7 +14,7 @@ module Debugbar
14
14
 
15
15
  Debugbar::Current.new_request!(SecureRandom.uuid)
16
16
 
17
- status, headers, body = @app.call(env)
17
+ res = @app.call(env)
18
18
 
19
19
  # TODO: Remove this if statement?
20
20
  # We check meta because the frontend doesn't support request without meta yet.
@@ -29,9 +29,7 @@ module Debugbar
29
29
  end
30
30
  end
31
31
 
32
- headers["X-Debugbar-On"] = "yes" # Used for the browser extension
33
-
34
- [status, headers, body]
32
+ res
35
33
  end
36
34
  end
37
35
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Debugbar
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.2"
5
5
  end