Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/janlelis/debugging
Improve your Print Debugging
https://github.com/janlelis/debugging
debugging developer-tools print ruby
Last synced: 2 months ago
JSON representation
Improve your Print Debugging
- Host: GitHub
- URL: https://github.com/janlelis/debugging
- Owner: janlelis
- License: mit
- Created: 2014-01-19T20:57:29.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2022-12-25T21:51:40.000Z (about 2 years ago)
- Last Synced: 2024-09-16T07:18:20.744Z (4 months ago)
- Topics: debugging, developer-tools, print, ruby
- Language: Ruby
- Size: 46.9 KB
- Stars: 42
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: MIT-LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Ruby Print Debugging [![version](https://badge.fury.io/rb/debugging.svg)](https://badge.fury.io/rb/debugging) [](https://github.com/janlelis/debugging/actions?query=workflow%3ATest)
Helps you to introspect and debug your code.
## Setup
Install gem:
```
$ gem install debugging
```In Ruby:
```ruby
require 'debugging/all'
```Instead of requiring all, you can also require only one function, e.g:
```ruby
require 'debugging/q'
```In a bundler project, you will need to add the gem to your project's `Gemfile`:
```ruby
gem 'debugging', require: 'debugging/all'
```## Methods
### at(label = nil)Prints out that a specific point in a script has been reached.
```
[label] @ method `...', line ... of file ....
```### beep
Lets your terminal bell ring.
### callstack
Prints out your current callstack. For example:
```
start
catch
block in start
eval_input
each_top_level_statement
catch
block in each_top_level_statement
loop
block (2 levels) in each_top_level_statement
block in eval_input
signal_status
block (2 levels) in eval_input
evaluate
evaluate
eval
irb_binding
```### howtocall(obj = self, method_or_proc)
Displays parameter names and types for a proc or method (identified by a symbol):
```ruby
def function(a, b = 3, &c)
end
howtocall :function #=> function(a, b, &c)
```What is not visible in the example above: All optional parameters are displayed underlined.
If you want to access a function that is defined on an other object than the current one,
you can pass it as an optional parameter:```ruby
howtocall FileUtils, :cd #=> cd(dir, options, &block)
howtocall Open3, :popen3 #=> popen3(*cmd, **opts, &block)```
An example with lambdas and keyword arguments:
```ruby
a = ->(filter: /\A.*\z/, string:){ string[filter] }
howtocall a #=> call(string:, filter:)
```### q(*args)
Like `Kernel#p`, but with colors on one line:
```ruby
q :is_like, ?p, "but on one line"
```### re(string, regex, groups = nil)
Assists you when matching regexes againts strings. Try this one:
```ruby
re "[email protected]", /\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,10})\b/i, 0..2
```## J-_-L
Copyright (c) 2010-2022 Jan Lelis. MIT License. Originated from the
[zucker](https://github.com/janlelis/sugar_refinery) gem.