glassy-kernel

Version, currently master branch1 version
  • master branchlatestOct 12, 2020

github.com/glassy-framework/glassy-kernel

DI (Dependency Injection) Container for the Glassy Framework

3 stars
2 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  glassy-kernel:
    github: glassy-framework/glassy-kernel
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.35.1
License
MIT
Author
Anderson Danilo

Dependencies

This version declares no dependencies.

README

glassy-kernel

CircleCI

DI (Dependency Injection) Container for the Glassy Framework, based in bundles.

Inspired by: phoopy

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      glassy-kernel:
        github: glassy-framework/glassy-kernel
  2. Run shards install

Usage

Create a dependency file, ex: config/services.yml

services:
  my_object:
    class: MyClass
    kwargs:
      logger: '@logger'
    tag:
      - my_tag_example
  
  logger:
    class: MyLogger

Implement these classes as you like. After that you can implement the container as below.

require "glassy-kernel"

class AppBundle < Glassy::Kernel::Bundle
  SERVICES_PATH = "#{__DIR__}/config/services.yml"
end

class AppKernel < Glassy::Kernel::Kernel
  register_bundles [
    AppBundle
  ]
end

kernel = AppKernel.new
kernel.container.my_object.say_hello

Development

Always run crystal spec to execute the tests

Contributing

  1. Fork it (https://github.com/glassy-framework/glassy-kernel/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors