{"id":13877906,"url":"https://github.com/bkuhlmann/irb-kit","last_synced_at":"2025-04-14T06:22:06.287Z","repository":{"id":240379270,"uuid":"802490551","full_name":"bkuhlmann/irb-kit","owner":"bkuhlmann","description":"Extends IRB by providing additional productivity enhancements.","archived":false,"fork":false,"pushed_at":"2025-03-25T02:11:26.000Z","size":149,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-13T09:49:20.825Z","etag":null,"topics":["console","extensions","irb","ruby","utilities"],"latest_commit_sha":null,"homepage":"https://alchemists.io/projects/irb-kit","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bkuhlmann.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.adoc","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["bkuhlmann"]}},"created_at":"2024-05-18T12:49:43.000Z","updated_at":"2025-03-25T02:11:30.000Z","dependencies_parsed_at":"2024-05-30T16:04:15.806Z","dependency_job_id":"cc2c2273-e2aa-4f01-b321-375f16e98dfb","html_url":"https://github.com/bkuhlmann/irb-kit","commit_stats":null,"previous_names":["bkuhlmann/irb-kit"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkuhlmann%2Firb-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkuhlmann%2Firb-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkuhlmann%2Firb-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkuhlmann%2Firb-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bkuhlmann","download_url":"https://codeload.github.com/bkuhlmann/irb-kit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830904,"owners_count":21168368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console","extensions","irb","ruby","utilities"],"created_at":"2024-08-06T08:01:34.565Z","updated_at":"2025-04-14T06:22:06.272Z","avatar_url":"https://github.com/bkuhlmann.png","language":"Ruby","funding_links":["https://github.com/sponsors/bkuhlmann"],"categories":["Ruby"],"sub_categories":[],"readme":":toc: macro\n:toclevels: 5\n:figure-caption!:\n\n:hanami_link: link:https://hanamirb.org[Hanami]\n:irb_article_link: link:https://alchemists.io/articles/interactive_ruby[Interactive Ruby]\n:irb_extensions_link: link:https://github.com/ruby/irb/blob/master/EXTEND_IRB.md[IRB Extensions]\n:irb_link: link:https://github.com/ruby/irb[IRB]\n:rails_link: link:https://rubyonrails.org[Rails]\n:ruby_link: link:https://www.ruby-lang.org[Ruby]\n:xdg_link: link:https://alchemists.io/projects/xdg[XDG]\n:iterm_link: link:https://iterm2.com[iTerm2]\n\n= IRB Kit\n\nThis 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.\n\ntoc::[]\n\n== Features\n\n* Provides custom commands and helpers.\n* Provides dynamic prompt based on environment.\n\n== Requirements\n\n. {ruby_link}.\n. {irb_link}.\n. A solid understanding of {irb_article_link}.\n\n== Setup\n\nTo install _with_ security, run:\n\n[source,bash]\n----\n# 💡 Skip this line if you already have the public certificate installed.\ngem cert --add \u003c(curl --compressed --location https://alchemists.io/gems.pem)\ngem install irb-kit --trust-policy HighSecurity\n----\n\nTo install _without_ security, run:\n\n[source,bash]\n----\ngem install irb-kit\n----\n\nYou can also add the gem directly to your project:\n\n[source,bash]\n----\nbundle add irb-kit\n----\n\nOnce the gem is installed, you only need to require it:\n\n[source,ruby]\n----\nrequire \"irb/kit\"\n----\n\n== Usage\n\nTo use, add the following to your `~/.config/irb/irbrc` configuration (or `~/.irbrc` if not using {xdg_link}).\n\n[source,ruby]\n----\nbegin\n  require \"irb/kit\"\nrescue LoadError =\u003e error\n  puts \"ERROR: #{error.message.capitalize}.\"\nend\n----\n\nThis 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.\n\n=== Quick Start\n\nIf you'd like all the bells and whistles fully enabled, add the following to your {irb_link} configuration (as discussed above):\n\n[source,ruby]\n----\nbegin\n  require \"irb/kit\"\n\n  IRB::Kit.register_commands :all\n  IRB::Kit.register_helpers :all\n\n  IRB.conf[:PROMPT] ||= {}\n\n  IRB.conf[:PROMPT][:DEMO] = {\n    PROMPT_I: \"[#{IRB::Kit.prompt}]\u003e \",\n    PROMPT_N: \"[#{IRB::Kit.prompt}]| \",\n    PROMPT_C: \"[#{IRB::Kit.prompt}]| \",\n    PROMPT_S: \"[#{IRB::Kit.prompt}]%l \",\n    RETURN: \"=\u003e %s\\n\"\n  }\n\n  IRB.conf[:PROMPT_MODE] = :DEMO\nrescue LoadError =\u003e error\n  puts \"ERROR: #{error.message.capitalize}.\"\nend\n----\n\nThe above enables all commands and helpers and configures your prompt for {ruby_link}, {hanami_link}, and {rails_link} environments.\n\n\n💡 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.\n\n=== Commands\n\nCustom command are provided for you by this gem. Each is listed below as found when using `help` within an {irb_link} console:\n\n....\nKit\n  descendants        Show class descendants.\n....\n\nTo enable all of these commands, use `IRB::Kit.register_commands :all`. This is the same as using:\n\n[source,ruby]\n----\nIRB::Kit.register_commands :descendants\n----\n\nKnowing 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.\n\n==== `descendants`\n\nUse this command to show all descendants of a class. Example:\n\n[source,ruby]\n----\ndescendants IO\n# File\n\ndescendants Ractor::Error\n# Ractor::IsolationError\n# Ractor::MovedError\n# Ractor::RemoteError\n# Ractor::UnsafeError\n----\n\n=== Helpers\n\nSeveral custom helpers are provided for you by this gem. Each is listed below as found when using `help` within an {irb_link} console:\n\n....\nHelper methods\n  conf           Returns the current IRB context.\n  clip           Copy input to macOS clipboard. DEPRECATED.\n  esource        Edit the source code of a constant or method in your default editor.\n  paste          Paste last entry from macOS clipboard.\n  search         Search an object's methods by pattern.\n....\n\nTo enable all of these helpers, use `IRB::Kit.register_helpers :all`. This is the same as using:\n\n[source,ruby]\n----\nIRB::Kit.register_helpers(*%i[clip esource paste search])\n----\n\nKnowing 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.\n\n==== `clip`\n\n⚠️ This helper is deprecated and _will be removed_ in the next major release. Use IRB's new `copy` helper instead.\n\nUse this helper to copy output into the macOS clipboard. Example:\n\n[source,ruby]\n----\nclip (1..3).to_a\n# 1\n# 2\n# 3\n\nclip 1, 2, 3\n# 1\n# 2\n# 3\n\nclip Object.new\n# #\u003cObject:0x000000012a46eaf8\u003e\n----\n\nThis helper accepts any number of arguments. Each is delimited by a new line for pasting into another application.\n\n==== `esource`\n\nUse 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:\n\n[source,ruby]\n----\nesource IRB, :start\n# Editing: irb-1.13.2/lib/irb.rb:893...\n\nesource IRB, \"start\"\n# Editing: irb-1.13.2/lib/irb.rb:893...\n\nesource \"IRB::IRBRC_EXT\"\n# Editing: irb-1.13.2/lib/irb/init.rb:407...\n\nesource :RUBY_DESCRIPTION\n# ERROR (invalid path): ruby.\n----\n\nThe 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.\n\n==== `paste`\n\nUse 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:\n\n[source,ruby]\n----\npaste\n# \"This is a demonstration\"\n----\n\nThis helper takes no arguments.\n\n==== `search`\n\nUse this helper to search for methods on an object. Example:\n\n[source,ruby]\n----\nsearch Module, \"protected\"\n# protected_instance_methods\n# protected_method_defined?\n# protected_methods\n\nsearch Module, /_defined/\n# const_defined?\n# class_variable_defined?\n# method_defined?\n# public_method_defined?\n# private_method_defined?\n# protected_method_defined?\n# instance_variable_defined?\n----\n\nThis 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.\n\n=== Prompt\n\nA 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:\n\n[source,ruby]\n----\nIRB.conf[:PROMPT][:DEMO] = {\n  PROMPT_I: \"[#{IRB::Kit.prompt}]\u003e \",\n  PROMPT_N: \"[#{IRB::Kit.prompt}]| \",\n  PROMPT_C: \"[#{IRB::Kit.prompt}]| \",\n  PROMPT_S: \"[#{IRB::Kit.prompt}]%l \",\n  RETURN: \"=\u003e %s\\n\"\n}\n\nIRB.conf[:PROMPT_MODE] = :DEMO\n----\n\nYou only need to swap out the `:DEMO` key with a key that identifies you as you see fit.\n\nAt the moment, the prompt dynamically detects the following environments:\n\n* {ruby_link}\n* {hanami_link}\n* {rails_link}\n\nAdditionally, when working with the {hanami_link} and/or {rails_link} frameworks, environment information will be color coded as follows:\n\n* *Non-Production*: Displays as green for any environment other than production.\n* *Production*: Displays as red but only for a production environment.\n\nThe following screenshots demonstrate what the prompt looks like in different environments:\n\n*Ruby (with Git)*\n\nimage::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-with_git.png[Screenshot,651,150,role=focal_point]\n\n*Ruby (without Git)*\n\nimage::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-without_git.png[Screenshot,400,146,role=focal_point]\n\n*Hanami (development)*\n\nimage::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-hanami-development.png[Screenshot,690,146,role=focal_point]\n\n*Hanami (production)*\n\nimage::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-hanami-production.png[Screenshot,910,169,role=focal_point]\n\n*Rails*\n\nimage::https://alchemists.io/images/projects/irb-kit/screenshots/prompt-rails.png[Screenshot,756,170,role=focal_point]\n\n== Development\n\nTo contribute, run:\n\n[source,bash]\n----\ngit clone https://github.com/bkuhlmann/irb-kit\ncd irb-kit\nbin/setup\n----\n\nYou can also use the IRB console for direct access to all objects:\n\n[source,bash]\n----\nbin/console\n----\n\n== Tests\n\nTo test, run:\n\n[source,bash]\n----\nbin/rake\n----\n\n== link:https://alchemists.io/policies/license[License]\n\n== link:https://alchemists.io/policies/security[Security]\n\n== link:https://alchemists.io/policies/code_of_conduct[Code of Conduct]\n\n== link:https://alchemists.io/policies/contributions[Contributions]\n\n== link:https://alchemists.io/policies/developer_certificate_of_origin[Developer Certificate of Origin]\n\n== link:https://alchemists.io/projects/irb-kit/versions[Versions]\n\n== link:https://alchemists.io/community[Community]\n\n== Credits\n\n* Built with link:https://alchemists.io/projects/gemsmith[Gemsmith].\n* Engineered by link:https://alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkuhlmann%2Firb-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbkuhlmann%2Firb-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkuhlmann%2Firb-kit/lists"}