github.com/luckyframework/lucky_env

An environment variable manager

6 stars
19 dependents
License: MIT

Nothing has been indexed for 0.1.1 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  lucky_env:
    github: luckyframework/lucky_env
    version: ~> 0.1.1

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.1.1. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

LuckyEnv

Yet another environment variable manager. Read from a file like a .env

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  lucky_env:
    github: luckyframework/lucky_env
  1. Run shards install

Usage

Environment variable file

Create your "env" file. Name it whatever you want. Most common is .env.

The file is created with key/value pairs separated by =.

APP_NAME=my_app
LUCKY_ENV=development
DEV_PORT=3002
DB_NAME=${APP_NAME}_${LUCKY_ENV}

Crystal code

# This would normally go in your `src/shards.cr` file
require "lucky_env"

# Loads the ".env" file. Raises if it is missing
LuckyEnv.load(".env")

# Use `load?` if the file is optional. 
# This will not raise if the file is missing
LuckyEnv.load?(".env")

ENV["LUCKY_ENV"] == "development" # => true

# Returns whatever `ENV["LUCKY_ENV"]` is set to, or `"development"` if not set.
LuckyEnv.environment # => "development"

# Environment predicates
LuckyEnv.development? # => true
LuckyEnv.production? # => false
LuckyEnv.test? # => false

Development

Install shards shards install, and start making changes. Be sure to run ./bin/ameba, and the crystal formatter crystal tool format spec src.

Read through the issues for things you can work on. If you have an idea, feel free to open a new issue!

Contributing

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