debug-extras 0.1.0 → 0.2.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 +4 -4
- data/lib/debug-extras.rb +16 -11
- data/lib/debug_extras/core_ext/object.rb +11 -0
- data/lib/debug_extras/error_page.rb +15 -0
- data/lib/debug_extras/exceptions.rb +3 -0
- data/lib/debug_extras/gem_version.rb +1 -1
- data/lib/debug_extras/helpers/view_helpers.rb +6 -34
- data/lib/debug_extras/middleware.rb +21 -0
- data/lib/debug_extras/railtie.rb +17 -0
- data/lib/debug_extras/settings.rb +9 -0
- data/lib/debug_extras/templates/main.html.erb +39 -0
- metadata +9 -3
- data/lib/debug_extras/helpers/controller_helpers.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e28babbb91f3d8087f3fed430c67c8c4f6ab32d6
|
4
|
+
data.tar.gz: 29c8e723fc8c897a55150d4ebe5e81c0a6146adb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31b4776464461e21d70791796ee805bd7282a47d48cd3a31ce94ea4fa0a36f7414ec475750b72b222febac4451732b281bf1d8acb34299b9d480d3f631f7f01e
|
7
|
+
data.tar.gz: f9ff33003fbb0559a1100ab9bd3ec051b3c9ddf9a95008e8e035fece2adab39f5446363c7e296a31135eddf237122a5a82874d69583748108e063ac394017dcc
|
data/lib/debug-extras.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "debug_extras/version"
|
2
|
+
require "active_support/concern"
|
3
|
+
require "active_support/core_ext/string/output_safety"
|
4
|
+
require "active_support/dependencies/autoload"
|
5
|
+
require "active_support/lazy_load_hooks"
|
6
|
+
require "action_view/helpers/output_safety_helper"
|
7
|
+
require "awesome_print"
|
8
|
+
require "debug_extras/middleware"
|
9
|
+
require "debug_extras/core_ext/object"
|
10
|
+
require "debug_extras/helpers/view_helpers"
|
6
11
|
|
7
12
|
module DebugExtras
|
13
|
+
extend ActiveSupport::Autoload
|
14
|
+
|
15
|
+
autoload :Settings
|
16
|
+
|
8
17
|
ActiveSupport.on_load :action_view do
|
9
|
-
require 'debug_extras/helpers/view_helpers'
|
10
18
|
ActionView::Base.send :include, DebugExtras::Helpers::ViewHelpers
|
11
19
|
end
|
12
|
-
|
13
|
-
ActiveSupport.on_load :action_controller_base do
|
14
|
-
require 'debug_extras/helpers/controller_helpers'
|
15
|
-
ActionController::Base.send :include, DebugExtras::Helpers::ControllerHelpers
|
16
|
-
end
|
17
20
|
end
|
21
|
+
|
22
|
+
require "debug_extras/railtie" if defined? Rails::Railtie
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'debug_extras/exceptions'
|
2
|
+
|
3
|
+
class Object
|
4
|
+
def dd(message, settings = {})
|
5
|
+
prefix = message.class.to_s
|
6
|
+
prefix << "##{message.length}" if message.respond_to? :length
|
7
|
+
settings.merge! DebugExtras::Settings.ap_options
|
8
|
+
output = prefix + message.ai(settings)
|
9
|
+
raise DebugExtras::DebugData.new(output)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "erb"
|
2
|
+
|
3
|
+
module DebugExtras
|
4
|
+
class ErrorPage
|
5
|
+
def initialize(exception, request_path)
|
6
|
+
@exception = exception
|
7
|
+
@request_path = request_path
|
8
|
+
@template = File.read(File.expand_path("../templates/main.html.erb", __FILE__))
|
9
|
+
end
|
10
|
+
|
11
|
+
def render
|
12
|
+
ERB.new(@template).result( binding )
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,39 +1,11 @@
|
|
1
|
-
module DebugExtras
|
2
|
-
module
|
3
|
-
|
1
|
+
module DebugExtras
|
2
|
+
module Helpers
|
3
|
+
module ViewHelpers
|
4
|
+
extend ActiveSupport::Concern
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def object_dump(object, full = false)
|
10
|
-
output = ''
|
11
|
-
vars = object.instance_variables
|
12
|
-
|
13
|
-
output << pretty('object class')
|
14
|
-
output << pretty(object.class)
|
15
|
-
|
16
|
-
output << pretty('instance variables list')
|
17
|
-
output << pretty(vars)
|
18
|
-
|
19
|
-
output << pretty('instance variables details')
|
20
|
-
vars.each do |v|
|
21
|
-
output << pretty(v)
|
22
|
-
output << pretty(object.instance_variable_get(v))
|
6
|
+
def rap(object)
|
7
|
+
raw ap(object, DebugExtras::Settings.ap_options)
|
23
8
|
end
|
24
|
-
|
25
|
-
if full
|
26
|
-
output << pretty('methods list')
|
27
|
-
output << pretty(object.methods)
|
28
|
-
end
|
29
|
-
|
30
|
-
raw output
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def pretty(string)
|
36
|
-
string.ai
|
37
9
|
end
|
38
10
|
end
|
39
11
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'debug_extras/error_page'
|
2
|
+
|
3
|
+
module DebugExtras
|
4
|
+
class Middleware
|
5
|
+
def initialize(app)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env['puma.config'].options.user_options.delete(:app) if env.has_key?('puma.config')
|
11
|
+
@app.call env
|
12
|
+
rescue StandardError => ex
|
13
|
+
if [ex.class, ex.cause.class].map(&:to_s).include? 'DebugExtras::DebugData'
|
14
|
+
error_page = ErrorPage.new(ex, Rails.env["PATH_INFO"])
|
15
|
+
[200, { "Content-Type" => "text/html; charset=utf-8" }, [error_page.render]]
|
16
|
+
else
|
17
|
+
@app.call env
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module DebugExtras
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
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
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def app
|
14
|
+
Rails.application
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
7
|
+
<title><%= @request_path %></title>
|
8
|
+
|
9
|
+
<style>
|
10
|
+
body {
|
11
|
+
margin: 0;
|
12
|
+
padding: 15px;
|
13
|
+
color: #c52f24;
|
14
|
+
font-weight: bold;
|
15
|
+
font-size: 12px;
|
16
|
+
font-family: Menlo, Consolas, Ubuntu, monospace;
|
17
|
+
background: #f5f8fa;
|
18
|
+
}
|
19
|
+
|
20
|
+
.container {
|
21
|
+
width: 100%;
|
22
|
+
}
|
23
|
+
|
24
|
+
pre {
|
25
|
+
white-space: pre-wrap;
|
26
|
+
}
|
27
|
+
|
28
|
+
kbd {
|
29
|
+
background: none;
|
30
|
+
shadow: none;
|
31
|
+
}
|
32
|
+
</style>
|
33
|
+
</head>
|
34
|
+
<body>
|
35
|
+
<div class="container">
|
36
|
+
<%= @exception.message %>
|
37
|
+
</div>
|
38
|
+
</body>
|
39
|
+
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debug-extras
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Avgustov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,9 +122,15 @@ files:
|
|
122
122
|
- Rakefile
|
123
123
|
- debug-extras.gemspec
|
124
124
|
- lib/debug-extras.rb
|
125
|
+
- lib/debug_extras/core_ext/object.rb
|
126
|
+
- lib/debug_extras/error_page.rb
|
127
|
+
- lib/debug_extras/exceptions.rb
|
125
128
|
- lib/debug_extras/gem_version.rb
|
126
|
-
- lib/debug_extras/helpers/controller_helpers.rb
|
127
129
|
- lib/debug_extras/helpers/view_helpers.rb
|
130
|
+
- lib/debug_extras/middleware.rb
|
131
|
+
- lib/debug_extras/railtie.rb
|
132
|
+
- lib/debug_extras/settings.rb
|
133
|
+
- lib/debug_extras/templates/main.html.erb
|
128
134
|
- lib/debug_extras/version.rb
|
129
135
|
homepage: https://github.com/vavgustov/debug-extras
|
130
136
|
licenses:
|