interception 0.3 → 0.4
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 +7 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +1 -1
- data/README.md +2 -1
- data/ext/extconf.rb +3 -1
- data/ext/interception.c +13 -4
- data/interception.gemspec +1 -1
- data/lib/interception.rb +23 -2
- metadata +25 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f0ebd4b7db1148fb11059cb84d5a519197a95ef8
|
4
|
+
data.tar.gz: a8492711364f1614140dfb76107b61a1d56d2fee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ba1c3eaec141e8bec83833be3ac36eeb9f51b6611300a25d2fa5184b83ffc41c577d67d3e4881b49af7e322d753abb70e93caeea527b90be06f93086d02aa0a
|
7
|
+
data.tar.gz: 4d94822f309263068cab75ef2c4b3a24c4a0ed94e17966c73dc71c7782c77c12726eaaf39f2e5e09238b4d3f6dfbc10931e95e0300b50a1d43db21701d317335
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
gemspec
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ gem install interception
|
|
14
14
|
Or, if you're using bundler:
|
15
15
|
|
16
16
|
```ruby
|
17
|
-
source
|
17
|
+
source 'https://rubygems.org'
|
18
18
|
gem 'interception'
|
19
19
|
```
|
20
20
|
|
@@ -76,6 +76,7 @@ Known bugs
|
|
76
76
|
* On rubinius we don't catch some low-level exceptions (like `ZeroDivisionError`).
|
77
77
|
* On jruby 1.6, the binding has the wrong value for `self` in `NoMethodError`s. ([fixed](https://github.com/jruby/jruby/commit/4246d96f63155aeb70694a9a0ace0eeb2c936065) in jruby-head)
|
78
78
|
* On MRI-1.8.7, the binding sometimes has the wrong value for `self`.
|
79
|
+
* The Interception versions prior to `0.4` **do not** support MRI-2.1.0. `0.4` does support it.
|
79
80
|
|
80
81
|
Meta-fu
|
81
82
|
=======
|
data/ext/extconf.rb
CHANGED
@@ -10,7 +10,9 @@ if RbConfig::CONFIG['ruby_install_name'] == 'jruby'
|
|
10
10
|
elsif RbConfig::CONFIG['ruby_install_name'] =~ /^ruby/
|
11
11
|
|
12
12
|
require 'mkmf'
|
13
|
-
$CFLAGS += " -DRUBY_18" if
|
13
|
+
$CFLAGS += " -DRUBY_18" if RUBY_VERSION =~ /^(1.8)/
|
14
|
+
$CFLAGS += " -DRUBY_19" if RUBY_VERSION =~ /^(1.9)/
|
15
|
+
$CFLAGS += " -DRUBY_20" if RUBY_VERSION =~ /^(2.0)/
|
14
16
|
extension_name = "interception"
|
15
17
|
dir_config(extension_name)
|
16
18
|
create_makefile(extension_name)
|
data/ext/interception.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
static VALUE rb_mInterception;
|
4
4
|
|
5
|
-
|
5
|
+
struct FRAME {
|
6
6
|
VALUE self;
|
7
7
|
int argc;
|
8
8
|
ID last_func;
|
@@ -39,7 +39,14 @@ interception_start(VALUE self)
|
|
39
39
|
return Qnil;
|
40
40
|
}
|
41
41
|
|
42
|
-
|
42
|
+
VALUE
|
43
|
+
interception_stop(VALUE self)
|
44
|
+
{
|
45
|
+
rb_remove_event_hook(interception_hook);
|
46
|
+
return Qnil;
|
47
|
+
}
|
48
|
+
|
49
|
+
#elif RUBY_19 || RUBY_20
|
43
50
|
|
44
51
|
void
|
45
52
|
interception_hook(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
|
@@ -55,19 +62,21 @@ interception_start(VALUE self)
|
|
55
62
|
return Qnil;
|
56
63
|
}
|
57
64
|
|
58
|
-
#endif
|
59
|
-
|
60
65
|
VALUE
|
61
66
|
interception_stop(VALUE self)
|
62
67
|
{
|
63
68
|
rb_remove_event_hook(interception_hook);
|
64
69
|
return Qnil;
|
65
70
|
}
|
71
|
+
#endif
|
66
72
|
|
67
73
|
void
|
68
74
|
Init_interception()
|
69
75
|
{
|
70
76
|
rb_mInterception = rb_define_module("Interception");
|
77
|
+
|
78
|
+
#if defined(RUBY_18) || defined(RUBY_19) || defined(RUBY_20)
|
71
79
|
rb_define_singleton_method(rb_mInterception, "start", interception_start, 0);
|
72
80
|
rb_define_singleton_method(rb_mInterception, "stop", interception_stop, 0);
|
81
|
+
#endif
|
73
82
|
}
|
data/interception.gemspec
CHANGED
data/lib/interception.rb
CHANGED
@@ -110,11 +110,32 @@ module Interception
|
|
110
110
|
|
111
111
|
# Start sending events to rescue.
|
112
112
|
# Implemented per-platform
|
113
|
-
|
113
|
+
# @note For Ruby 2.1 we use the new TracePoint API.
|
114
|
+
def self.start
|
115
|
+
if ruby_21?
|
116
|
+
@tracepoint ||= TracePoint.new(:raise) do |tp|
|
117
|
+
self.rescue(tp.raised_exception, tp.binding)
|
118
|
+
end
|
119
|
+
|
120
|
+
@tracepoint.enable
|
121
|
+
else
|
122
|
+
raise NotImplementedError
|
123
|
+
end
|
124
|
+
end
|
114
125
|
|
115
126
|
# Stop sending events to rescue.
|
116
127
|
# Implemented per-platform
|
117
|
-
def self.stop
|
128
|
+
def self.stop
|
129
|
+
if ruby_21?
|
130
|
+
@tracepoint.disable
|
131
|
+
else
|
132
|
+
raise NotImplementedError
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.ruby_21?
|
137
|
+
RUBY_VERSION == '2.1.0' && RUBY_ENGINE == 'ruby'
|
138
|
+
end
|
118
139
|
|
119
140
|
require File.expand_path('../cross_platform.rb', __FILE__)
|
120
141
|
end
|
metadata
CHANGED
@@ -1,38 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interception
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
5
|
-
prerelease:
|
4
|
+
version: '0.4'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Conrad Irwin
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
none: false
|
21
20
|
type: :development
|
22
21
|
prerelease: false
|
23
|
-
|
24
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
|
-
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
27
30
|
requirements:
|
28
|
-
- -
|
31
|
+
- - '>='
|
29
32
|
- !ruby/object:Gem::Version
|
30
33
|
version: '0'
|
31
|
-
none: false
|
32
34
|
type: :development
|
33
35
|
prerelease: false
|
34
|
-
|
35
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
description: Provides a cross-platform ability to intercept all exceptions as they
|
37
42
|
are raised.
|
38
43
|
email: conrad.irwin@gmail.com
|
@@ -43,6 +48,7 @@ extra_rdoc_files: []
|
|
43
48
|
files:
|
44
49
|
- .gitignore
|
45
50
|
- .travis.yml
|
51
|
+
- CHANGELOG.md
|
46
52
|
- Gemfile
|
47
53
|
- LICENSE.MIT
|
48
54
|
- README.md
|
@@ -59,26 +65,26 @@ files:
|
|
59
65
|
- spec/spec_helpers.rb
|
60
66
|
homepage: http://github.com/ConradIrwin/interception
|
61
67
|
licenses: []
|
68
|
+
metadata: {}
|
62
69
|
post_install_message:
|
63
70
|
rdoc_options: []
|
64
71
|
require_paths:
|
65
72
|
- lib
|
66
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
74
|
requirements:
|
68
|
-
- -
|
75
|
+
- - '>='
|
69
76
|
- !ruby/object:Gem::Version
|
70
77
|
version: '0'
|
71
|
-
none: false
|
72
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
79
|
requirements:
|
74
|
-
- -
|
80
|
+
- - '>='
|
75
81
|
- !ruby/object:Gem::Version
|
76
82
|
version: '0'
|
77
|
-
none: false
|
78
83
|
requirements: []
|
79
84
|
rubyforge_project:
|
80
|
-
rubygems_version:
|
85
|
+
rubygems_version: 2.0.3
|
81
86
|
signing_key:
|
82
|
-
specification_version:
|
87
|
+
specification_version: 4
|
83
88
|
summary: Intercept exceptions as they are being raised
|
84
89
|
test_files: []
|
90
|
+
has_rdoc:
|