log_buddy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Rakefile +2 -0
- data/lib/log_buddy.rb +10 -6
- data/log_buddy.gemspec +1 -1
- data/spec/helper.rb +1 -1
- data/spec/log_buddy_spec.rb +9 -0
- metadata +1 -1
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/lib/log_buddy.rb
CHANGED
@@ -16,7 +16,7 @@ Examples:
|
|
16
16
|
|
17
17
|
=end
|
18
18
|
class LogBuddy
|
19
|
-
VERSION = '0.1.
|
19
|
+
VERSION = '0.1.1'
|
20
20
|
|
21
21
|
# Use LogBuddy!
|
22
22
|
def self.init(options = {})
|
@@ -46,11 +46,15 @@ class LogBuddy
|
|
46
46
|
def d(msg = nil, &blk)
|
47
47
|
LogBuddy.debug(msg) if msg
|
48
48
|
return unless block_given?
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
begin
|
50
|
+
logged_line = LogBuddy.read_line(caller[0])
|
51
|
+
arguments = LogBuddy.parse_args(logged_line)
|
52
|
+
arguments.each do |arg|
|
53
|
+
result = eval(arg, blk.binding)
|
54
|
+
LogBuddy.debug(%[#{arg} = '#{result}'\n])
|
55
|
+
end
|
56
|
+
rescue Exception => e
|
57
|
+
LogBuddy.debug "LogBuddy caught an exception: #{e.message}"
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
data/log_buddy.gemspec
CHANGED
data/spec/helper.rb
CHANGED
@@ -3,7 +3,7 @@ require "test/unit"
|
|
3
3
|
require "test/spec"
|
4
4
|
require "test/spec/should-output"
|
5
5
|
require "mocha"
|
6
|
-
require "redgreen"
|
6
|
+
require "redgreen" unless Object.const_defined?("TextMate")
|
7
7
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "log_buddy"))
|
8
8
|
|
9
9
|
def silence_warnings
|
data/spec/log_buddy_spec.rb
CHANGED
@@ -8,6 +8,10 @@ module SomeModule
|
|
8
8
|
def self.message
|
9
9
|
"hello"
|
10
10
|
end
|
11
|
+
|
12
|
+
def self.raise_exception
|
13
|
+
raise Exception
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
describe "LogBuddy" do
|
@@ -109,5 +113,10 @@ describe "LogBuddy" do
|
|
109
113
|
LogBuddy.expects(:debug).with(%[@ivar1 = '1'\n])
|
110
114
|
d { local1; local2; @ivar1 }
|
111
115
|
end
|
116
|
+
|
117
|
+
it "should gracefully handle exceptions" do
|
118
|
+
LogBuddy.expects(:debug).with('LogBuddy caught an exception: Exception')
|
119
|
+
d { SomeModule.raise_exception }
|
120
|
+
end
|
112
121
|
end
|
113
122
|
end
|