Skip to content

Commit

Permalink
RuboCop auto-corrected stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MadBomber committed Oct 2, 2014
1 parent 926af01 commit 378101b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 36 deletions.
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
require "bundler/gem_tasks"

require 'bundler/gem_tasks'
22 changes: 11 additions & 11 deletions debug_me.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'debug_me/version'

Gem::Specification.new do |spec|
spec.name = "debug_me"
spec.name = 'debug_me'
spec.version = DebugMe::VERSION
spec.authors = ["Dewayne VanHoozer"]
spec.email = ["dvanhoozer@gmail.com"]
spec.summary = "A tool to print the labeled value of variables."
spec.description = %q{This thing is pretty old. There are much better
spec.authors = ['Dewayne VanHoozer']
spec.email = ['dvanhoozer@gmail.com']
spec.summary = 'A tool to print the labeled value of variables.'
spec.description = 'This thing is pretty old. There are much better
ways of debugging in a complex application. But,
you know, I keep returning to this little method
time after time. I guess that marks me as a geezer.}
spec.homepage = "http://github.com/MadBomber/debug_me"
spec.license = "You want it, its yours"
time after time. I guess that marks me as a geezer.'
spec.homepage = 'http://github.com/MadBomber/debug_me'
spec.license = 'You want it, its yours'

spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency 'bundler', '~> 1.7'
spec.add_development_dependency 'rake', '~> 10.0'
end
40 changes: 18 additions & 22 deletions lib/debug_me.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
require 'pp'
require "debug_me/version"
require 'debug_me/version'

module DebugMe

def debug_me( options={}, &block )

def debug_me(options = {}, &block)
default_options = {
:tag => 'DEBUG:', # A tag to prepend to each output line
:time => true, # Include a time-stamp in front of the tag
:header => true, # Print a header string before printing the variables
:ivar => true, # Include instance variables in the output
:cvar => true, # Include class variables in the output
:file => $stdout # The output file
tag: 'DEBUG:', # A tag to prepend to each output line
time: true, # Include a time-stamp in front of the tag
header: true, # Print a header string before printing the variables
ivar: true, # Include instance variables in the output
cvar: true, # Include class variables in the output
file: $stdout # The output file
}

if 'Hash' == options.class.to_s
options = default_options.merge(options)
else
options = default_options.merge({:tag => options})
options = default_options.merge(tag: options)
end

f = options[:file]
s = ""
s = ''
s += "#{sprintf('%010.6f', Time.now.to_f)} " if options[:time]
s += " #{options[:tag]}"
wf = caller # where_from under 1.8.6 its a stack trace array under 1.8.7 is a string
Expand All @@ -31,30 +29,28 @@ def debug_me( options={}, &block )

if block_given?

block_value = [ block.call ].flatten.compact
block_value = [block.call].flatten.compact

if block_value.empty?
block_value = eval('local_variables', block.binding)
block_value += [ eval('instance_variables', block.binding) ] if options[:ivar]
block_value += [ self.class.send('class_variables') ] if options[:cvar]
block_value += [eval('instance_variables', block.binding)] if options[:ivar]
block_value += [self.class.send('class_variables')] if options[:cvar]
block_value = block_value.flatten.compact
else
block_value.map! { |v| v.to_s }
block_value.map!(&:to_s)
end

block_value.each do |v|
ev = eval(v, block.binding)
f.puts "#{s} #{v} -=> #{pp ev}" #.pretty_inspect}"
f.puts "#{s} #{v} -=> #{pp ev}" # .pretty_inspect}"
end

end ## if block_given?

f.flush

end ## def debug_me( options={}, &block )

# def log_me(msg, opts={})
# debug_me({:tag => msg, :header => false}.merge(opts))
# end

# def log_me(msg, opts={})
# debug_me({:tag => msg, :header => false}.merge(opts))
# end
end # module DebugMe
2 changes: 1 addition & 1 deletion lib/debug_me/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module DebugMe
VERSION = "1.0.0"
VERSION = '1.0.0'
end

0 comments on commit 378101b

Please sign in to comment.