debug_me 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 910d8a6178916e6c0c6d19362e6eddfd7e5dc813
4
+ data.tar.gz: 0072112c8789c4a6417ebca895825ad4d81d9df8
5
+ SHA512:
6
+ metadata.gz: 803d7ae403786bf55cf5370721f9977d551c7f30d02930f4fdec015b32c0c23a5ea70abb54bade240cdba8e931037084b2ea9fa2e842e9c435437f4ae1f04784
7
+ data.tar.gz: 8373de00f006b6054b59d2cbb3c9a596f5da47eadb10db6f781b4b2f6ceafd5f64a6314322cb362116bc58dd76845c391d20996f957e18563e96b1335fabe959
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in debug_me.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1 @@
1
+ If you want it, its yours.
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # DebugMe
2
+
3
+ This thing is pretty old. There are much better
4
+ ways of debugging in a complex application. But,
5
+ you know, I keep returning to this little method
6
+ time after time. I guess that marks me as a geezer.
7
+
8
+ A tool to print the labeled value of variables.
9
+
10
+ Works with local, instance and class variables.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'debug_me'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install debug_me
27
+
28
+ ## Examples Usage
29
+
30
+ ```ruby
31
+ require 'debug_me'
32
+ include DebugMe
33
+
34
+ debug_me # Prints only the header banner consisting of tag, method name, file name and line number
35
+
36
+ debug_me('INFO') # Also prints only the header but with a different tag
37
+
38
+ debug_me {} # prints the default header and __ALL__ variables
39
+
40
+ debug_me {:just_this_variable} # prints the default header and the value of only one specific variable
41
+
42
+ debug_me { [:this_one, :that_one, :that_other_one] } # prints default header and three specific variables
43
+
44
+ # Use an array of symbols and strings to pass multiple variables for output
45
+ # Each element of the array is 'eval'ed with the context binding of the caller
46
+ debug_me(){[ :my_var, 'my_complex_var_or_method[my_var]' ]}
47
+
48
+ debug_me(:header => false) {} # disables the printing of the header; prints all variables
49
+
50
+ debug_me(:tag => 'MyTag', :header => false) {} # disables header, sets different tag, prints all variables
51
+
52
+ debug_me('=== LOOK ===') {} # changes the tag and prints all variables with a header line
53
+
54
+ debug_me('=== LOOK ===') {:@foo} # changes the tag, prints a header line and a specific instance variable
55
+
56
+ debug_me('=== LOOK ===') {:@@foo} # changes the tag, prints a header line and a specific class variable
57
+
58
+ debug_me(:ivar => false, :cvar => false) {} # print only the local variables with the default tag and a header line
59
+
60
+ ```
61
+
62
+ ## Contributing
63
+
64
+ 1. Fork it ( https://github.com/[my-github-username]/debug_me/fork )
65
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
66
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
67
+ 4. Push to the branch (`git push origin my-new-feature`)
68
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/debug_me.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'debug_me/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "debug_me"
8
+ spec.version = DebugMe::VERSION
9
+ spec.authors = ["Dewayne VanHoozer"]
10
+ spec.email = ["dvanhoozer@gmail.com"]
11
+ spec.summary = "A tool to print the labeled value of variables."
12
+ spec.description = %q{This thing is pretty old. There are much better
13
+ ways of debugging in a complex application. But,
14
+ you know, I keep returning to this little method
15
+ time after time. I guess that marks me as a geezer.}
16
+ spec.homepage = "http://github.com/MadBomber/debug_me"
17
+ spec.license = "You want it, its yours"
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
data/lib/debug_me.rb ADDED
@@ -0,0 +1,60 @@
1
+ require 'pp'
2
+ require "debug_me/version"
3
+
4
+ module DebugMe
5
+
6
+ def debug_me( options={}, &block )
7
+
8
+ default_options = {
9
+ :tag => 'DEBUG:', # A tag to prepend to each output line
10
+ :time => true, # Include a time-stamp in front of the tag
11
+ :header => true, # Print a header string before printing the variables
12
+ :ivar => true, # Include instance variables in the output
13
+ :cvar => true, # Include class variables in the output
14
+ :file => $stdout # The output file
15
+ }
16
+
17
+ if 'Hash' == options.class.to_s
18
+ options = default_options.merge(options)
19
+ else
20
+ options = default_options.merge({:tag => options})
21
+ end
22
+
23
+ f = options[:file]
24
+ s = ""
25
+ s += "#{sprintf('%010.6f', Time.now.to_f)} " if options[:time]
26
+ s += " #{options[:tag]}"
27
+ wf = caller # where_from under 1.8.6 its a stack trace array under 1.8.7 is a string
28
+ wf = wf[0] if 'Array' == wf.class.to_s
29
+
30
+ f.puts "#{s} Source: #{wf}" if options[:header]
31
+
32
+ if block_given?
33
+
34
+ block_value = [ block.call ].flatten.compact
35
+
36
+ if block_value.empty?
37
+ block_value = eval('local_variables', block.binding)
38
+ block_value += [ eval('instance_variables', block.binding) ] if options[:ivar]
39
+ block_value += [ self.class.send('class_variables') ] if options[:cvar]
40
+ block_value = block_value.flatten.compact
41
+ else
42
+ block_value.map! { |v| v.to_s }
43
+ end
44
+
45
+ block_value.each do |v|
46
+ ev = eval(v, block.binding)
47
+ f.puts "#{s} #{v} -=> #{pp ev}" #.pretty_inspect}"
48
+ end
49
+
50
+ end ## if block_given?
51
+
52
+ f.flush
53
+
54
+ end ## def debug_me( options={}, &block )
55
+
56
+ # def log_me(msg, opts={})
57
+ # debug_me({:tag => msg, :header => false}.merge(opts))
58
+ # end
59
+
60
+ end # module DebugMe
@@ -0,0 +1,3 @@
1
+ module DebugMe
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: debug_me
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dewayne VanHoozer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: |-
42
+ This thing is pretty old. There are much better
43
+ ways of debugging in a complex application. But,
44
+ you know, I keep returning to this little method
45
+ time after time. I guess that marks me as a geezer.
46
+ email:
47
+ - dvanhoozer@gmail.com
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - ".gitignore"
53
+ - Gemfile
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - debug_me.gemspec
58
+ - lib/debug_me.rb
59
+ - lib/debug_me/version.rb
60
+ homepage: http://github.com/MadBomber/debug_me
61
+ licenses:
62
+ - You want it, its yours
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.3.0
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: A tool to print the labeled value of variables.
84
+ test_files: []