{"id":21496498,"url":"https://github.com/mlibrary/canister","last_synced_at":"2025-07-15T19:32:37.454Z","repository":{"id":62554918,"uuid":"120537325","full_name":"mlibrary/canister","owner":"mlibrary","description":"A simple IoC container for ruby","archived":false,"fork":false,"pushed_at":"2023-10-24T22:10:52.000Z","size":33,"stargazers_count":11,"open_issues_count":2,"forks_count":2,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-10-30T16:52:24.418Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mlibrary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-02-06T23:41:21.000Z","updated_at":"2023-11-16T17:02:27.000Z","dependencies_parsed_at":"2022-11-03T05:15:40.248Z","dependency_job_id":"e8937567-8a6e-47d6-8edc-1ac0d970cfc8","html_url":"https://github.com/mlibrary/canister","commit_stats":{"total_commits":21,"total_committers":2,"mean_commits":10.5,"dds":0.04761904761904767,"last_synced_commit":"acd8c780c5e7f6bd246c52ec0f77f41c83b2b346"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlibrary%2Fcanister","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlibrary%2Fcanister/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlibrary%2Fcanister/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlibrary%2Fcanister/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlibrary","download_url":"https://codeload.github.com/mlibrary/canister/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226064472,"owners_count":17568036,"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-23T16:16:45.144Z","updated_at":"2024-11-23T16:16:45.757Z","avatar_url":"https://github.com/mlibrary.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Canister\n\n[![Build Status](https://travis-ci.org/mlibrary/canister.svg?branch=master)](https://travis-ci.org/mlibrary/canister)\n[![Coverage Status](https://coveralls.io/repos/github/mlibrary/canister/badge.svg?branch=master)](https://coveralls.io/github/mlibrary/canister?branch=master)\n[![API Docs](https://img.shields.io/badge/API_docs-rubydoc.info-blue.svg)](https://www.rubydoc.info/github/mlibrary/canister)\n\n## Summary\n\nCanister is a simple IoC container for ruby. It has no dependencies and provides only\nthe functionality you need. It does not monkey-patch ruby or pollute the global\nnamespace, and most importantly *it expects to be invisible to your domain classes.*\n\nIt provides:\n\n* Out-of-order declaration\n* Caching\n* Automatic dependency resolution\n* Automatic cache invalidation on re-registration\n\n## Why do I need this? Especially in ruby?\n\nCanister was created to make it easier to declare the setup for an application's\nproduction and test environments in a single place, without needing to know\nwhen exactly those objects were created.\n\n*Canister is not a replacement for\ndependency injection.* Rather, it is useful when you have designed your objects\nto have their dependencies injected.\n\nThe domain of your application is not concerned with the design\npatterns you use to implement it; therefore, the domain entities within in it should\nrepresent the domain, not the patterns.\nFor example, it would be a *mistake* to write all of your classes such that they\naccept a single parameter called `container`.  `Car.new(container)` is undesirable\nwhen what your application really calls for is `Car.new(make, model, year)`.\n\nFor more information on dependency injection and inversion of control containers in\nruby, please see\n[this excellent article](https://gist.github.com/malakai97/b1d3bdf6d80c6f99a875930981243f9d)\nby [Jim Weirich](https://en.wikipedia.org/wiki/Jim_Weirich) that both sums up the issue\nand was the inspiration for this gem.\n\n\n## Installation\n\nAdd it to your Gemfile and you're off to the races.\n\n## Usage\n\n```ruby\n# Basic usage\ncontainer = Canister.new\ncontainer.register(:foo) { \"foo\" }\ncontainer.register(:bar) {|c| c.foo + \"bar\" }\n\ncontainer.bar     #=\u003e \"foobar\"\ncontainer[:bar]   #=\u003e \"foobar\"\ncontainer[\"bar\"]  #=\u003e \"foobar\"\n\n# Dependencies can be declared in any order\ncontainer.register(:after) {|c| \"#{c.before} and after\" }\ncontainer.register(:before) { \"before\" }\ncontainer.after   #=\u003e \"before and after\"\n\n# Values are cached\ncontainer.register(:wait) { sleep 3; 27 }\ncontainer.wait\n  .\n  .\n  .\n  #=================\u003e 27\ncontainer.wait    #=\u003e 27\n\n# Caches are invalidated automatically\ncontainer.register(:foo) { \"oof\" }\ncontainer.bar     #=\u003e \"oofbar\"\n```\n\n## Contributing\n\nStandard rules apply.\n\n## Compatibility\n\nCanister has been tested on the following:\n\n* ruby \u003e= 2.3.x\n* ruby \u003e= 3.x\n* jruby 9.4.2.0 (3.1.0)\n\nAs Canister does not rely on any specific runtime environment other than\nthe ruby core, it is compatible with every ruby library and framework.\n\n## Authors\n\n* The author and maintainer is [Bryan Hockey](https://github.com/malakai97)\n* This project was inspired by\n  [this excellent article](https://gist.github.com/malakai97/b1d3bdf6d80c6f99a875930981243f9d)\n  by [Jim Weirich](https://en.wikipedia.org/wiki/Jim_Weirich). (We are not affiliated, so\n  don't blame him if this breaks.)\n\n## License\n\n    Copyright (c) 2018 The Regents of the University of Michigan.\n    All Rights Reserved.\n    Licensed according to the terms of the Revised BSD License.\n    See LICENSE.md for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlibrary%2Fcanister","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlibrary%2Fcanister","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlibrary%2Fcanister/lists"}