Coder Social home page Coder Social logo

ambience's Introduction

ambience Build Status

App configuration using ENV for Crystal applications inspired by figaro.

Installation

Add this to your application's shard.yml:

dependencies:
  ambience:
    github: vjdhama/ambience
    version: 0.4.2

Usage

require "ambience"

Ambience.application("configuration_file_path", "environment")
Ambience.load

Refer example kemal application for more insight.

Example configuration file

api_url: example.com
development:
  app_id: foobar123
  app_key: barfoo123

production:
  app_id: bar123foo
  app_key: 123foobar

##TODO'S

  • Convenience Proxy Methods.
  • Required keys convenience method.
  • Cli for Ambience.
  • Add examples for frost.
  • Add examples for kemal.

Contributing

  1. Fork it ( https://github.com/vjdhama/ambience/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

  • vjdhama - Vijay Dhama : creator, maintainer

ambience's People

Contributors

achilles42 avatar vjdhama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ambience's Issues

Build is failing

Currently build is failing due to mocks dependency, which doesn't work well with crystal version >= 0.16.0.

Missing hash key: "development" (KeyError)

Hello! First of all thank you for this shard. I have spotted a strange behaviour.

This is my configuration file:

ENABLED_ENV_PATH: "asd"
DISABLED_ENV_PATH: "qwe"

This is the code loading it:

Ambience.application(path_to_file, "development")
Ambience.load

This code triggers a compile exception with this stracktrace:

[4582919] *CallStack::unwind:Array(Pointer(Void)) +87
[4582810] *CallStack#initialize<CallStack>:Array(Pointer(Void)) +10
[4582762] *CallStack::new:CallStack +42
[4745529] *KeyError +41
[4745465] *KeyError::new<String>:KeyError +105
[4782014] *Hash(YAML::Type, YAML::Type) +270
[4781734] *Hash(YAML::Type, YAML::Type) +6
[4758057] *Ambience::Application#environment_configuration<Ambience::Application>:(Hash(String, String) | Hash(YAML::Type, YAML::Type) | Nil) +1161
[4756863] *Ambience::Application#load<Ambience::Application>:(Hash(String, String) | Hash(YAML::Type, YAML::Type) | Nil) +47
[4756619] *Ambience::load:(Hash(String, String) | Hash(YAML::Type, YAML::Type) | Nil) +107
[4728188] *Env::Manager::load_envs:(Hash(String, String) | Hash(YAML::Type, YAML::Type) | Nil) +204
[4527122] ???
[4537545] main +41
[233773866693] __libc_start_main +245
[4487785] ???
[0] ???

I can fix this specifing the development in the configuration file like this:

ENABLED_ENV_PATH: "asd"
DISABLED_ENV_PATH: "qwe"

development:

Why is it needed? Am I missing something?
By the way, it happens also with the kemal example in this repo.

Thank you.

More information in README

Hi. It will be more informative if you show some config samples in README (and show that config should be YAML)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.