Code Monkey home page Code Monkey logo

debugging's Introduction

Ruby Print Debugging version

Helps you to introspect and debug your code.

Setup

Install gem:

$ gem install debugging

In Ruby:

require 'debugging/all'

Instead of requiring all, you can also require only one function, e.g:

require 'debugging/q'

In a bundler project, you will need to add the gem to your project's Gemfile:

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:

<main>
  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):

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:

howtocall FileUtils, :cd #=> cd(dir, options, &block)
howtocall Open3, :popen3 #=> popen3(*cmd, **opts, &block)

An example with lambdas and keyword arguments:

a = ->(filter: /\A.*\z/, string:){ string[filter] }
howtocall a #=> call(string:, filter:)

q(*args)

Like Kernel#p, but with colors on one line:

q :is_like, ?p, "but on one line"

re(string, regex, groups = nil)

Assists you when matching regexes againts strings. Try this one:

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 gem.

debugging's People

Contributors

janlelis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.