Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyObtiva committed Jun 4, 2024
1 parent 7511add commit 3123d23
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ If you like [Awesome_Print](https://rubygems.org/gems/awesome_print) (or [Amazin

Debuggers are great! They help us troubleshoot complicated programming problems by inspecting values produced by code, line by line. They are invaluable when trying to understand what is going on in a large application composed of thousands or millions of lines of code.

In day-to-day test-driven development and simple app debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Still, there are a number of problems with puts debugging, like difficulty in locating puts statements in a large output log, knowing which methods and line numbers were invoked, identifying which variables were printed, and seeing the content of structured hashes and arrays in an understandable format.
In day-to-day test-driven development and simple app debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Still, there are a number of problems with puts debugging, like difficulty in locating puts statements in a large output log, knowing which files, line numbers, and methods the puts statements were invoked from, identifying which variables were printed, and seeing the content of structured hashes and arrays in an understandable format.

Enter [puts_debuggerer](https://rubygems.org/gems/puts_debuggerer)! A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, invoked class methods, code statements, headers, footers, stack traces, and formats output nicely courtesy of [awesome_print](https://rubygems.org/gems/awesome_print) (or [amazing_print](https://github.com/amazing-print/amazing_print) if you prefer).
Enter [puts_debuggerer](https://rubygems.org/gems/puts_debuggerer)! A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, class names, method names, code statements, headers, footers, and stack traces; and formats output nicely courtesy of [awesome_print](https://rubygems.org/gems/awesome_print) (or [amazing_print](https://github.com/amazing-print/amazing_print) if you prefer).

[puts_debuggerer](https://rubygems.org/gems/puts_debuggerer) automates tips mentioned in [this blog post](https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html) by Aaron Patterson using the `pd` method available everywhere after requiring the [gem](https://rubygems.org/gems/puts_debuggerer).

Expand All @@ -39,7 +39,7 @@ Output:
=> "Beatles"
```

`pd` revealed that the variable contains the band name "Beatles" as its value not the bug "Beetle", in addition to revealing the printed code statement `pd bug_or_band`, the file name `/Users/User/trivia_app.rb`, the line number `6`, the class name `TriviaApp`, and the invoked method name `question`.
`pd` revealed that the variable contains the band name "Beatles" as its value not the bug "Beetle", in addition to revealing the printed code statement `pd bug_or_band`, the file name `/Users/User/trivia_app.rb`, the line number `6`, the class name `TriviaApp`, and the method name `question`.

## Background

Expand Down Expand Up @@ -72,7 +72,7 @@ Which gets lost in a logging stream such as:
(0.2ms) COMMIT
```

Here is a simple example using `pd` instead, which provides everything the puts statements above provide in addition to deducing the file name, line number, and invoked class method automatically for dead-easy debugging:
Here is a simple example using `pd` instead, which provides everything the puts statements above provide in addition to deducing the file name, line number, class name, and method name automatically for dead-easy debugging:

```ruby
pd order_total
Expand Down Expand Up @@ -418,7 +418,7 @@ Output:
=> "Beatles"
```
In addition to the object/expression output, you get to see the source file name, line number, invoked class method, and source code to help you debug and troubleshoot problems quicker (it even works in IRB).
In addition to the object/expression output, you get to see the source file name, line number, class name, method name, and source code to help you debug and troubleshoot problems quicker (it even works in IRB).
You can use `pd` at the top-level main object too, and it prings `Object.<main>` for the class/method.
Expand Down Expand Up @@ -831,7 +831,7 @@ Prints out the following in standard out stream only (not in log files):

Print engine is similar to `printer`, except it is focused on the scope of formatting
the data object being printed (excluding metadata such as file name, line number,
invoked class method, and expression, which are handled by the `printer`).
class name, method name, and expression, which are handled by the `printer`).
As such, it is also a global method symbol or lambda expression.
Examples of global methods are `:p`, `:ap`, and `:pp`.
An example of a lambda expression is `lambda {|object| puts object.to_a.join(" | ")}`
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Jeweler::Tasks.new do |gem|
gem.name = "puts_debuggerer"
gem.homepage = "http://github.com/AndyObtiva/puts_debuggerer"
gem.license = "MIT"
gem.summary = %Q{Ruby library for improved puts debugging, automatically displaying bonus useful information such as source file name, line number, invoked class method, and source code.}
gem.summary = %Q{Ruby library for improved puts debugging, automatically displaying bonus useful information such as source file name, line number, class name, method name, and source code.}
gem.description = <<-MULTI
Debuggers are great! They help us troubleshoot complicated programming problems by inspecting values produced by code, line by line. They are invaluable when trying to understand what is going on in a large application composed of thousands or millions of lines of code.
In day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which methods were invoked, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, invoked class methods, code statements, and formats output nicely courtesy of awesome_print.
In day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which file names, line numbers, classes, and methods contained the puts statements, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, class names, method names, and code statements; and formats output nicely courtesy of awesome_print.
Partially inspired by this blog post: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html (Credit to Tenderlove.)
MULTI
gem.email = "[email protected]"
Expand Down
3 changes: 2 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Here are tasks considered for future versions. Once done, they are moved to the
- Fix issue with attempting to modify a frozen hash when passed as value for `pd` command (check if frozen)
- When using last arg as hash for options, leave out options that are not puts_debuggerer-specific for printing out
- Support displaying the date/time of the pd printout via an option (local and global)
- Display class#method for instance methods and class::method for class methods
- Consider supporting `header: :method` to print the Class#method name as the header (consider supporting in footer/wrapper too)
- Consider adding performance profiling to pd methods automatically, with some customization options too
- Fix issue with no printing code in bigger rails apps filled with other gems (perhaps there is some conflict?)
Expand All @@ -16,7 +17,7 @@ Here are tasks considered for future versions. Once done, they are moved to the
- Have `caller` printing in Glimmer DSL for Opal print one statement per line
- Support header: 30 to customize the length of the header (and do the same for footer and wrapper)
- Support header: '#' to customize the character of the header (and do the same for footer and wrapper)
- h: true and f: true alternatives for header and footer (as well as other ideas to shorten)
- :h and :f alternatives for header and footer (as well as other ideas to shorten)
- Support `methods: true` to print unique methods not on Object or `methods: :all`, automatically sorted
- Consider making header use >>> and footer <<< instead of * for better findability.
- Provide option to set a logger as printer without hooking formatter unto logger
Expand Down
6 changes: 3 additions & 3 deletions puts_debuggerer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Andy Maleh".freeze]
s.date = "2024-05-31"
s.description = "Debuggers are great! They help us troubleshoot complicated programming problems by inspecting values produced by code, line by line. They are invaluable when trying to understand what is going on in a large application composed of thousands or millions of lines of code.\nIn day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which methods were invoked, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, invoked class methods, code statements, and formats output nicely courtesy of awesome_print.\nPartially inspired by this blog post: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html (Credit to Tenderlove.)\n".freeze
s.date = "2024-06-04"
s.description = "Debuggers are great! They help us troubleshoot complicated programming problems by inspecting values produced by code, line by line. They are invaluable when trying to understand what is going on in a large application composed of thousands or millions of lines of code.\nIn day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which file names, line numbers, classes, and methods contained the puts statements, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, class names, method names, and code statements; and formats output nicely courtesy of awesome_print.\nPartially inspired by this blog post: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html (Credit to Tenderlove.)\n".freeze
s.email = "[email protected]".freeze
s.extra_rdoc_files = [
"CHANGELOG.md",
Expand All @@ -34,7 +34,7 @@ Gem::Specification.new do |s|
s.homepage = "http://github.com/AndyObtiva/puts_debuggerer".freeze
s.licenses = ["MIT".freeze]
s.rubygems_version = "3.5.3".freeze
s.summary = "Ruby library for improved puts debugging, automatically displaying bonus useful information such as source file name, line number, invoked class method, and source code.".freeze
s.summary = "Ruby library for improved puts debugging, automatically displaying bonus useful information such as source file name, line number, class name, method name, and source code.".freeze

s.specification_version = 4

Expand Down

0 comments on commit 3123d23

Please sign in to comment.