• Stars
    star
    143
  • Rank 248,684 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 12 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a lightweight dependency injection framework for Ruby

Morphine

NOTE: I am in the process of extracting dependency injection features from Gaug.es. Currently, the only feature of this library is memoization. I am not dumb or inexperienced. I'm just not done yet.

Morphine is a lightweight dependency injection framework for Ruby. It uses a simple Ruby DSL to ease the pain of wiring your dependencies together.

Usage

Create a container for your dependencies and include the Morphine module.

class Application
  include Morphine

  register :track_service do
    KestrelTrackService.new(kestrel_client, config.tracking_queue)
  end

  register :track_processor do
    KestrelTrackProcessor.new(blocking_kestrel_client, config.tracking_queue)
  end

private

  register :kestrel_client do
    c = config['kestrel'].dup
    Kestrel::Client.new(c.delete('servers'), c.symbolize_keys)
  end

  register :blocking_kestrel_client do
    Kestrel::Client::Blocking.new(kestrel_client)
  end
end

Create an instance of your container, and use that to load your dependencies

$app = Application.new

get '/track.gif' do
  $app.track_processor.record(params['h'])
end

But I don't need dependency injection in Ruby!

Many argue that you don't need 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.

That's why Morphine is an extremely simple library.

Contributing

If you find what looks like a bug:

  1. Check the GitHub issue tracker to see if anyone else has reported issue.
  2. If you don't see anything, create an issue with information on how to reproduce it.

If you want to contribute an enhancement or a fix:

  1. Fork the project on GitHub.
  2. Make your changes with tests.
  3. Commit the changes without making changes to the Rakefile, Gemfile, gemspec, or any other files that aren't related to your enhancement or fix
  4. Send a pull request.

More Repositories

1

dotenv

A Ruby gem to load environment variables from `.env`.
Ruby
6,388
star
2

gaskit

a git-backed issue tracker
JavaScript
908
star
3

qu

a Ruby library for queuing and processing background jobs.
Ruby
507
star
4

stop-trump

a list of public projects on GitHub resisting the Trump administration
264
star
5

github-notifications

A client for reading GitHub notifications
CoffeeScript
212
star
6

dotenv-deployment

Make dotenv more useful in other environments.
Ruby
97
star
7

strappydoo

bootstrap and run any project with the same command
Shell
75
star
8

github-app-example

JavaScript
69
star
9

OWNERS

a human and machine readable format that specifies who is responsible for maintaining a project
Ruby
66
star
10

workflow

GitHub workflow automation via .probot.js file in your repository.
JavaScript
45
star
11

adapter-git

Git adapter for adapter gem.
Ruby
42
star
12

chordpro

A ruby parser for the chordpro song file format.
Ruby
33
star
13

monologue

Sample application to demonstrate TDD and design patterns in JavaScript
JavaScript
24
star
14

chordbook

Chord sheets and tab for guitar and ukulele.
Ruby
23
star
15

parse-reminder

a node module to parse natural language reminders into who, what, and when
JavaScript
22
star
16

envy

a schema for your application's environment variables
Ruby
21
star
17

probot-owners

@mention maintainers in Pull Requests based on contents of the OWNERS file
JavaScript
20
star
18

spiderman

your friendly neighborhood web crawler
Ruby
17
star
19

annotation

Convert linter output into annotations for the GitHub Checks API
Go
10
star
20

sunspot_mongo_mapper

A Sunspot wrapper for MongoMapper.
Ruby
10
star
21

dashing-octostatus

GitHub Status widget for the dashing dashboard framework
CoffeeScript
9
star
22

update-dotenv

A NodeJS module to write updates to a .env file
JavaScript
9
star
23

lucid

JavaScript
8
star
24

soapbox

a desktop application for presenting HTML-based slideshows
CoffeeScript
8
star
25

webhook-proxy

JavaScript
8
star
26

chord-editor

Edit song sheets in ChordPro, Chord Sheet, and Ultimate Guitar formats
HTML
8
star
27

tower_defense

A Tower Defense-style game written in Ruby with Gosu
Ruby
7
star
28

hubot-websocket

A websocket adapter for Hubot
CoffeeScript
7
star
29

producingoss

Ruby
6
star
30

github-data

Interesting data about GitHub
5
star
31

dotfiles

Shell
5
star
32

bkeepers.github.io

CSS
5
star
33

talks

proposals, notes, and outlines for talks that I've written, submitted, or presented
4
star
34

retext-words

JavaScript
4
star
35

fsbo

Simple site to sell my house
JavaScript
4
star
36

state

a state machine for GitHub Issues and Pull Requests
JavaScript
4
star
37

atom

JavaScript
3
star
38

sanitize-whitelist

Ruby
3
star
39

posthtml-extend-issues-28

HTML
2
star
40

office

A place to talk with people about things.
2
star
41

git-history

article for .net Magazine
2
star
42

owners-node

JavaScript
2
star
43

readable.news

Social news made into a readable feed.
Vue
2
star
44

mikedeboer.github.io

Website to redirect node-github
HTML
1
star
45

svada

JavaScript
1
star
46

markdown-test

1
star
47

hypester

Ruby
1
star
48

g2kg-intrawebs

Sample site for g2kg class
Ruby
1
star
49

github-for-developers-7

1
star
50

python-actions

GitHub Actions for Python packaging and distribution
Dockerfile
1
star
51

hubot-commands

experiment with building a command interface into Hubot
JavaScript
1
star
52

mailmerge

Ruby
1
star
53

testing

C
1
star
54

heroku-buildpack-git-test

Shell
1
star
55

github-notifications-app

A native wrapper around https://notifications.githubapp.com
JavaScript
1
star
56

expect-promise

an extension to expect for testing promises
JavaScript
1
star