{"id":13809244,"url":"https://github.com/balance-platform/ex_pression","last_synced_at":"2025-04-11T15:12:32.689Z","repository":{"id":216420712,"uuid":"738602073","full_name":"balance-platform/ex_pression","owner":"balance-platform","description":"Evaluate user input expressions","archived":false,"fork":false,"pushed_at":"2024-11-23T19:49:31.000Z","size":72,"stargazers_count":11,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T13:47:28.639Z","etag":null,"topics":["elixir","elixir-library","expression","expression-evaluator","user-input"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/balance-platform.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2024-01-03T15:55:26.000Z","updated_at":"2025-01-24T15:46:28.000Z","dependencies_parsed_at":"2024-01-17T08:04:35.570Z","dependency_job_id":"1c89c12f-1047-45a9-8871-9b4cfe212abf","html_url":"https://github.com/balance-platform/ex_pression","commit_stats":null,"previous_names":["balance-platform/ex_pression"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balance-platform%2Fex_pression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balance-platform%2Fex_pression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balance-platform%2Fex_pression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balance-platform%2Fex_pression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/balance-platform","download_url":"https://codeload.github.com/balance-platform/ex_pression/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248429117,"owners_count":21101785,"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":["elixir","elixir-library","expression","expression-evaluator","user-input"],"created_at":"2024-08-04T01:02:12.400Z","updated_at":"2025-04-11T15:12:32.503Z","avatar_url":"https://github.com/balance-platform.png","language":"Elixir","readme":"# ExPression\n[![Hex Version](https://img.shields.io/hexpm/v/ex_pression.svg)](https://hex.pm/packages/ex_pression)\n[![Docs](https://img.shields.io/badge/docs-hexpm-blue.svg)](https://hexdocs.pm/ex_pression)\n[![License](https://img.shields.io/hexpm/l/ex_pression.svg)](LICENSE)\n[![Coverage Status](https://coveralls.io/repos/github/balance-platform/ex_pression/badge.svg?branch=master)](https://coveralls.io/github/balance-platform/ex_pression?branch=master)\n\nEvaluate user input expressions.\n\n## Installation\nThe package can be installed by adding `ex_pression` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:ex_pression, \"~\u003e 0.5.0\"}\n  ]\nend\n```\n\n## Key features\n1. **Safe** evaluation without access to other Elixir modules.\n```elixir\niex\u003e ExPression.eval(\"exit(self())\")\n{:error, %ExPression.Error{name: \"UndefinedFunctionError\", message: \"Function 'self/0' was referenced, but was not defined\", data: %{function: :self}}}\n```\n\n2. Support for **JSON** syntax and data types.\n```elixir\niex\u003e ExPression.eval(\"\"\"\n{\n  \"name\": \"ex_pression\",\n  \"deps\": [\"xpeg\"]\n}\n\"\"\")\n{:ok, %{\"name\" =\u003e \"ex_pression\", \"deps\" =\u003e [\"xpeg\"]}}\n```\n\n3. Familiar **python**-like operators and standard functions.\n```elixir\niex\u003e ExPression.eval(~s/{\"1\": \"en\", \"2\": \"fr\"}[str(int_code)]/, bindings: %{\"int_code\" =\u003e 1})\n{:ok, \"en\"}\n```\n\n4. **Extend** expressions by providing Elixir module with functions that you want to use.\n```elixir\ndefmodule MyFunctions do\n  # use $ special symbol in expressions\n  def handle_special(\"$\", date_str), do: Date.from_iso8601!(date_str)\n  # Use diff function in expressions\n  def diff(date_1, date_2), do: Date.diff(date_1, date_2)\nend\n\niex\u003e ExPression.eval(~s/diff($\"2023-02-02\", $\"2022-02-02\")/, functions_module: MyFunctions)\n{:ok, 365}\n```\n\nFull language description can be found in [FULL_DESCRIPTION.md](./FULL_DESCRIPTION.md)\n\n## Implementation\nString representation of expression is parsed into AST form. Parsing is done with PEG grammar parser [xpeg](https://github.com/zevv/xpeg). Grammar is defined in module `ExPression.Parser.Grammar`.\nAST interpretation logic is written in plain `Elixir` in module `ExPression.Interpreter`.\n\n## Contribution\nFeel free to make a pull request. All contributions are appreciated!\n","funding_links":[],"categories":["Text and Numbers"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalance-platform%2Fex_pression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbalance-platform%2Fex_pression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalance-platform%2Fex_pression/lists"}