{"id":16086141,"url":"https://github.com/zw963/pryx","last_synced_at":"2025-03-18T06:30:41.374Z","repository":{"id":43972191,"uuid":"483942482","full_name":"zw963/pryx","owner":"zw963","description":"pry extension tools","archived":false,"fork":false,"pushed_at":"2024-12-17T12:11:16.000Z","size":499,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T07:49:39.594Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zw963.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-21T07:03:10.000Z","updated_at":"2024-12-17T12:11:07.000Z","dependencies_parsed_at":"2024-02-08T15:02:05.253Z","dependency_job_id":null,"html_url":"https://github.com/zw963/pryx","commit_stats":{"total_commits":115,"total_committers":1,"mean_commits":115.0,"dds":0.0,"last_synced_commit":"d2629054d6fbcca98ae50749e49ecd6673134940"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zw963%2Fpryx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zw963%2Fpryx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zw963%2Fpryx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zw963%2Fpryx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zw963","download_url":"https://codeload.github.com/zw963/pryx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243908093,"owners_count":20367343,"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":[],"created_at":"2024-10-09T13:10:39.257Z","updated_at":"2025-03-18T06:30:40.995Z","avatar_url":"https://github.com/zw963.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pryx [![CI](https://github.com/zw963/pryx/actions/workflows/ci.yml/badge.svg)](https://github.com/zw963/pryx/actions/workflows/ci.yml) [![Gem Version](https://badge.fury.io/rb/pryx.svg)](http://badge.fury.io/rb/pryx) ![](https://ruby-gem-downloads-badge.herokuapp.com/pryx?type=total)\n\nThree Virtues of a Programmer: Laziness, Impatience, and Hubris. -- Larry Wall, the author of Perl Programming language.\n\n## Getting Started\n\n[NOTICE] Check [What's new in Ruby 3.2's IRB?](https://st0012.dev/whats-new-in-ruby-3-2-irb) for the introduced new feature of Ruby 3.2 IRB which includes part of feature this gem provides.\n\nDon't add this gem into bundler's Gemfile.\n\nInstead, install it directly via RubyGems\n\n    $ gem install pryx\n\t\nThen user can use pryx cross all your's project.\t\n\n## Usage\n\nAt first, it is just pry, with more extensions.\n\nyou can always run it with `pryx`.\n\n```sh\n ╰─ $ pryx\n[1] pry(main)\u003e ? Array#each_with_object\n\nFrom: enum.c (C Method):\nOwner: Enumerable\nVisibility: public\nSignature: each_with_object(arg1)\nNumber of lines: 20\n\nCalls the block once for each element, passing both the element\nand the given object:\n\n  (1..4).each_with_object([]) {|i, a| a.push(i**2) }\n  # =\u003e [1, 4, 9, 16]\n\n  {foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k }\n  # =\u003e {0=\u003e:foo, 1=\u003e:bar, 2=\u003e:baz}\n\nWith no block given, returns an Enumerator.\n\nstatic VALUE\nenum_each_with_object(VALUE obj, VALUE memo)\n{\n    RETURN_SIZED_ENUMERATOR(obj, 1, \u0026memo, enum_size);\n\n    rb_block_call(obj, id_each, 0, 0, each_with_object_i, memo);\n\n    return memo;\n}\n[2] pry(main)\u003e \n\n```\n\nSecond, it add a new `Kernel#pry!`, you can use it instead of `binding.pry`.\n It's not just an alias, there are more.\n\nBefore use it, you need set `RUBYOPT` variable.\n\nYou can do this two way in a terminal.\n\n```sh\n$: export RUBYOPT+=' -rpryx'   # For BASH only\n$: export RUBYOPT=\"$RUBYOPT -rpryx\" # For others shell\n$: ruby your_file.rb              # add pry! in your_file for start pry session\n\n```\n\nor Run your's code directly use:\n\n\n```sh\n$: RUBYOPT+='-rpryx' ruby your_file.rb  # add pry! in your_file for start pry session\n```\n\nFollowing is a example, assume there is a `test.rb` with content:\n\n```rb\n# test.rb\n3.times do\n  pry!\n  puts 'hello'\nend\n```\n\nThen, when you run `RUBYOPT='-rpryx' ruby test.rb`\n\n![pry.png](images/pry!.png)\n\nYou can even connect to a pry session started from remote or background process \nuse http connection.\n\n![pry_remote.png](images/pry_remote.png)\n\nUntil now, you've only seen the tip of the iceberg, please have a try.\n\n\nthe preferred way to use pryx is add `export RUBYOPT+=' -rpryx'` to system start script.\n\nIt should almost not affect your's code too much, only special methods defined into Kernel#, \nno any gem be required before you invoke those added methods.\n\n## useful command which added directly to Kernel#\n\n### Kernel#pry!\n\nstart a pry session, this session only can be intercept once if add into a loop.\nwhen used with a rails/roda web server, it only intercept one per request.\n\nwe have IRB equivalent, named `irb!`, though, only a little feature support it.\n\nFollowing feature both available when start a Pry or IRB session:\n\n1.  Add `Kernel#ls1`(use ls1 to avoid conflict with pry builtin ls command), see [looksee](https://github.com/oggy/looksee)\n2.  Use `ap` for pretty print. see [awesome-print](https://github.com/awesome-print/awesome_print)\n3.  Use `Clipboard.copy` or `Clipboard.paste` to interactive with system clipboard. see [clipboard](https://github.com/janlelis/clipboard)\n\nFollowing feature available only for a Pry session:\n\n1.  Add `next/step/continue/up/down` command for debug, use [pry-nav](https://github.com/nixme/pry-nav) [pry-stack_explorer](https://github.com/pry/pry-stack_explorer)\n2.  Add `$/?` command for see source, see [pry-doc](https://github.com/pry/pry-doc)\n3.  pry-remote debug support. you still use `pry!` no changes, it will use `pry-remote` automatically\n    if current ruby process was running on backround, then, it will use pry-remote, and listen on 0.0.0.0:9876,\n    Then, you can connect to it from another terminal! see [pry-remote](https://github.com/Mon-Ouie/pry-remote)\n4.  Add `pa` command, see [pry-power_assert](https://github.com/yui-knk/pry-power_assert)\n5.  Add `hier` command for print the class hierarchies, see [pry-hier](https://github.com/phaul/pry-hier)\n6.  Add `pry-aa_ancestors` command for print the class hierarchy, see [pry-aa_ancestors](https://github.com/tbpgr/pry-aa_ancestors)\n7.  Add `up/down/frame/stack` command, see [pry-stack_explorer](https://github.com/pry/pry-stack_explorer)\n8.  Add `yes` or `y` command, see [pry-yes](https://github.com/christofferh/pry-yes)\n9.  Add `pry-disam`, Check following screenshot for a example:\n\n![pry-disasm](images/disasm.png)\n\n### Kernel#pry1 Kernel#pry2  (sorry for the bad name, please create a issue you have a better one)\n\npry2 do nothing, but it will be interceptd and start a pry session only after pry1 is running.\n\nI haven use this hack for avoid pry session start on working place.\n\nYou know what i means.\n\n### Kernel#irb1 Kernel#irb2 \n\nIRB equivalent for pry1, pry2\nwe have irb1 and irb2 too.\n\n### Kernel#pry3\n\nIt just normal `binding.pry`, that is, will always be intercept if code can reach.\nbut above plugins and libraries all correct configured.\n\nwe have another Kernel#pry?, which enable `pry-state` automatically, see [pry-state](https://github.com/SudhagarS/pry-state)\n\n### Add CLI command, rescue, kill-pry-rescue, pryx, irbx, pry!\n\n`rescue` and `kill-pry-rescue` come from `pry-rescue` gem, it not load by default, but you can use rescue command from command line directly.\nsee [pry-rescue](https://github.com/ConradIrwin/pry-rescue)\n\npryx is same as pry, but, with plugins and libraries correct configured, it will load `./config/environment.rb` if this file exists.\n\nirbx is same things for irb.\n\n`pry!` just a alias to `binding.pry`, but, if process is running on background, it a alias to `binding.remote_pry('0.0.0.0', 9876)`, \nyou can specify host or port manually, like this: `pry!(host: '192.168.1.100')`. \nin another terminal, you can run `pry!` directly to connect to it use IP + port.\n\ne.g. assume your's pry-remote server started background on another host(192.168.1.100), port 9876\nIt maybe in container, you can connect remote pry like this:\n\n```sh\n$: pry! -s 192.168.1.100 -p 9876\n```\n\n## Philosophy\n\nThis gem is design to Minimal impact on target ruby code, in fact, after `require 'pryx'` or `RUBYOPT='-rpryx'`\n(they do same thing), only several instance method be defined on Kernel, and several gems add to $LOAD_PATH, \nbut not load, ready to require it, no more. so, it should be safe to use it, either affect performance nor\nnamespace/variables etc.\n\nBut, you should only use it in development, though, it was tested is run in container(alpine) too.\n\n## Limit\n  \n  2. Pry's show auto-watch when not work, because `Enter` key rebinding to `run the last command`.\n     i consider this is more useful, you can always use `w` alias to see the watch changes.\n\n## Support\n\n  * MRI 2.6+\n\n## History\n\n  See [CHANGELOG](https://github.com/zw963/pryx/blob/master/CHANGELOG) for details.\n\n## Contributing\n\n  * [Bug reports](https://github.com/zw963/pryx/issues)\n  * [Source](https://github.com/zw963/pryx)\n  * Patches:\n    * Fork on Github.\n    * Run `gem install --dev pryx` or `bundle install`.\n    * Create your feature branch: `git checkout -b my-new-feature`.\n    * Commit your changes: `git commit -am 'Add some feature'`.\n    * Push to the branch: `git push origin my-new-feature`.\n    * Send a pull request :D.\n\t\n\tNot listed famous pry plugins is welcome!!\n\n## license\n\nReleased under the MIT license, See [LICENSE](https://github.com/zw963/pryx/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzw963%2Fpryx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzw963%2Fpryx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzw963%2Fpryx/lists"}