{"id":15288009,"url":"https://github.com/up2jj/conditioner","last_synced_at":"2025-03-24T03:45:32.841Z","repository":{"id":152762920,"uuid":"623129854","full_name":"up2jj/conditioner","owner":"up2jj","description":"Conditional logic utility","archived":false,"fork":false,"pushed_at":"2023-04-19T18:24:14.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T10:16:02.141Z","etag":null,"topics":["boolean-logic","elixir","elixir-lang","logic"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/up2jj.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":"2023-04-03T18:55:33.000Z","updated_at":"2023-04-21T20:26:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"8ca700dd-00ed-4b31-b494-f415b2be317b","html_url":"https://github.com/up2jj/conditioner","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/up2jj%2Fconditioner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/up2jj%2Fconditioner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/up2jj%2Fconditioner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/up2jj%2Fconditioner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/up2jj","download_url":"https://codeload.github.com/up2jj/conditioner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245206530,"owners_count":20577582,"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":["boolean-logic","elixir","elixir-lang","logic"],"created_at":"2024-09-30T15:43:46.053Z","updated_at":"2025-03-24T03:45:32.812Z","avatar_url":"https://github.com/up2jj.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Conditioner\n\n[![hex.pm version](https://img.shields.io/hexpm/v/conditioner?color=green)](https://hex.pm/packages/conditioner)\n\n---\n\n## Introduction\n\nConditioner allows you to define and process conditional logic in separated way:\n\n1. Create logical representation of conditions:\n\n```elixir\nconditions = %{\n      \"and\" =\u003e [\n        [\"filename\", \"containsfn\", \"he\"],\n        [\"filename\", \"containsfn\", \"lo\"],\n        [\"otherrule\", \"contains\", \"lo\"],\n        %{\n          \"or\" =\u003e [\n            [\"filename\", \"containsfn\", \"bo\"],\n            [\"filename\", \"containsfn\", \"he\"],\n            %{\"and\" =\u003e true}\n          ]\n        }\n      ]\n    }\n\n```\n\n2. Define matcher module with rules:\n\n```elixir\n  defmodule SomeMatcher do\n    # using Conditioner.Matcher is optional, but module provides some convenient functions\n    use Conditioner.Matcher\n\n    def match?([\"filename\", \"containsfn\", str], _original_value) do\n      # match?/2 can return anonymous function or boolean value \n      fn val -\u003e\n        String.contains?(val, str)\n      end\n    end\n\n    def match?([\"otherrule\", \"contains\", str], _original_value) do\n      String.contains?(value, str)\n    end\n\n    def match?(\"hello\", \"hello\") do\n      # rule pattern can by anything, i.e. plain string\n      true\n    end\n  end\n```\n\n3. Verify conditions by calling matcher with rules:\n\n```elixir\nresult = Conditioner.match?(conditions, \"hello\", SomeMatcher)\n```\n\n## Goals\n\n1. Conditions are represented as map, so they can be easily serialized and stored,\n\n2. Rules can be represented as any type, as long as rule can be matched by pattern matching mechanism in Elixir,\n\n3. Matcher can be defined as module or anonymous function.\n\n## Changelog\n\n* 0.2.2 - docs improvements, add custom caller exception, \n\n* 0.2.1 - support defining matcher as fun with arity 2,\n\n* 0.2.0 - changed `Conditioner.Matcher.match/3` function signature to `match?/3`, docs improvements,\n\n* 0.1.0 - initial version.\n\n\n## Installation\n\n\n```elixir\ndef deps do\n  [\n    {:conditioner, \"~\u003e 0.2.2\"}\n  ]\nend\n```\n\nThe docs can be found at \u003chttps://hexdocs.pm/conditioner\u003e.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fup2jj%2Fconditioner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fup2jj%2Fconditioner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fup2jj%2Fconditioner/lists"}