{"id":22204112,"url":"https://github.com/flarebyte/boolean_rhapsody","last_synced_at":"2025-08-13T03:17:03.481Z","repository":{"id":266052094,"uuid":"897229914","full_name":"flarebyte/boolean_rhapsody","owner":"flarebyte","description":"Tune into the truth with Boolean Rhapsody in Dart","archived":false,"fork":false,"pushed_at":"2025-07-11T05:28:54.000Z","size":1177,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-02T14:05:48.047Z","etag":null,"topics":["dart","dart-package"],"latest_commit_sha":null,"homepage":"","language":"Dart","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/flarebyte.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null}},"created_at":"2024-12-02T09:15:15.000Z","updated_at":"2025-07-11T05:28:56.000Z","dependencies_parsed_at":"2025-02-08T07:24:22.435Z","dependency_job_id":"2288e62c-3c94-4aa4-9232-29d67964ae28","html_url":"https://github.com/flarebyte/boolean_rhapsody","commit_stats":null,"previous_names":["flarebyte/boolean_rhapsody"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/flarebyte/boolean_rhapsody","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flarebyte%2Fboolean_rhapsody","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flarebyte%2Fboolean_rhapsody/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flarebyte%2Fboolean_rhapsody/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flarebyte%2Fboolean_rhapsody/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flarebyte","download_url":"https://codeload.github.com/flarebyte/boolean_rhapsody/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flarebyte%2Fboolean_rhapsody/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270173393,"owners_count":24539590,"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-08-13T02:00:09.904Z","response_time":66,"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":["dart","dart-package"],"created_at":"2024-12-02T17:16:01.368Z","updated_at":"2025-08-13T03:17:03.459Z","avatar_url":"https://github.com/flarebyte.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# boolean\\_rhapsody\n\n![Experimental](https://img.shields.io/badge/status-experimental-blue)\n\n\u003e Tune into the truth with Boolean Rhapsody in Dart\n\nA module for evaluating boolean expressions using predefined functions,\nlogical operators, and references to previously defined rules.\n\n![Hero image for boolean\\_rhapsody](doc/boolean_rhapsody.jpeg)\n\nHighlights:\n\n-   Combine predefined boolean functions, logical operators (`and`, `or`,\n    `not`), and parentheses to create complex expressions.\n-   Supports referencing previously defined rules for modular and reusable\n    logic.\n-   Ensures strict validation of syntax, variable existence, and type\n    compatibility for robust execution.\n-   Functions evaluate conditions based on a dynamic context and return\n    boolean results.\n-   Clear and well-defined grammar prioritizing expressiveness and error\n    prevention.\n\nA few examples:\n\nCheck if a required environment variable is present:\n\n```dart\nis_present(env:flag:green);\n```\n\nValidate that a numeric score exceeds a threshold:\n\n```dart\nnumber_greater_than(env:score, config:passing_score);\n```\n\nCompare string values for exact match:\n\n```dart\nstring_equals(env:mode, config:expected_mode);\n```\n\nConfirm that a timestamp is before a configured deadline:\n\n```dart\ndate_time_less_than(env:submission_time, config:deadline);\n```\n\nEnsure a minimum number of items in a list:\n\n```dart\nlist_size_greater_than_equals(env:cart_items, config:min_required);\n```\n\nCheck if a user's roles include all required permissions:\n\n```dart\nis_superset_of(env:user_roles, config:required_roles);\n```\n\nInstantiate function registry containing boolean functions like\nstring\\_equals:\n\n```dart\nfinal functionRegistry = BooleanRhapsodyFunctionRegistry();\n```\n\nConfigure analyser options with allowed prefixes, functions, and a variable\nvalidator:\n\n```dart\nfinal options = RhapsodyAnalyserOptions(\n  prefixes: ['env', 'config'],\n  functions: rhapsodyFunctionNames,\n  variableValidator: (name) =\u003e RegExp(r'^[a-zA-Z][a-zA-Z0-9]*$').hasMatch(name),\n  functionRegistry: functionRegistry,\n);\n\n```\n\nTokenise rule strings into a list of tokens:\n\n```dart\nfinal tokeniser = RhapsodyTokeniser();\nfinal tokens = tokeniser.parse('rule example = is_present(env:flag);');\n\n```\n\nPerform semantic analysis on parsed tokens:\n\n```dart\nfinal analyser = RhapsodySemanticAnalyser(options);\nfinal analysis = analyser.analyse(tokens);\n\n```\n\nInstantiate interpreter with analysed rule structure:\n\n```dart\nfinal interpreter = RhapsodyInterpreter(analysis);\n```\n\nCreate evaluation context with variable bindings:\n\n```dart\nRhapsodyEvaluationContextBuilder builder =\n RhapsodyEvaluationContextBuilder(prefixes: ['env', 'config']);\n builder.setRefValue('env:state', 'green');\n builder.setRefValue('env:alert', 'panic');\n RhapsodyEvaluationContext context = builder.build();\n\n```\n\nInterpret rules against the provided evaluation context:\n\n```dart\ninterpreter.interpret(context);\n```\n\nPrint or inspect rule evaluation results:\n\n```dart\nprint(context.ruleState.states);\n```\n\n## Documentation and links\n\n-   [Code Maintenance :wrench:](MAINTENANCE.md)\n-   [Code Of Conduct](CODE_OF_CONDUCT.md)\n-   [Contributing :busts\\_in\\_silhouette: :construction:](CONTRIBUTING.md)\n-   [Architectural Decision Records :memo:](DECISIONS.md)\n-   [Contributors\n    :busts\\_in\\_silhouette:](https://github.com/flarebyte/boolean_rhapsody/graphs/contributors)\n-   [Dependencies](https://github.com/flarebyte/boolean_rhapsody/network/dependencies)\n-   [Glossary\n    :book:](https://github.com/flarebyte/overview/blob/main/GLOSSARY.md)\n-   [Software engineering principles\n    :gem:](https://github.com/flarebyte/overview/blob/main/PRINCIPLES.md)\n-   [Overview of Flarebyte.com ecosystem\n    :factory:](https://github.com/flarebyte/overview)\n-   [Dart dependencies](DEPENDENCIES.md)\n-   [Internal dependencies](INTERNAL-DEPENDENCIES.md)\n-   [Usage](USAGE.md)\n-   [Example](example/example.dart)\n\n## Related\n\n-   [form\\_validator](https://pub.dev/packages/form_validator)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflarebyte%2Fboolean_rhapsody","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflarebyte%2Fboolean_rhapsody","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflarebyte%2Fboolean_rhapsody/lists"}