razing_ruby 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/lib/.DS_Store +0 -0
- data/lib/razing_ruby/.DS_Store +0 -0
- data/lib/razing_ruby/exception.rb +39 -0
- data/lib/razing_ruby/kernel.rb +57 -0
- data/lib/razing_ruby/version.rb +3 -0
- data/lib/razing_ruby.rb +4 -0
- data/razing_ruby.gemspec +23 -0
- metadata +92 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Kelly Becker
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# RazingRuby
|
2
|
+
|
3
|
+
Extends system level debug tools to help you find bugs both in development and production.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'razing_ruby', require: ['razing_ruby/kernel', 'razing_ruby/exception']
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install razing_ruby
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
**Kernel#set_trace_func**
|
22
|
+
|
23
|
+
You can add additional **Kernel#set_trace_func** handlers by running `set_trace_func multiple` times; which will return the index to remove it later with **Kernel#unset_trace_func_index**.
|
24
|
+
|
25
|
+
`set_trace_func` also now accepts a block or a proc argument with the argument taking precendence.
|
26
|
+
|
27
|
+
**Kernel#set_raise_func**
|
28
|
+
|
29
|
+
You can now add additional **Kernel#raise** handlers! When you use `set_raise_func`; which operates just as `set_trace_func` above; you can now handle exceptions with multiple providers. This is useful if you want to send every exception to Graylog 2 or Airbrake. It also means you will be able to send more exceptions since it integrates directly into Kernel#raise!
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it ( http://github.com/<my-github-username>/razing_ruby/fork )
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/.DS_Store
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Exception
|
2
|
+
attr_reader :call_binding
|
3
|
+
|
4
|
+
def raze_initialize(*a, &b)
|
5
|
+
# Find the calling location
|
6
|
+
expected_file, expected_line = caller(1).first.split(':')[0,2]
|
7
|
+
expected_line = expected_line.to_i
|
8
|
+
return_count = 5 # If we see more than 5 returns, stop tracing
|
9
|
+
|
10
|
+
# Find our caller in the midst of the trace
|
11
|
+
find_binding = Proc.new do |event, file, line, id, binding, kls|
|
12
|
+
if file == expected_file && line == expected_line
|
13
|
+
# Found it: Save the binding and stop tracing
|
14
|
+
@call_binding = binding
|
15
|
+
unset_trace_func(find_binding)
|
16
|
+
end
|
17
|
+
|
18
|
+
if event == :return
|
19
|
+
# Seen too many returns, give up. :-(
|
20
|
+
unset_trace_func(find_binding) if (return_count -= 1) <= 0
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Start tracing until we see our caller.
|
25
|
+
set_trace_func(find_binding)
|
26
|
+
ruby_initialize(*a, &b)
|
27
|
+
set_backtrace(caller(3))
|
28
|
+
|
29
|
+
# Hitup our exception handlers
|
30
|
+
Kernel.raze_raise_funcs.each { |p| p.call(self) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def call_variables
|
34
|
+
eval('local_variables.reduce({}) { |o, l| o.merge(l => eval("#{l}")) }', call_binding)
|
35
|
+
end
|
36
|
+
|
37
|
+
alias_method :ruby_initialize, :initialize
|
38
|
+
alias_method :initialize, :raze_initialize
|
39
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Kernel
|
2
|
+
#####################
|
3
|
+
#= Ruby Trace Func =#
|
4
|
+
#####################
|
5
|
+
|
6
|
+
def raze_trace_funcs
|
7
|
+
@@raze_trace_funcs ||= []
|
8
|
+
end
|
9
|
+
|
10
|
+
def raze_set_trace_func(proc = nil, &block)
|
11
|
+
return false unless (proc ||= block).is_a?(Proc)
|
12
|
+
ruby_set_trace_func(Proc.new{ |*a, &b|
|
13
|
+
Kernel.raze_trace_funcs.each { |p| p.call(*a, &b) }
|
14
|
+
}) if Kernel.raze_trace_funcs.empty?
|
15
|
+
(Kernel.raze_trace_funcs << proc).index(proc)
|
16
|
+
end
|
17
|
+
|
18
|
+
def raze_unset_trace_func(proc = nil, &block)
|
19
|
+
Kernel.raze_trace_funcs.delete(proc ||= block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def raze_unset_trace_func_index(index)
|
23
|
+
Kernel.raze_trace_funcs.delete_at(index)
|
24
|
+
end
|
25
|
+
|
26
|
+
alias_method :ruby_set_trace_func, :set_trace_func
|
27
|
+
alias_method :set_trace_func, :raze_set_trace_func
|
28
|
+
alias_method :unset_trace_func, :raze_unset_trace_func
|
29
|
+
alias_method :unset_trace_func_index, :raze_unset_trace_func_index
|
30
|
+
alias_method :trace_funcs, :raze_trace_funcs
|
31
|
+
|
32
|
+
################
|
33
|
+
#= Ruby Raise =#
|
34
|
+
################
|
35
|
+
|
36
|
+
def raze_raise_funcs
|
37
|
+
@@raze_raise_funcs ||= []
|
38
|
+
end
|
39
|
+
|
40
|
+
def raze_set_raise_func(proc = nil, &block)
|
41
|
+
return false unless (proc ||= block).is_a?(Proc)
|
42
|
+
(Kernel.raze_raise_funcs << proc).index(proc)
|
43
|
+
end
|
44
|
+
|
45
|
+
def raze_unset_raise_func(proc = nil, &block)
|
46
|
+
Kernel.raze_raise_funcs.delete(proc ||= block)
|
47
|
+
end
|
48
|
+
|
49
|
+
def raze_unset_raise_func_index(index)
|
50
|
+
Kernel.raze_raise_funcs.delete_at(index)
|
51
|
+
end
|
52
|
+
|
53
|
+
alias_method :set_raise_func, :raze_set_raise_func
|
54
|
+
alias_method :unset_raise_func, :raze_unset_raise_func
|
55
|
+
alias_method :unset_raise_func_index, :raze_unset_raise_func_index
|
56
|
+
alias_method :raise_funcs, :raze_raise_funcs
|
57
|
+
end
|
data/lib/razing_ruby.rb
ADDED
data/razing_ruby.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'razing_ruby/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "razing_ruby"
|
8
|
+
spec.version = RazingRuby::VERSION
|
9
|
+
spec.authors = ["Kelly Becker"]
|
10
|
+
spec.email = ["kellylsbkr@gmail.com"]
|
11
|
+
spec.summary = %q{Don't raise ruby... Raze ruby and find that bug}
|
12
|
+
spec.description = %q{Extends system level debug tools to help you find bugs both in development and production}
|
13
|
+
spec.homepage = "http://kellybecker.me"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: razing_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kelly Becker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.5'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.5'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Extends system level debug tools to help you find bugs both in development
|
47
|
+
and production
|
48
|
+
email:
|
49
|
+
- kellylsbkr@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- lib/.DS_Store
|
60
|
+
- lib/razing_ruby.rb
|
61
|
+
- lib/razing_ruby/.DS_Store
|
62
|
+
- lib/razing_ruby/exception.rb
|
63
|
+
- lib/razing_ruby/kernel.rb
|
64
|
+
- lib/razing_ruby/version.rb
|
65
|
+
- razing_ruby.gemspec
|
66
|
+
homepage: http://kellybecker.me
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.23
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: Don't raise ruby... Raze ruby and find that bug
|
91
|
+
test_files: []
|
92
|
+
has_rdoc:
|