{"id":15590180,"url":"https://github.com/bkeepers/morphine","last_synced_at":"2025-04-14T19:34:19.991Z","repository":{"id":2515020,"uuid":"3490692","full_name":"bkeepers/morphine","owner":"bkeepers","description":"a lightweight dependency injection framework for Ruby","archived":false,"fork":false,"pushed_at":"2016-05-31T12:55:53.000Z","size":8,"stargazers_count":142,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T07:51:18.287Z","etag":null,"topics":[],"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/bkeepers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-20T04:04:06.000Z","updated_at":"2023-12-20T03:46:42.000Z","dependencies_parsed_at":"2022-07-21T11:29:16.441Z","dependency_job_id":null,"html_url":"https://github.com/bkeepers/morphine","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/bkeepers%2Fmorphine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkeepers%2Fmorphine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkeepers%2Fmorphine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkeepers%2Fmorphine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bkeepers","download_url":"https://codeload.github.com/bkeepers/morphine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248946439,"owners_count":21187504,"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-10-02T23:20:34.205Z","updated_at":"2025-04-14T19:34:19.941Z","avatar_url":"https://github.com/bkeepers.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Morphine\n\n**NOTE: I am in the process of extracting dependency injection features from [Gaug.es](http://get.gaug.es). Currently, the only feature of this library is memoization. I am not dumb or inexperienced. I'm just not done yet.**\n\nMorphine is a lightweight dependency injection framework for Ruby. It uses a simple Ruby DSL to ease the pain of wiring your dependencies together.\n\n## Usage\n\nCreate a container for your dependencies and include the `Morphine` module.\n\n```ruby\nclass Application\n  include Morphine\n\n  register :track_service do\n    KestrelTrackService.new(kestrel_client, config.tracking_queue)\n  end\n\n  register :track_processor do\n    KestrelTrackProcessor.new(blocking_kestrel_client, config.tracking_queue)\n  end\n\nprivate\n\n  register :kestrel_client do\n    c = config['kestrel'].dup\n    Kestrel::Client.new(c.delete('servers'), c.symbolize_keys)\n  end\n\n  register :blocking_kestrel_client do\n    Kestrel::Client::Blocking.new(kestrel_client)\n  end\nend\n```\n\nCreate an instance of your container, and use that to load your dependencies\n\n```ruby\n$app = Application.new\n\nget '/track.gif' do\n  $app.track_processor.record(params['h'])\nend\n```\n\n# But I don't need dependency injection in Ruby!\n\nMany [argue](http://weblog.jamisbuck.org/2008/11/9/legos-play-doh-and-programming) that you [don't](http://davybrion.com/blog/2010/10/why-you-dont-need-dependency-injection-in-ruby/) [need](http://fabiokung.com/2010/05/06/ruby-and-dependency-injection-in-a-dynamic-world/) dependency injection in dynamic languages like Ruby. What they are really saying is you don't need a complicated dependency injection framework, and *they're right*.\n\nThat's why Morphine is an extremely simple library.\n\n## Contributing\n\nIf you find what looks like a bug:\n\n1. Check the [GitHub issue tracker](http://github.com/bkeepers/morphine/issues/) to see if anyone else has reported issue.\n2. If you don't see anything, create an issue with information on how to reproduce it.\n\nIf you want to contribute an enhancement or a fix:\n\n1. Fork the project on GitHub.\n2. Make your changes with tests.\n3. Commit the changes without making changes to the Rakefile, Gemfile, gemspec, or any other files that aren't related to your enhancement or fix\n4. Send a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkeepers%2Fmorphine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbkeepers%2Fmorphine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkeepers%2Fmorphine/lists"}