No release in over a year
Simplify working with environment variables in a Ruby on Rails application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

RailsEnvHelper Gem Documentation

RailsEnvHelper is a Ruby gem designed to simplify handling environment variables in Rails applications. It provides methods to load environment variables from a YAML configuration file and access them based on the current Rails environment.


Installation:

To install RailsEnvHelper, add it to your Gemfile:

ruby,

gem 'rails_env_helper'

Then, run the following command to install the gem:

base,

bundle install

Usage:

Initializing Environment Variables:

RailsEnvHelper provides a method to initialize environment variables from a YAML configuration file. Call the initialize_env_variables method and provide the path to your YAML file:

ruby,

RailsEnvHelper.initialize_env_variables('config/env_variables.yaml')

Accessing Environment Variables:

You can access environment variables using the get_env method:

ruby,

value = RailsEnvHelper.get_env('variable_name')

Example YAML Configuration:

Here's an example YAML configuration file (config/env_variables.yaml):

yaml,

development:
    variable_name: value_for_development
    database_host: localhost
    database_port: 5432

test:
    variable_name: value_for_test
    database_host: test-db.example.com
    database_port: 5433

production:
    variable_name: value_for_production
    database_host: prod-db.example.com
    database_port: 5434

Error Handling:

RailsEnvHelper handles various error scenarios gracefully, such as missing configuration files or invalid YAML syntax.


Running Tests:

To run the test suite, ensure you have RSpec installed. Then, execute the following command:

bash,

bundle exec rspec

Contributing:

Bug reports and pull requests are welcome on GitHub at https://github.com/Bhuvanesh-ROR/rails_env_helper.


License:

The gem is available as open source under the terms of the MIT License.