irb-kit
Extends IRB by providing additional productivity enhancements.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.0%) to scientific vocabulary
Keywords
console
extensions
irb
ruby
utilities
Last synced: 4 months ago
·
JSON representation
·
Repository
Extends IRB by providing additional productivity enhancements.
Basic Info
- Host: GitHub
- Owner: bkuhlmann
- License: other
- Language: Ruby
- Default Branch: main
- Homepage: https://alchemists.io/projects/irb-kit
- Size: 173 KB
Statistics
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
console
extensions
irb
ruby
utilities
Created over 1 year ago
· Last pushed 4 months ago
Metadata Files
Readme
Funding
License
Citation
README.adoc
:toc: macro
:toclevels: 5
:figure-caption!:
:hanami_link: link:https://hanamirb.org[Hanami]
:irb_article_link: link:https://alchemists.io/articles/interactive_ruby[Interactive Ruby]
:irb_extensions_link: link:https://github.com/ruby/irb/blob/master/EXTEND_IRB.md[IRB Extensions]
:irb_link: link:https://github.com/ruby/irb[IRB]
:rails_link: link:https://rubyonrails.org[Rails]
:ruby_link: link:https://www.ruby-lang.org[Ruby]
:xdg_link: link:https://alchemists.io/projects/xdg[XDG]
:iterm_link: link:https://iterm2.com[iTerm2]
= IRB Kit
This gem is a collection of {irb_extensions_link} for enhancing {irb_link} with additional commands, helpers, prompts, and more. Add this gem to your {irb_link} configuration (i.e. `irbrc`) to get all these enhancements immediately while keeping your IRB configuration slim and readable.
toc::[]
== Features
* Provides custom commands and helpers.
* Provides dynamic prompt based on environment.
== Requirements
. {ruby_link}.
. {irb_link}.
. A solid understanding of {irb_article_link}.
== Setup
To install _with_ security, run:
[source,bash]
----
# 💡 Skip this line if you already have the public certificate installed.
gem cert --add <(curl --compressed --location https://alchemists.io/gems.pem)
gem install irb-kit --trust-policy HighSecurity
----
To install _without_ security, run:
[source,bash]
----
gem install irb-kit
----
You can also add the gem directly to your project:
[source,bash]
----
bundle add irb-kit
----
Once the gem is installed, you only need to require it:
[source,ruby]
----
require "irb/kit"
----
== Usage
To use, add the following to your `~/.config/irb/irbrc` configuration (or `~/.irbrc` if not using {xdg_link}).
[source,ruby]
----
begin
require "irb/kit"
rescue LoadError => error
puts "ERROR: #{error.message.capitalize}."
end
----
This ensures this gem is fully loaded in order to enhance {irb_link} further. Otherwise, an error is displayed if you are in a Ruby project that doesn't have this gem as a dependency. To customize, read on.
=== Quick Start
If you'd like all the bells and whistles fully enabled, add the following to your {irb_link} configuration (as discussed above):
[source,ruby]
----
begin
require "irb/kit"
IRB::Kit.register_commands :all
IRB::Kit.register_helpers :all
IRB.conf[:PROMPT] ||= {}
IRB.conf[:PROMPT][:DEMO] = {
PROMPT_I: "[#{IRB::Kit.prompt}]> ",
PROMPT_N: "[#{IRB::Kit.prompt}]| ",
PROMPT_C: "[#{IRB::Kit.prompt}]| ",
PROMPT_S: "[#{IRB::Kit.prompt}]%l ",
RETURN: "=> %s\n"
}
IRB.conf[:PROMPT_MODE] = :DEMO
rescue LoadError => error
puts "ERROR: #{error.message.capitalize}."
end
----
The above enables all commands and helpers and configures your prompt for {ruby_link}, {hanami_link}, and {rails_link} environments.
💡 Use of `:DEMO`, while functional, is meant to be replaced with the name of your organization or personal identity. So please ensure you replace both occurrences of `:DEMO` with your own unique identifier.
=== Commands
Custom command are provided for you by this gem. Each is listed below as found when using `help` within an {irb_link} console:
....
Kit
descendants Show class descendants.
....
To enable all of these commands, use `IRB::Kit.register_commands :all`. This is the same as using:
[source,ruby]
----
IRB::Kit.register_commands :descendants
----
Knowing this, you can disable all commands entirely, use only the ones you care about, or enable all of them at once. The following explains each helper in greater detail.
==== `descendants`
Use this command to show all descendants of a class. Example:
[source,ruby]
----
descendants IO
# File
descendants Ractor::Error
# Ractor::IsolationError
# Ractor::MovedError
# Ractor::RemoteError
# Ractor::UnsafeError
----
=== Helpers
Several custom helpers are provided for you by this gem. Each is listed below as found when using `help` within an {irb_link} console:
....
Helper methods
conf Returns the current IRB context.
clip Copy input to macOS clipboard. DEPRECATED.
esource Edit the source code of a constant or method in your default editor.
paste Paste last entry from macOS clipboard.
search Search an object's methods by pattern.
....
To enable all of these helpers, use `IRB::Kit.register_helpers :all`. This is the same as using:
[source,ruby]
----
IRB::Kit.register_helpers(*%i[clip esource paste search])
----
Knowing this, you can disable all helpers entirely, use only the ones you care about, or enable all of them at once. The following explains each helper in greater detail.
==== `clip`
⚠️ This helper is deprecated and _will be removed_ in the next major release. Use IRB's new `copy` helper instead.
Use this helper to copy output into the macOS clipboard. Example:
[source,ruby]
----
clip (1..3).to_a
# 1
# 2
# 3
clip 1, 2, 3
# 1
# 2
# 3
clip Object.new
# #
----
This helper accepts any number of arguments. Each is delimited by a new line for pasting into another application.
==== `esource`
Use this helper, short for _edit source_, to print and edit the source of a constant or method in your default editor. This assumes your have the `EDITOR` environment variable set and configured to use your favorite editor. If not, you'll get an error requiring your to update your environment accordingly. Here are a few usage examples:
[source,ruby]
----
esource IRB, :start
# Editing: irb-1.13.2/lib/irb.rb:893...
esource IRB, "start"
# Editing: irb-1.13.2/lib/irb.rb:893...
esource "IRB::IRBRC_EXT"
# Editing: irb-1.13.2/lib/irb/init.rb:407...
esource :RUBY_DESCRIPTION
# ERROR (invalid path): ruby.
----
The first argument is the constant or object you want to search for or target. The second argument is the object's method you want to find the source code location for. You can also use a symbol or string for the method.
==== `paste`
Use this helper to paste the last entry from your macOS clipboard into your console. For example, assuming the text `This is a demonstration` is in your clipboard, you'd see the following:
[source,ruby]
----
paste
# "This is a demonstration"
----
This helper takes no arguments.
==== `search`
Use this helper to search for methods on an object. Example:
[source,ruby]
----
search Module, "protected"
# protected_instance_methods
# protected_method_defined?
# protected_methods
search Module, /_defined/
# const_defined?
# class_variable_defined?
# method_defined?
# public_method_defined?
# private_method_defined?
# protected_method_defined?
# instance_variable_defined?
----
This helper takes two arguments. The first is the object you want to search on and the second argument is the string or regular expression of the methods to search for.
=== Prompt
A dynamic prompt, based on environment, is provided for you. The code -- as shown above -- for configuring IRB to make use of this custom prompt is:
[source,ruby]
----
IRB.conf[:PROMPT][:DEMO] = {
PROMPT_I: "[#{IRB::Kit.prompt}]> ",
PROMPT_N: "[#{IRB::Kit.prompt}]| ",
PROMPT_C: "[#{IRB::Kit.prompt}]| ",
PROMPT_S: "[#{IRB::Kit.prompt}]%l ",
RETURN: "=> %s\n"
}
IRB.conf[:PROMPT_MODE] = :DEMO
----
You only need to swap out the `:DEMO` key with a key that identifies you as you see fit.
At the moment, the prompt dynamically detects the following environments:
* {ruby_link}
* {hanami_link}
* {rails_link}
Additionally, when working with the {hanami_link} and/or {rails_link} frameworks, environment information will be color coded as follows:
* *Non-Production*: Displays as green for any environment other than production.
* *Production*: Displays as red but only for a production environment.
The following screenshots demonstrate what the prompt looks like in different environments:
*Ruby (with Git)*
image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-with_git.png[Screenshot,651,150,role=focal_point]
*Ruby (without Git)*
image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-without_git.png[Screenshot,400,146,role=focal_point]
*Hanami (development)*
image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-hanami-development.png[Screenshot,690,146,role=focal_point]
*Hanami (production)*
image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-hanami-production.png[Screenshot,910,169,role=focal_point]
*Rails*
image::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-rails.png[Screenshot,756,170,role=focal_point]
== Development
To contribute, run:
[source,bash]
----
git clone https://github.com/bkuhlmann/irb-kit
cd irb-kit
bin/setup
----
You can also use the IRB console for direct access to all objects:
[source,bash]
----
bin/console
----
== Tests
To test, run:
[source,bash]
----
bin/rake
----
== link:https://alchemists.io/policies/license[License]
== link:https://alchemists.io/policies/security[Security]
== link:https://alchemists.io/policies/code_of_conduct[Code of Conduct]
== link:https://alchemists.io/policies/contributions[Contributions]
== link:https://alchemists.io/policies/developer_certificate_of_origin[Developer Certificate of Origin]
== link:https://alchemists.io/projects/irb-kit/versions[Versions]
== link:https://alchemists.io/community[Community]
== Credits
* Built with link:https://alchemists.io/projects/gemsmith[Gemsmith].
* Engineered by link:https://alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
Owner
- Name: Brooke Kuhlmann
- Login: bkuhlmann
- Kind: user
- Location: Boulder, CO USA
- Company: Alchemists
- Website: https://alchemists.io
- Repositories: 56
- Profile: https://github.com/bkuhlmann
Quality over quantity.
Citation (CITATION.cff)
cff-version: 1.2.0
message: Please use the following metadata when citing this project in your work.
title: IRB Kit
abstract: Extends IRB by providing additional productivity enhancements.
version: 1.3.0
license: Hippocratic-2.1
date-released: 2025-07-19
authors:
- family-names: Kuhlmann
given-names: Brooke
affiliation: Alchemists
orcid: https://orcid.org/0000-0002-5810-6268
keywords:
- ruby
- irb
- console
- utilities
repository-code: https://github.com/bkuhlmann/irb-kit
repository-artifact: https://rubygems.org/gems/irb-kit
url: https://alchemists.io/projects/irb-kit
GitHub Events
Total
- Watch event: 1
- Delete event: 27
- Push event: 33
- Create event: 8
Last Year
- Watch event: 1
- Delete event: 27
- Push event: 33
- Create event: 8
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- rubygems 7,076 total
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 16
- Total maintainers: 1
rubygems.org: irb-kit
Extends IRB by providing additional productivity enhancements.
- Homepage: https://alchemists.io/projects/irb-kit
- Documentation: http://www.rubydoc.info/gems/irb-kit/
- License: Hippocratic-2.1
-
Latest release: 1.3.0
published 5 months ago
Rankings
Dependent packages count: 14.8%
Dependent repos count: 45.3%
Average: 50.9%
Downloads: 92.8%
Maintainers (1)
Funding
- https://github.com/sponsors/bkuhlmann
Last synced:
4 months ago
Dependencies
Gemfile
rubygems
- amazing_print ~> 1.6 development
- caliber ~> 0.51 development
- debug ~> 1.9 development
- git-lint ~> 7.3 development
- guard-rspec ~> 4.7 development
- rake ~> 13.2 development
- reek ~> 6.3 development
- repl_type_completor ~> 0.1 development
- rspec ~> 3.13 development
- simplecov ~> 0.22 development
irb-kit.gemspec
rubygems
- irb ~> 1.13
- zeitwerk ~> 2.6