{"id":18605330,"url":"https://github.com/fny/self_control","last_synced_at":"2025-05-17T09:41:26.940Z","repository":{"id":182112543,"uuid":"667975814","full_name":"fny/self_control","owner":"fny","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-18T18:20:56.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T00:02:24.994Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fny.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-18T18:17:08.000Z","updated_at":"2023-07-18T18:17:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"dfe6631b-b7d5-47f1-bbc0-d17c85063909","html_url":"https://github.com/fny/self_control","commit_stats":null,"previous_names":["fny/self_control"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fny%2Fself_control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fny%2Fself_control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fny%2Fself_control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fny%2Fself_control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fny","download_url":"https://codeload.github.com/fny/self_control/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254595057,"owners_count":22097474,"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":"2024-11-07T02:20:56.348Z","updated_at":"2025-05-17T09:41:26.483Z","avatar_url":"https://github.com/fny.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SelfControl 🎛\n\nControl flow with an audit trail for conditional statements. Track your ifs and elses to make debugging gnarly conditionals a breeze.\n\n## About\n\nSelfControl was sponsored by Greenlight COVID-19 monitoring to\ndebug deeply nested logic used to determine whether students and teachers are fit to return to school.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'self_control'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install self_control\n\n## Usage\n\nI'm an extremely complicated person. Figuring out when I want to ice cream is hard.\n\n```ruby\nrequire 'self_control'\n\n@temperature = 70\n@income = 10\n\ndef sunny?; false; end\ndef having_cravings?; true; end\ndef hot?; @temperature \u003e 97; end\ndef have_enough_money; @income \u003e 2; end\ndef temperature_moderate?; @temperature \u003e 50; end\n\nflow = SelfControl::Flow.new(self) do\n  If(:hot?) {\n    Return(:yes)\n  }.Elsif(And(:sunny?, :have_enough_money?)) {\n    Return(:yes)\n  }.Else {\n    If(:temperature_moderate?) {\n      If(:having_cravings?) {\n        Return(:yes)\n      }\n    }\n  }\n  Return(:no)\nend\n\nflow.result # =\u003e :yes\nputs(flow.trace)\n# root:\n#   branch 1.0:\n#     if: hot? =\u003e false\n#     elsif and: boolean =\u003e false\n#       sunny? =\u003e false\n#       have_enough_money =\u003e true\n#     else: boolean =\u003e true\n#     branch 2.0:\n#       if: temperature_moderate? =\u003e true\n#       branch 3.0:\n#         if: having_cravings? =\u003e true\n\n```\n\nWithin the specified target (in this case `self`):\n\nYou can also execute statements directly inside a branch, but you won't be able to see what was evaluated in the trace.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\nTo type check run:\n\n```\nsolargraph typecheck\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/fny/self_control.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffny%2Fself_control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffny%2Fself_control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffny%2Fself_control/lists"}