{"id":26705403,"url":"https://github.com/tangledpath/ruby-state-machine","last_synced_at":"2025-04-13T14:40:45.327Z","repository":{"id":55086946,"uuid":"10490715","full_name":"tangledpath/ruby-state-machine","owner":"tangledpath","description":"A full-featured state machine gem for use within ruby.  It can be used within Rails, but Rails is not required.","archived":false,"fork":false,"pushed_at":"2021-01-11T19:20:57.000Z","size":13,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-27T05:35:26.699Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/tangledpath.png","metadata":{"files":{"readme":"README.md","changelog":"History.txt","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":"2013-06-04T23:08:33.000Z","updated_at":"2023-01-23T05:06:06.000Z","dependencies_parsed_at":"2022-08-14T11:31:24.023Z","dependency_job_id":null,"html_url":"https://github.com/tangledpath/ruby-state-machine","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangledpath%2Fruby-state-machine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangledpath%2Fruby-state-machine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangledpath%2Fruby-state-machine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangledpath%2Fruby-state-machine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tangledpath","download_url":"https://codeload.github.com/tangledpath/ruby-state-machine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248731224,"owners_count":21152791,"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":[],"created_at":"2025-03-27T05:34:10.904Z","updated_at":"2025-04-13T14:40:45.053Z","avatar_url":"https://github.com/tangledpath.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Ruby State Machine\nRuby State Machine (ruby-state-machine) is a full-featured state machine gem for use within ruby.  It can also be used in Rails.  This was written because we required a state machine that allowed different actions to be performed based on the previous and current events, as well as injecting logic (a \"decider\") to determine the next event.  \n\n## Installation:\n\nAdd this line to your application's Gemfile:\n\n    gem 'ruby-state-machine'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install ruby-state-machine\n\n## Location:\nHere: http://github.com/tangledpath/ruby-state-machine\n\nRDocs: http://ruby-state-mach.rubyforge.org/\n\n\n## USAGE:\n\n```ruby\nrequire 'ruby-state-machine/state_machine'\n\n# Note, a state machine is not created directly; instead, the behavior of a state\n# machine is added through a mixin, e.g.:\nclass SampleMachine\n  include StateMachine\n  state_machine :states =\u003e [:a_state, :b_state, :c_state, :d_state], :events =\u003e [:w_event, :x_event, :y_event, :z_event]\n  state_transition :state=\u003e:a_state, :event=\u003e:x_event, :next=\u003e:c_state # Define next state for :a_state when :x_event is sent\n  state_transition :state=\u003e:a_state, :event=\u003e:y_event, :next=\u003e:a_state # Define next state for :a_state when :y_event is sent\n  state_transition :state=\u003e:a_state, :event=\u003e:z_event, :next=\u003e:b_state # ...\n                                                            \n  state_transition :state=\u003e:b_state, :event=\u003e:w_event, :next=\u003e:b_state\n  state_transition :state=\u003e:b_state, :event=\u003e:y_event, :next=\u003e:c_state\n  state_transition :state=\u003e:b_state, :event=\u003e:z_event, :next=\u003e:a_state\n                                                            \n  state_transition :state=\u003e:c_state, :event=\u003e:x_event, :next=\u003e:b_state\nend\n\nsm = SampleMachine.new\nputs sm.current_state # :a_state\nsm.send_event(:x_event)\nputs sm.current_state # :c_state\n```\n\nFor examples of other functionality, including branching, deciders, lambdas, etc, see http://ruby-state-mach.rubyforge.org/StateMachine/ClassMethods.html#state_transition-instance_method.\n\n\n## CONTRIBUTE\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## LICENSE:\n\n(The MIT License)\n\nCopyright (c) 2007-2013 Steven Miers\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangledpath%2Fruby-state-machine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftangledpath%2Fruby-state-machine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangledpath%2Fruby-state-machine/lists"}