Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dependo

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependo

  • 0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Dependo

Dependo is a very simple Dependency Injection framework for Ruby. Some say you don't need dependency injection when you're using Ruby. Maybe they're right, but I've come across some places where I need it.

For example, in my apps using Sinatra and Sequel, I need to be able to log, using a single Logger instance, from both my Sinatra app and from within my Sequel models. I'm not about to pass that Logger around as a parameter anywhere, and I don't want to instantiate it in every class that needs to log.

So, injecting the Logger is the easiest, best solution.

Requirements/Installation

Dependo doesn't depend on anything. In test, it relies on rspec and either rcov (Ruby 1.8) or simplecov (Ruby 1.9).

Install the gem: gem install dependo-(version).gem

Running the tests:

rake spec

Building the gem:

rake gem:build

Install gem with Rake:

rake gem:install

Usage

Register

Dependo::Registry[:log] = Logger.new(STDOUT)

Include

This makes it easy to use your injected dependencies as instance methods:

class MyThing
    include Dependo::Mixin
end

thing = MyThing.new
thing.log.info "I'm logging!"

Extend

This makes it easy to use your injected dependencies as class methods:

class MyThing
    extend Dependo::Mixin
end

MyThing.log.info "I'm logging!"

##License

See the LICENSE file. Licensed under the Apache 2.0 License

FAQs

Package last updated on 13 Feb 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc