{"id":16224346,"url":"https://github.com/camertron/commonjs-rhino","last_synced_at":"2025-04-08T01:47:21.187Z","repository":{"id":19349123,"uuid":"22588423","full_name":"camertron/commonjs-rhino","owner":"camertron","description":"CommonJs support for Rhino, in Ruby.","archived":false,"fork":false,"pushed_at":"2015-07-12T21:38:04.000Z","size":140,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T01:52:19.930Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/camertron.png","metadata":{"files":{"readme":"README.md","changelog":"History.txt","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-04T01:39:11.000Z","updated_at":"2019-02-19T15:06:45.000Z","dependencies_parsed_at":"2022-08-31T05:20:46.786Z","dependency_job_id":null,"html_url":"https://github.com/camertron/commonjs-rhino","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/camertron%2Fcommonjs-rhino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/camertron%2Fcommonjs-rhino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/camertron%2Fcommonjs-rhino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/camertron%2Fcommonjs-rhino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/camertron","download_url":"https://codeload.github.com/camertron/commonjs-rhino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247761029,"owners_count":20991533,"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-10T12:23:56.970Z","updated_at":"2025-04-08T01:47:21.164Z","avatar_url":"https://github.com/camertron.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/camertron/commonjs-rhino.svg)](https://travis-ci.org/camertron/commonjs-rhino) [![Code Climate](https://codeclimate.com/github/camertron/commonjs-rhino/badges/gpa.svg)](https://codeclimate.com/github/camertron/commonjs-rhino) [![Test Coverage](https://codeclimate.com/github/camertron/commonjs-rhino/badges/coverage.svg)](https://codeclimate.com/github/camertron/commonjs-rhino/coverage)\n\ncommonjs-rhino\n==============\n\nCommonJs support for Rhino, in Ruby (JRuby specifically). commonjs-rhino allows you to create JavaScript contexts that contain a `require` method you can use to load CommonJs modules.\n\n## Installation\n\n`gem install commonjs-rhino`\n\nThen, require it somewhere in your code:\n\n```ruby\nrequire 'commonjs-rhino'\n```\n\nPlease be aware this gem requires Mozilla's Rhino JavaScript environment, which means Rhino will need to be somewhere in your Java classpath. commonjs-rhino was developed using [expert](https://github.com/camertron/expert). You may find it convenient to use expert in your own project to manage commonjs-rhino's Java dependencies. Just add expert to your bundle and add these lines in your project:\n\n```ruby\nrequire 'expert'\nExpert.environment.require_all\n\nrequire 'commonjs-rhino'\n# your code here\n```\n\n## Usage\n\nLet's say you have this nice little CommonJs JavaScript module you'd like to use in Rhino. The module exists on disk at `/path/to/camertron/teapot.js`:\n\n```javascript\n(function() {\n  module.exports.strVariable = 'foobarbaz';\n  module.exports.func = function() {\n    return \"I'm a little teapot\";\n  };\n}).call();\n```\n\nCreate a commonjs-rhino context, point it at your modules, and require away:\n\n```ruby\ncontext = CommonjsRhino.create_context(['/path/to/camertron'])\ncontext.eval('var hello = require(\"camertron/teapot\")')\ncontext.eval('hello.strVariable')  # =\u003e 'foobarbaz'\n```\n\nIt's that easy!\n\nYou can also evaluate files with the handy `eval_file` method:\n\n```ruby\ncontext.eval_file('/path/to/file.js')\n```\n\n## Requirements\n\n1. [JRuby](http://jruby.org/)\n2. [Rhino](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino) in your classpath (see above).\n\n## Running Tests\n\n`bundle exec rspec` should do the trick :)\n\n## Authors\n\n* Cameron C. Dutro: http://github.com/camertron\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamertron%2Fcommonjs-rhino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcamertron%2Fcommonjs-rhino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamertron%2Fcommonjs-rhino/lists"}