{"id":15584344,"url":"https://github.com/jhund/multi_ruby_runner","last_synced_at":"2025-04-12T06:41:00.619Z","repository":{"id":56884810,"uuid":"54062268","full_name":"jhund/multi_ruby_runner","owner":"jhund","description":"Execute Ruby code in different Ruby environments. It lets you for example call JRuby code from MRI. It relies on rbenv or RVM to manage the Ruby runtime environment.","archived":false,"fork":false,"pushed_at":"2024-04-16T15:39:03.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T02:03:15.244Z","etag":null,"topics":["mri","rbenv","ruby","ruby-environment","ruby-script","rvm"],"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/jhund.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.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-03-16T19:56:19.000Z","updated_at":"2024-04-16T15:35:12.000Z","dependencies_parsed_at":"2024-10-02T20:41:03.004Z","dependency_job_id":"2eb56d31-db59-458c-8f62-730b1d206a9d","html_url":"https://github.com/jhund/multi_ruby_runner","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"b3e1bfea38d13fb73a1919e5013d08bbc3cb532d"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhund%2Fmulti_ruby_runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhund%2Fmulti_ruby_runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhund%2Fmulti_ruby_runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhund%2Fmulti_ruby_runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhund","download_url":"https://codeload.github.com/jhund/multi_ruby_runner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530609,"owners_count":21119591,"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":["mri","rbenv","ruby","ruby-environment","ruby-script","rvm"],"created_at":"2024-10-02T20:40:50.411Z","updated_at":"2025-04-12T06:41:00.587Z","avatar_url":"https://github.com/jhund.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi Ruby Runner\n\nThis gem lets you call Ruby code in one Ruby environment from Ruby code in another environment.\n\nIt makes use of Ruby version managers to switch the Ruby runtime environment. Typically you will write a ruby script that executes the code you want and call that script via MultiRubyRunner in the desired Ruby runtime environment.\n\nExamples:\n\n* Call JRuby code from MRI 2.3.0\n* Call MRI 1.9.3 code from MRI 2.2.1\n\n## Requirements\n\n### Operating system\n\n* Linux: Not tested, but should work.\n* OS X: Tested and works.\n* Windows: I don’t think it works, and I have no plans of supporting this scenario.\n\n### Ruby version manager\n\n* rbenv: Works\n* RVM: Works\n* None: You really should use a Ruby version manager :-)\n\n### Ruby versions\n\nCaller: The Ruby code that invokes other ruby code.\nCallee: The Ruby code being invoked.\n\n* MRI: Works for caller and callee.\n* JRuby: Works for callee. May not work for caller as we use `fork` in a non-blocking use case.\n* Rubinius: Not tested, however it should work.\n\n### Bundler\n\nWe have Bundler baked into the Gem via `Bundler.with_clean_env`. This is not necessary for overall functionality. I assume you’re using Bundler.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'multi_ruby_runner'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install multi_ruby_runner\n\n## Usage\n\n### Blocking (without fork)\n\nIf you want to execute a Ruby script and wait for its result via output to STDOUT, use this snippet:\n\n    mrr = MultiRubyRunner.new\n    stdout = mrr.execute_command_in_directory(\n      \"./bin/ruby-script-to-execute argument1 argument2\",\n      \"/path/to/folder/that/sets/ruby/env\"\n    )\n\nNote that we’re passing `argument1` and `argument2` as positional arguments to the callee Ruby script.\n\n### Non blocking (with fork)\n\nIf you just want to start a process and return back to the caller right away, you can set the `:blocking` option to false. In that case you will get the child process’ PID as return value. This is useful if you want to start a service and communicate with it e.g., via `Sockets`.\n\n    mrr = MultiRubyRunner.new\n    child_pid = mrr.execute_command_in_directory(\n      \"./bin/ruby-script-to-execute argument1 argument2\",\n      \"/path/to/folder/that/sets/ruby/env\",\n      blocking: false\n    )\n\nYou can communicate with the child process via pipes or sockets.\n\n### Ruby scripts to call\n\nHere is an example Ruby script that can be called via MultiRubyRunner:\n\n    #!/usr/bin/env ruby\n\n    # This is an example callee script for MultiRubyRunner\n\n    require_relative '../lib/path/to/your/ruby/code'\n\n    # Check for arguments\n    arg1 = ARGV[0]\n    arg2 = ARGV[1]\n\n    # Puts will return some text to STDOUT\n    puts \"The current time is #{ Time.now }\"\n\nPlease note that even if you use JRuby, you keep `ruby` in the shebang. Your Ruby version manager will make sure that the code will be executed by JRuby.\n\n## Additional resources\n\nI found Jesse Storimer’s books `Working With Unix Processes` and `Working With TCP Sockets` very helpful.\n\n## Contributing\n\n1. Fork it ( https://github.com/jhund/multi_ruby_runner/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n### Resources\n\n* [Source code (github)](https://github.com/jhund/multi_ruby_runner)\n* [Issues](https://github.com/jhund/multi_ruby_runner/issues)\n* [Rubygems.org](http://rubygems.org/gems/multi_ruby_runner)\n\n### License\n\n[MIT licensed](https://github.com/jhund/multi_ruby_runner/blob/master/LICENSE.txt).\n\n### Copyright\n\nCopyright (c) 2016 Jo Hund. See [(MIT) LICENSE](https://github.com/jhund/multi_ruby_runner/blob/master/LICENSE.txt) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhund%2Fmulti_ruby_runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhund%2Fmulti_ruby_runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhund%2Fmulti_ruby_runner/lists"}