peekaboo 0.2.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.1 (November 4, 2010)
2
+
3
+ Bugfix:
4
+
5
+ - Fixed `.enable_tracing_on` to work with both Ruby version 1.8.7 and 1.9.2
6
+
1
7
  ## 0.2.0 (October 28, 2010)
2
8
 
3
9
  Features:
@@ -3,7 +3,7 @@ module Peekaboo
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 2
6
- PATCH = 0
6
+ PATCH = 1
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH].join('.')
9
9
  end
data/lib/peekaboo.rb CHANGED
@@ -115,7 +115,8 @@ module Peekaboo
115
115
  method_names.each do |method_name|
116
116
  unless peek_list.include? method_name
117
117
  peek_list << method_name
118
- Peekaboo.wrap_method self, method_name if self.instance_methods(false).include? method_name.to_s
118
+ method_list = self.instance_methods(false).map(&:to_sym)
119
+ Peekaboo.wrap_method self, method_name if method_list.include? method_name
119
120
  else
120
121
  raise "Already tracing `#{method_name}'"
121
122
  end
@@ -97,9 +97,11 @@ describe Peekaboo do
97
97
  end
98
98
 
99
99
  it "should show methods that raise an exception" do
100
- @tracer.should_receive(:info).
101
- with trace_message %{Invoking: #{@test_class}#method_raises with [] !!! Raising: "something went wrong"}
102
- lambda { @test_instance.method_raises }.should raise_exception
100
+ lambda do
101
+ @tracer.should_receive(:info).
102
+ with trace_message %{Invoking: #{@test_class}#method_raises with [] !!! Raising: "something went wrong"}
103
+ @test_instance.method_raises
104
+ end.should raise_exception
103
105
  end
104
106
  end
105
107
 
data/spec/spec_helper.rb CHANGED
@@ -36,9 +36,24 @@ Spec::Runner.configure do |config|
36
36
  end
37
37
 
38
38
  def trace_message contents, offset = 1
39
- file_and_line = caller(1)[0]
40
- file, line = file_and_line.split(':')
41
- line = line.to_i + offset
42
- "#{file}:#{line}\n\t( #{contents} )"
39
+ file, line, method = CallChain.parse_caller(caller(1).first)
40
+ line += offset
41
+
42
+ if RUBY_VERSION < '1.9'
43
+ "#{file}:#{line}\n\t( #{contents} )"
44
+ else
45
+ "#{file}:#{line}:in `#{method}'\n\t( #{contents} )"
46
+ end
47
+ end
48
+
49
+ class CallChain
50
+ def self.parse_caller(at)
51
+ if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
52
+ file = Regexp.last_match[1]
53
+ line = Regexp.last_match[2].to_i
54
+ method = Regexp.last_match[3]
55
+ [file, line, method]
56
+ end
57
+ end
43
58
  end
44
59
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peekaboo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 2
9
- - 0
10
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - Sonny Ruben Garcia
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-10-28 00:00:00 -05:00
17
+ date: 2010-11-04 00:00:00 -05:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - "="
28
27
  - !ruby/object:Gem::Version
29
- hash: 27
30
28
  segments:
31
29
  - 1
32
30
  - 3
@@ -42,7 +40,6 @@ dependencies:
42
40
  requirements:
43
41
  - - "="
44
42
  - !ruby/object:Gem::Version
45
- hash: 41
46
43
  segments:
47
44
  - 0
48
45
  - 9
@@ -58,7 +55,6 @@ dependencies:
58
55
  requirements:
59
56
  - - "="
60
57
  - !ruby/object:Gem::Version
61
- hash: 5
62
58
  segments:
63
59
  - 0
64
60
  - 6
@@ -101,7 +97,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
97
  requirements:
102
98
  - - ">="
103
99
  - !ruby/object:Gem::Version
104
- hash: 3
105
100
  segments:
106
101
  - 0
107
102
  version: "0"
@@ -110,7 +105,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
105
  requirements:
111
106
  - - ">="
112
107
  - !ruby/object:Gem::Version
113
- hash: 3
114
108
  segments:
115
109
  - 0
116
110
  version: "0"