spit 0.1.2 → 0.1.3
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/README.rdoc +11 -3
- data/VERSION +1 -1
- data/lib/spit.rb +39 -15
- data/spit.gemspec +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -2,15 +2,23 @@
|
|
2
2
|
|
3
3
|
Spit variables out to your log in a noticeable color. It adds a sensible label automatically.
|
4
4
|
|
5
|
-
== Usage
|
5
|
+
== Usage Examples
|
6
6
|
|
7
7
|
You use it by doing something like this:
|
8
8
|
|
9
9
|
Spit account
|
10
10
|
|
11
|
-
And it puts something like this in the log output:
|
11
|
+
And it puts something like this in the log output (but with color):
|
12
12
|
|
13
|
-
|
13
|
+
account: <#Account @name="Steve">
|
14
|
+
|
15
|
+
To show the source of the line (filename, method, and line number) do something like this:
|
16
|
+
|
17
|
+
Spit.s account
|
18
|
+
|
19
|
+
And it puts something like this in the log output (but with color):
|
20
|
+
|
21
|
+
foo_controller.index(38) account: <#Account @name="Steve">
|
14
22
|
|
15
23
|
== The Point
|
16
24
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/spit.rb
CHANGED
@@ -1,22 +1,46 @@
|
|
1
1
|
def Spit txt
|
2
|
-
|
2
|
+
Spit.print txt, caller[0]
|
3
|
+
end
|
4
|
+
|
5
|
+
module Spit
|
6
|
+
def self.s txt
|
7
|
+
self.print txt, caller[0], :source=>true
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.print txt, line, options={}
|
11
|
+
|
12
|
+
txt = txt.inspect rescue txt
|
13
|
+
|
14
|
+
path, number = line.match(/(.+):(\d+)/)[1..2]
|
15
|
+
|
16
|
+
label = IO.readlines("/projects/homerun/homerun/app/controllers/web/dev_controller.rb")[number.to_i - 1]
|
17
|
+
label.strip!.sub!(/Spit\S+ /, '')
|
18
|
+
|
19
|
+
label = "#{Spit.extract_label(Spit.parse_line line)} #{label}" if options[:source]
|
3
20
|
|
4
|
-
|
21
|
+
clear, green, red, yellow, blue, pink, italic, bold, highlight = "\e[0m", "\e[32m", "\e[31m", "\e[33m", "\e[36m", "\e[35m", "\e[3m", "\e[1m", "\e[7m"
|
22
|
+
puts "#{green}#{italic}#{label}:#{clear}#{bold}#{yellow} #{txt}#{clear}"
|
5
23
|
|
6
|
-
|
24
|
+
# clear, green, red, yellow, blue, pink, gray, italic, bold = "\e[0m", "\e[32m", "\e[31m", "\e[33m", "\e[36m", "\e[35m", "\e[164m", "\e[3m", "\e[1m"
|
25
|
+
# puts "#{red}#{txt}#{clear}"
|
26
|
+
# puts "#{green}#{label}:#{clear} #{green}#{highlight}#{txt}#{clear}"
|
27
|
+
# puts "#{green}#{label}:#{clear}#{highlight}#{green} #{txt}#{clear}"
|
28
|
+
# puts "#{gray}#{txt}:#{clear}#{yellow} #{txt}#{clear}"
|
29
|
+
# puts "#{red}#{txt}:#{clear}#{yellow} #{txt}#{clear}"
|
30
|
+
# puts "#{red}#{txt} #{clear} aa"
|
31
|
+
# puts "#{green}#{label}:#{clear} #{txt}\naaa"
|
7
32
|
|
8
|
-
|
9
|
-
label.strip!.sub!(/Ol /, '')
|
33
|
+
end
|
10
34
|
|
11
|
-
|
12
|
-
|
35
|
+
def self.parse_line path
|
36
|
+
method = path[/`(.+)'/, 1] # `
|
37
|
+
path, l = path.match(/(.+):(\d+)/)[1..2]
|
38
|
+
path = File.expand_path path
|
39
|
+
clazz = path[/.+\/(.+)\.rb/, 1]
|
40
|
+
{:path=>path, :line=>l, :method=>method, :clazz=>clazz}
|
41
|
+
end
|
13
42
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# puts "#{green}#{label}:#{clear}#{highlight}#{green} #{txt}#{clear}"
|
18
|
-
# puts "#{gray}#{txt}:#{clear}#{yellow} #{txt}#{clear}"
|
19
|
-
# puts "#{red}#{txt}:#{clear}#{yellow} #{txt}#{clear}"
|
20
|
-
# puts "#{red}#{txt} #{clear} aa"
|
21
|
-
# puts "#{green}#{label}:#{clear} #{txt}\naaa"
|
43
|
+
def self.extract_label h
|
44
|
+
"#{h[:clazz]}.#{h[:method]}(#{h[:line]})"
|
45
|
+
end
|
22
46
|
end
|
data/spit.gemspec
CHANGED
metadata
CHANGED