{"id":16372458,"url":"https://github.com/mgwidmann/rubixir","last_synced_at":"2025-10-04T19:38:04.602Z","repository":{"id":71789201,"uuid":"45784386","full_name":"mgwidmann/rubixir","owner":"mgwidmann","description":null,"archived":false,"fork":false,"pushed_at":"2016-02-25T06:27:34.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-24T22:35:48.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/mgwidmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2015-11-08T14:44:27.000Z","updated_at":"2023-09-01T11:57:59.000Z","dependencies_parsed_at":"2023-05-09T15:31:10.011Z","dependency_job_id":null,"html_url":"https://github.com/mgwidmann/rubixir","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mgwidmann/rubixir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Frubixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Frubixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Frubixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Frubixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgwidmann","download_url":"https://codeload.github.com/mgwidmann/rubixir/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Frubixir/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278366599,"owners_count":25975091,"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-04T02:00:05.491Z","response_time":63,"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-10-11T03:11:28.301Z","updated_at":"2025-10-04T19:38:04.587Z","avatar_url":"https://github.com/mgwidmann.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rubixir\n\nRun ruby code from the Erlang VM by writing it in Elixir syntax.\n\n## Installation\n\n  1. Add rubixir to your list of dependencies in mix.exs:\n\n    ```elixir\n    def deps do\n      [{:rubixir, \"~\u003e 0.0.1\"}]\n    end\n    ```\n\n  2. Ensure rubixir is started before your application:\n\n    ```elixir\n    def application do\n      [applications: [:rubixir]]\n    end\n    ```\n\n## Examples\n\nHere is an example using a class method to create a new object from a literal and then call a method on the resulting object. Notice the syntax is in Elixir syntax, but the generated string is in Ruby syntax.\n\n```elixir\niex\u003e to_ruby_string(quote do\niex\u003e   Hash.new(%{key: :value}).to_s\niex\u003e end)\n\"Hash.new({:key =\u003e :value}).to_s()\"\n```\n\nSo the only difference here is the way a map/hash is represented in both languages. Thats only because of the overlap in syntax. What went on was a complete compilation of Elixir AST to Ruby code, the Elixir statement was not simply transformed using `Macro.to_string/1`.\n\nPattern matching is also supported!\n\n```elixir\niex\u003e to_ruby_string(quote do\niex\u003e  [1, a, 3] = [1, 2, 3]\niex\u003e end) |\u003e IO.puts\n_rubixir_ = [1, 2, 3]\na = _rubixir_[1] rescue :_rubixir_nil_\nraise Rubixir::MatchError.new(_rubixir_) if a == :_rubixir_nil_\nraise Rubixir::MatchError.new(_rubixir_) unless (1 == _rubixir_[0] rescue false)\nraise Rubixir::MatchError.new(_rubixir_) unless (3 == _rubixir_[2] rescue false)\n_rubixir_\n```\n\nPatterns with hard values will raise exceptions on the ruby side, which gets propagated back to your Elixir code.\n\nYou can then talk directly to a ruby process like so:\n\n```elixir\niex\u003e worker = Rubixir.new\niex\u003e ruby worker do\niex\u003e   puts \"Hello Rubixir world!\"\niex\u003e end\nHello Rubixir world!\n```\n\nAnd get data back from it (in development):\n\n```elixir\niex\u003e user_posts = ruby do\niex\u003e   User.find(unquote(user_id)).posts\niex\u003e end\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgwidmann%2Frubixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgwidmann%2Frubixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgwidmann%2Frubixir/lists"}