0.0
No commit activity in last 3 years
No release in over 3 years
A Lita .env config loader.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 12
>= 0.9.2, ~> 0

Runtime

>= 2.1.1, ~> 2
>= 4.4.3, ~> 4
 Project Readme

Lita Dotenv Config Loader

Gem Version Dependency Status Code Climate Scrutinizer Code Quality Downloads Docs License

lita_dotenv is designed to allow storing an entire Lita bot config in an .env file including the following:

  • map environment variables to Lita config properties
  • coerce environment variable value types to Ruby types
  • load .env file if exists

The lita_config.rb file should be as simple as:

require 'lita_dotenv'

Lita.configure do |config|
  config = LitaDotenv.new(config).config
end

Installation

Add lita_dotenv to your Lita instance's Gemfile:

gem "lita_dotenv"

Configuration

.env

DotenvConfig uses a simple parser that follows the following rules for assigning ENV variable names to Lita paths:

  1. all paths begin with LITA_
  2. all paths are designed to match Lita configure paths
  3. optional type coercion is available by setting the type as a suffix:
  4. Symbol: __TYPESYM
  5. Boolean: __TYPEBOOL
  6. Integer: __TYPEINT
  7. JSON: __TYPEJSON
  8. JSON with symbole keys: __TYPEJSONSYM
  9. underscores are handled in paths by using camelCase starting with a lowercase letter where an underscore is inserted before each uppercase letter
LITA_ROBOT_NAME=Configbot          # config.robot.name = 'Configbot'
LITA_ROBOT_LOCALE__TYPESYM=en      # config.robot.locale = :en
LITA_ROBOT_logLevel__TYPESYM=info  # config.robot.log_level = :info

lita_config.rb

In the ideal case, the lita_config.rb file should be as simple as:

require 'lita_dotenv'

Lita.configure do |config|
  config = LitaDotenv.new(config).config
end

To Do

  • Map config hash key values, e.g. config.redis[:url]

Change Log

See CHANGELOG.md

Links

Project Repo

Lita

Contributing

  1. Fork it ( http://github.com/grokify/lita_dotenv/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 new Pull Request

License

Lita Dotenv Config Loader is available under the MIT license. See LICENSE.txt for details.

Lita Dotenv Config Loader © 2016 by John Wang