rextra 2.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rextra/debug.rb +51 -0
- metadata +3 -2
data/lib/rextra/debug.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
################################################################################
|
2
|
+
module Rextra
|
3
|
+
module Debug
|
4
|
+
################################################################################
|
5
|
+
module DebugHelper
|
6
|
+
def self.prepare
|
7
|
+
output("\n" + Term::ANSIColor::yellow{ '_/\\_' * 20 }) if
|
8
|
+
(require('term/ansicolor') rescue nil)
|
9
|
+
end
|
10
|
+
################################################################################
|
11
|
+
def self.output *args
|
12
|
+
outs = [STDERR]
|
13
|
+
#outs << logger if defined? RAILS_ENV # FIXME
|
14
|
+
args.each do |arg|
|
15
|
+
outs.each do |out|
|
16
|
+
out.puts(
|
17
|
+
if defined? Term::ANSIColor
|
18
|
+
Term::ANSIColor::green { arg.to_s }
|
19
|
+
else
|
20
|
+
arg.to_s
|
21
|
+
end
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
################################################################################
|
28
|
+
if (defined? RAILS_ENV and RAILS_ENV != 'production') or $DEBUG or $REXTRA_DEBUG
|
29
|
+
def __here *args
|
30
|
+
__d(*['here'].concat(args))
|
31
|
+
end
|
32
|
+
def __d *args
|
33
|
+
DebugHelper::prepare
|
34
|
+
DebugHelper::output *args
|
35
|
+
end
|
36
|
+
def __e *args
|
37
|
+
require 'binding_of_caller'
|
38
|
+
Binding.of_caller do |b|
|
39
|
+
args.each do |arg|
|
40
|
+
__d "[[#{arg}]] ==>" , (eval(arg,b).to_yaml rescue '[ERROR OUTPUTING]')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
else
|
45
|
+
def __here(*args) end
|
46
|
+
def __d(*args) end
|
47
|
+
def __e(*args) end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
################################################################################
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rextra
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version:
|
7
|
-
date: 2006-10-
|
6
|
+
version: 2.0.1
|
7
|
+
date: 2006-10-30 00:00:00 -07:00
|
8
8
|
summary: Ruby extras.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/rextra/binding_of_caller.rb
|
39
39
|
- lib/rextra/bleeding.rb
|
40
40
|
- lib/rextra/cutting.rb
|
41
|
+
- lib/rextra/debug.rb
|
41
42
|
- lib/rextra/enddata.rb
|
42
43
|
- README
|
43
44
|
test_files:
|