lib/ruby-dbg.rb in ruby-dbg-0.0.1 vs lib/ruby-dbg.rb in ruby-dbg-0.1.0
- old
+ new
@@ -16,11 +16,11 @@
def self.colorize(str, color_code)
"\e[#{color_code}m#{str}\e[0m"
end
- def self.dbg(*objs)
+ def self.dbg!(*msgs)
loc = caller_locations.first(2).last.to_s
matching_loc = loc.match(/.+(rb)\:\d+\:(in)\s/)
src = if !matching_loc.nil?
matching_loc[0][0..-5]
else
@@ -28,13 +28,13 @@
end
file, line = src.split(":")
file = file.split("/").last(2).join("/")
src = "[#{file}:#{line}]"
- objs.each_with_index do |obj, i|
+ msgs.each_with_index do |obj, i|
first = i == 0
- last = i == (objs.size - 1)
+ last = i == (msgs.size - 1)
val = if obj.is_a?(Symbol)
begin
if (val = binding.of_caller(3).local_variable_get(obj))
val = format_val(val)
@@ -65,10 +65,12 @@
output = colorize(output, @@color_code)
end
puts output
end
+
+ nil
end
def self.format_val(val)
if val.nil?
"nil"
@@ -78,9 +80,8 @@
val
end
end
end
-def dbg!(*objs)
- RubyDBG.dbg(*objs)
- nil
+def dbg!(*msgs)
+ RubyDBG.dbg!(*msgs)
end