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 +4 -4
- data/README.md +11 -21
- data/lib/debug_extras/dumper.rb +1 -1
- data/lib/debug_extras/{middleware.rb → middleware/debug.rb} +8 -10
- data/lib/debug_extras/middleware/fast_better_errors.rb +13 -0
- data/lib/debug_extras/railtie.rb +22 -5
- data/lib/debug_extras/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 377e4b36eef7d82e29633387824887706ee7d937
|
4
|
+
data.tar.gz: fa54e8daab506a47c6fc1fd977547a7631bf1783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 [](https://rubygems.org/gems/debug-extras) [](https://travis-ci.org/vavgustov/debug-extras) [](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
|
-
##
|
32
|
+
## Screenshots
|
33
|
+
|
34
|
+
`dd` from controller/model/service/etc:
|
43
35
|
|
44
36
|
```ruby
|
45
|
-
dd
|
37
|
+
dd Book.all
|
46
38
|
```
|
47
39
|
|
48
|
-

|
41
|
+
|
42
|
+
`dump` from views:
|
49
43
|
|
50
44
|
```erb
|
51
|
-
<%=
|
45
|
+
<%= dump Book.all %>
|
52
46
|
```
|
53
47
|
|
54
|
-

|
data/lib/debug_extras/dumper.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
module DebugExtras
|
2
|
-
class
|
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
|
data/lib/debug_extras/railtie.rb
CHANGED
@@ -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
|
5
|
-
|
6
|
-
|
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
|
data/lib/debug_extras/version.rb
CHANGED
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.
|
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
|