Skip to content

Bhuvanesh-ROR/rails_env_helper

Repository files navigation

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.


About

Simplify working with environment variables in a Ruby on Rails application.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •