{"id":16228719,"url":"https://github.com/bibendi/simple_contracts","last_synced_at":"2026-05-02T03:31:21.955Z","repository":{"id":56905098,"uuid":"140147545","full_name":"bibendi/simple_contracts","owner":"bibendi","description":"Plain Old Ruby Object Implementation of Contract.","archived":false,"fork":false,"pushed_at":"2018-10-10T11:54:13.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-16T20:10:47.121Z","etag":null,"topics":["contracts","docker","ruby"],"latest_commit_sha":null,"homepage":"","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/bibendi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-08T07:40:52.000Z","updated_at":"2018-11-05T08:34:10.000Z","dependencies_parsed_at":"2022-08-20T19:20:27.515Z","dependency_job_id":null,"html_url":"https://github.com/bibendi/simple_contracts","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bibendi/simple_contracts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibendi%2Fsimple_contracts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibendi%2Fsimple_contracts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibendi%2Fsimple_contracts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibendi%2Fsimple_contracts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bibendi","download_url":"https://codeload.github.com/bibendi/simple_contracts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibendi%2Fsimple_contracts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32522227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"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":["contracts","docker","ruby"],"created_at":"2024-10-10T12:56:18.886Z","updated_at":"2026-05-02T03:31:21.938Z","avatar_url":"https://github.com/bibendi.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/bibendi/simple_contracts.svg?branch=master)](https://travis-ci.org/bibendi/simple_contracts)\n[![Maintainability](https://api.codeclimate.com/v1/badges/7bbb13403a539b107863/maintainability)](https://codeclimate.com/github/bibendi/simple_contracts/maintainability)\n[![Cult Of Martians](http://cultofmartians.com/assets/badges/badge.svg)](https://cultofmartians.com/tasks/simple-contracts.html)\n\n# SimpleContracts\n\n\u003ca href=\"https://evilmartians.com/?utm_source=simple_contracts\"\u003e\n\u003cimg src=\"https://evilmartians.com/badges/sponsored-by-evil-martians.svg\" alt=\"Sponsored by Evil Martians\" width=\"236\" height=\"54\"\u003e\u003c/a\u003e\n\n## Plain Old Ruby Object Implementation of Contract\n\nThis project contains the most simple implementation of Contract written in Ruby (and maybe later in other languages).\n\nThe Contract is inspired by Design by Contracts approach and pushes Fail Fast techinque further.\n\nSo, Contract is a class with the only public method , that validates some action/behavior agains Contract Rules:\n - Guarantees - the rules that SHOULD be valid for each check of behavior\n - Expectations - list of all expected states that COULD be valid for the behavior check\n\nContract validates, that:\n - ALL Guarantees were met\n - AT LEAST ONE Expectations was met\n\nOtherwise, Contract raises an exception with details, at least on what step behavior was broken.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'simple_contracts'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install simple_contracts\n\n## Usage\n\n```ruby\n  class TwitterContract \u003c SimpleContracts::Base\n    def initialize(post)\n      super\n      @post = post\n    end\n\n    private\n\n    def guarantee_verified_delete\n      return true if Twitter::REST::Client.statuses(@post.tweet_id).empty?\n      false\n    end\n\n    def expect_some_action1\n      ...\n    end\n\n    def expect_some_action2\n      ...\n    end\n\n    # ... other rules\n  end\n\n  @post = Post.find(params.require(:post_id))\n\n  # Use synchronously, (raises exception, \"Fails Fast\"™):\n  TwitterContract.(@post, async: false) { TwitterAPI.destroy(@post) }\n\n  # Use asynchronously (does not affect TwitterAPI.destroy,\n  # but tracks any problems with TwitterContract validation)\n  TwitterContract.(@post) { TwitterAPI.destroy(@post) }\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/bibendi/simple_contracts.\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%2Fbibendi%2Fsimple_contracts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbibendi%2Fsimple_contracts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbibendi%2Fsimple_contracts/lists"}