{"id":13665694,"url":"https://github.com/rosenfeld/rack_web_console","last_synced_at":"2025-10-10T03:06:15.681Z","repository":{"id":56890275,"uuid":"63982764","full_name":"rosenfeld/rack_web_console","owner":"rosenfeld","description":"A web console for Rack apps.","archived":false,"fork":false,"pushed_at":"2024-10-19T18:58:36.000Z","size":18,"stargazers_count":30,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-09T03:11:36.004Z","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/rosenfeld.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2016-07-22T20:58:16.000Z","updated_at":"2024-10-19T18:58:23.000Z","dependencies_parsed_at":"2024-01-17T03:17:48.500Z","dependency_job_id":"10d70d44-9d1a-4ada-a4e2-cb88b353e257","html_url":"https://github.com/rosenfeld/rack_web_console","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"310574d519b1770fc771bc6b2734e1042215a9cb"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/rosenfeld/rack_web_console","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosenfeld%2Frack_web_console","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosenfeld%2Frack_web_console/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosenfeld%2Frack_web_console/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosenfeld%2Frack_web_console/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rosenfeld","download_url":"https://codeload.github.com/rosenfeld/rack_web_console/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosenfeld%2Frack_web_console/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002551,"owners_count":26083417,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-02T06:00:47.659Z","updated_at":"2025-10-10T03:06:15.654Z","avatar_url":"https://github.com/rosenfeld.png","language":"Ruby","readme":"# Rack Web Console [![Build Status](https://travis-ci.org/rosenfeld/rack_web_console.svg?branch=master)](https://travis-ci.org/rosenfeld/rack_web_console)\n\nRack Web Console is a simple Rack app class that allows one to run arbitrary Ruby code on a given\nbinding, which may be useful in development mode to test some code in a given context. This is\nsimilar to the `rails-web-console` (it was indeed extracted from it with a few enhancements) but\nworks for any Rack based application, including Rails.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'rack_web_console'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install rack_web_console\n\n## Usage\n\nThe hello world is not much useful, but here you are:\n\n```ruby\n# config.ru\nrequire 'rack_web_console'\nrun RackConsole.new binding\n```\n\nUsually, you'd be more interested in learning about the binding which is usually a controller\nor something like that. For example, if you want to test code from inside a Roda's `route` block:\n\n```ruby\n# config.ru\nrequire 'roda'\nrequire 'rack_web_console'\n\nclass App \u003c Roda\n  route do |r|\n    r.on('console'){ halt RackConsole.new(binding) } if ENV['RACK_ENV'] == 'development'\n    'default response'\n  end\nend\n\nrun App\n```\n\nThe local variable `r` would be available in the console for example in this case. Some\nframeworks may not have a method like Roda's `halt`, so in a Rails application for example,\nyou may have to do this:\n\n``` ruby\n# app/controllers/console_controller.rb:\nrequire 'rack_web_console'\nclass ConsoleController \u003c ApplicationController\n  skip_forgery_protection\n\n  def index\n    status, headers, body = RackConsole.new(binding).call(request.env)\n    response.headers.merge! headers\n    render html: body.join(\"\\n\").html_safe, status: status\n  end\nend\n\n# routes.rb:\nRails.application.routes.draw do\n  # ...\n  match 'console' =\u003e 'console#index', via: [:get, :post] if Rails.env.development?\nend\n```\n\nThis example demonstrates how to use it with a Rails project, but it could be used with basically\nany framework. If you're not really interested on some specific binding, you can simply mount it\ndirectly in config.ru:\n\n```ruby\n# config.ru\nrequire_relative 'config/environment'\n\nrequire 'rack_web_console'\nmap('/console'){ run RackConsole.new }\n\nrun Rails.application\n```\n\nBy default, only the output of the request thread is sent to the POST request response. If you\nwant to spawn new threads from the script and see the output of all threads, set the\n`:rack_console_capture_all` thread local to true:\n\n```ruby\nThread.current[:rack_console_capture_all] = true\nThread.start{ puts 'now it should be displayed in the browser' }.join\n```\n\n### Shortcuts from inside the textarea\n\n- Ctrl+Enter: Run code\n- Esc, Esc: Clear output\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec`\nto run the tests. You can also run `bin/console` for an interactive prompt that will allow\nyou to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a\nnew version, update the version number in `version.rb`, and then run `bundle exec rake\nrelease`, which will create a git tag for the version, push git commits and tags, and\npush the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome [on GitHub](https://github.com/rosenfeld/rack_web_console).\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","funding_links":[],"categories":["1. language"],"sub_categories":["1.1 ruby"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosenfeld%2Frack_web_console","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frosenfeld%2Frack_web_console","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosenfeld%2Frack_web_console/lists"}