{"id":16701683,"url":"https://github.com/coryodaniel/res","last_synced_at":"2025-09-24T00:30:32.466Z","repository":{"id":55883157,"uuid":"146633942","full_name":"coryodaniel/res","owner":"coryodaniel","description":"Elixir state machine demo","archived":false,"fork":false,"pushed_at":"2020-12-09T17:18:31.000Z","size":5,"stargazers_count":2,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T04:17:27.124Z","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/coryodaniel.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":"2018-08-29T17:19:11.000Z","updated_at":"2023-09-06T17:47:16.000Z","dependencies_parsed_at":"2022-08-15T08:31:34.581Z","dependency_job_id":null,"html_url":"https://github.com/coryodaniel/res","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coryodaniel/res","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryodaniel%2Fres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryodaniel%2Fres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryodaniel%2Fres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryodaniel%2Fres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coryodaniel","download_url":"https://codeload.github.com/coryodaniel/res/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryodaniel%2Fres/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276673568,"owners_count":25683938,"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-09-23T02:00:09.130Z","response_time":73,"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-12T18:45:10.704Z","updated_at":"2025-09-24T00:30:32.402Z","avatar_url":"https://github.com/coryodaniel.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Res\n\nThere are two state machine libraries you should probably check out, but this is a pretty straight forward implementation of a functional state machine without dependencies.\n\n* gen_fsm\n* machinery\n\n## To run\n\n```\nbrew install elixir\n\nmix deps.get # build dependencies\n\nmix docs # builds documentation for this project\nopen doc/index.html\nopen doc/Res.Machine.html\nopen doc/Res.State.html\n\nmix test\n```\n\nThis is a simple example of dynamically create-able state machines.\n\nIt supports:\n\n* creating state machines in JSON (priv/example.json)\n* transitions\n* tracking errors on transitions\n* pluggable transition logger (very simple: stdout, memory) Set to memory\n\nIt doesn't support:\n\n* callbacks\n* named transition (currently open =\u003e reserved, instead of passing a verb like \"book\" to book the room)\n* validating states/transition names (if you have a state named \"open\" but put a transition to value of \"opne\")\n\nRun this script to simulate a state for a single room:\n\n```shell\niex -S mix\n```\n\n`mix` is the build tool\n`iex` is the repl\n\nIn the context above you are loading the build tool (which compile the app) into a repl for you to interact with it.\n\n```elixir\nRes.Logger.Memory.start_link() # This will start the memory store\nmachine = Res.Machine.parse(\"priv/example.json\")\n\nstate = Res.Machine.init(machine)\nIO.puts state.current_state\n\n{:ok, state} = Res.Machine.transition(state, machine, \"reserved\")\nIO.puts state.current_state\n\n{:ok, state} = Res.Machine.transition(state, machine, \"in use\")\nIO.puts state.current_state\nIO.puts state.previous_state\n\n# This will fail\n{:error, state} = Res.Machine.transition(state, machine, \"reserved\")\n\nIO.puts state.current_state\nIO.puts state.error\nIO.puts Res.State.valid?(state)\n\nRes.Logger.Memory.list()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoryodaniel%2Fres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoryodaniel%2Fres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoryodaniel%2Fres/lists"}