debug-extras 0.3.0 → 0.3.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
  SHA1:
3
- metadata.gz: 22f0e2df357a2929bee4703f660b777bad7eae9c
4
- data.tar.gz: 37da334a490125800388a00ce5dee88b0eed0362
3
+ metadata.gz: 377e4b36eef7d82e29633387824887706ee7d937
4
+ data.tar.gz: fa54e8daab506a47c6fc1fd977547a7631bf1783
5
5
  SHA512:
6
- metadata.gz: e44b543a282aa88c2d10111afc9e1270ab5320b6cb06a2c2a3151b67af925437c770fb754fe3c83de19c7afaa0d8f306a7e0edab8b8fc2f09292e39ffedbd49b
7
- data.tar.gz: bac5229d5b6bde0dee0bbcca118b8e9439cba96ef42cd16a72fe7ad2ee964cfc2c1a3f22cb16461ef21c1a767f50fda4cec16c76135c4765c9f7e81b3a67ffd9
6
+ metadata.gz: 06c880e79dc2c7224e6e71c2ac10883d0cc0ce1121192eede19f82259f8bff163477ca6506418aad1f98a3525890c8bb5f1a05dd6093db3b154350d526294832
7
+ data.tar.gz: ab52151f23fff72a327ec182361e6a95f32e3c26b92af479d03d44b53a4b54638776942b26aed16ea8842717b4407a64427a38d4d37f83884dd62d569a8151b2
data/README.md CHANGED
@@ -1,16 +1,6 @@
1
- TODO: move to js
2
- TODO: check with rspec
3
- TODO: check with pure ruby
4
- TODO: make PR to better_errors? -
5
- TODO: check byebug
6
- TODO: update pivotal
7
- TODO: update REAMDE
8
-
9
1
  # DebugExtras [![Gem](https://img.shields.io/gem/v/debug-extras.svg)](https://rubygems.org/gems/debug-extras) [![Build Status](https://img.shields.io/travis/vavgustov/debug-extras/master.svg)](https://travis-ci.org/vavgustov/debug-extras) [![Code Climate](https://img.shields.io/codeclimate/github/vavgustov/debug-extras.svg)](https://codeclimate.com/github/vavgustov/debug-extras)
10
2
 
11
- Extras for Ruby on Rails debugging.
12
-
13
- TODO: add image here with dd results
3
+ Extras for Ruby on Rails debugging. [Screenshots](https://github.com/vavgustov/debug-extras#screenshots).
14
4
 
15
5
  ## Features
16
6
 
@@ -23,7 +13,7 @@ It's something like simple alternative to `dd` function from
23
13
 
24
14
  2. `dump <variable>` at your views. It's alternative for `debug` method from `ActionView::Helpers::DebugHelper`.
25
15
 
26
- 3. fix for `better_errors` and `binding_or_caller` performance
16
+ 3. temporary fix for `better_errors` and `binding_or_caller` performance [issue](https://github.com/charliesome/better_errors/issues/341).
27
17
 
28
18
  ## Installation
29
19
 
@@ -39,20 +29,20 @@ And then execute:
39
29
 
40
30
  Or you can install it using [rgversion](https://github.com/vavgustov/rgversion) like any other gems.
41
31
 
42
- ## Samples
32
+ ## Screenshots
33
+
34
+ `dd` from controller/model/service/etc:
43
35
 
44
36
  ```ruby
45
- dd self.instance_variables
37
+ dd Book.all
46
38
  ```
47
39
 
48
- ![image](https://user-images.githubusercontent.com/312873/28998770-ddfc7b74-7a3b-11e7-905b-52b3c1c797a4.png)
40
+ ![image](https://user-images.githubusercontent.com/312873/29333319-0480bb34-820c-11e7-82b0-3d2e648a4af8.png)
41
+
42
+ `dump` from views:
49
43
 
50
44
  ```erb
51
- <%= rap self.instance_variables %>
45
+ <%= dump Book.all %>
52
46
  ```
53
47
 
54
- ![image](https://user-images.githubusercontent.com/312873/28998927-9111f88a-7a3f-11e7-9c8d-cb825472d8ca.png)
55
-
56
-
57
-
58
-
48
+ ![image](https://user-images.githubusercontent.com/312873/29333320-0482b484-820c-11e7-87ce-800e5319ce98.png)
@@ -50,7 +50,7 @@ module DebugExtras
50
50
  output = ""
51
51
 
52
52
  dump.split("<").map.with_index do |v, k|
53
- if v.include? ":0x" and not v.include? "kbd"
53
+ if v.include? ":0x" and not (v.include? "kbd" or v.include? "pre")
54
54
  v.sub!(">", "")
55
55
  else
56
56
  output << "<" unless k.zero?
@@ -1,13 +1,18 @@
1
1
  module DebugExtras
2
- class Middleware
2
+ class Debug
3
3
  def initialize(app)
4
4
  @app = app
5
5
  end
6
6
 
7
7
  def call(env)
8
- better_errors_fix env
9
8
  @app.call env
10
9
  rescue StandardError => ex
10
+ process_exception(ex, env)
11
+ end
12
+
13
+ private
14
+
15
+ def process_exception(ex, env)
11
16
  if [ex.class, ex.cause.class].map(&:to_s).include? "DebugExtras::DebugData"
12
17
  debug_page = DebugPage.new(ex, env["PATH_INFO"])
13
18
  [200, { "Content-Type" => "text/html; charset=utf-8" }, [debug_page.render]]
@@ -15,12 +20,5 @@ module DebugExtras
15
20
  @app.call env
16
21
  end
17
22
  end
18
-
19
- private
20
-
21
- # based on https://github.com/charliesome/better_errors/issues/341
22
- def better_errors_fix(env)
23
- env["puma.config"].options.user_options.delete(:app) if env.has_key?("puma.config")
24
- end
25
23
  end
26
- end
24
+ end
@@ -0,0 +1,13 @@
1
+ module DebugExtras
2
+ # based on https://github.com/charliesome/better_errors/issues/341 proposals
3
+ class FastBetterErrors
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ env["puma.config"].options.user_options.delete(:app) if env.has_key?("puma.config")
10
+ @app.call env
11
+ end
12
+ end
13
+ end
@@ -1,17 +1,34 @@
1
+ require "debug_extras/middleware/debug"
2
+ require "debug_extras/middleware/fast_better_errors"
3
+
1
4
  module DebugExtras
2
5
  class Railtie < Rails::Railtie
3
6
  initializer "debug_extras.configure_rails_initialization" do
4
- if defined? ActionDispatch::DebugExceptions
5
- app.middleware.insert_after ActionDispatch::DebugExceptions, DebugExtras::Middleware
6
- else
7
- app.middleware.use DebugExtras::Middleware
7
+ if Rails.env.development?
8
+ insert_middleware(DebugExtras::Debug)
9
+ insert_middleware(DebugExtras::FastBetterErrors) if better_errors_slow?
8
10
  end
9
11
  end
10
12
 
11
13
  private
12
14
 
15
+ def insert_middleware(middleware)
16
+ if defined? BetterErrors::Middleware
17
+ app.middleware.insert_before ActionDispatch::Reloader, middleware
18
+ elsif defined? ActionDispatch::DebugExceptions
19
+ app.middleware.insert_after ActionDispatch::DebugExceptions, middleware
20
+ else
21
+ app.middleware.use middleware
22
+ end
23
+ end
24
+
25
+ def better_errors_slow?
26
+ return false unless defined? BetterErrors && defined? Puma
27
+ BetterErrors.binding_of_caller_available && [Rails.version, Puma::Const::PUMA_VERSION].map(&:to_i) == [5, 3]
28
+ end
29
+
13
30
  def app
14
31
  Rails.application
15
32
  end
16
33
  end
17
- end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module DebugExtras
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debug-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Avgustov
@@ -127,7 +127,8 @@ files:
127
127
  - lib/debug_extras/dumper.rb
128
128
  - lib/debug_extras/exceptions.rb
129
129
  - lib/debug_extras/helpers/view_helpers.rb
130
- - lib/debug_extras/middleware.rb
130
+ - lib/debug_extras/middleware/debug.rb
131
+ - lib/debug_extras/middleware/fast_better_errors.rb
131
132
  - lib/debug_extras/railtie.rb
132
133
  - lib/debug_extras/settings.rb
133
134
  - lib/debug_extras/templates/debug.html.erb