Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/environment variables #435

Merged
merged 4 commits into from
Apr 21, 2023
Merged

Conversation

nicolasguridi
Copy link
Contributor

Context

Potassium-generated apps, like any other web app, rely on environment variables. Typically, these variables are accessed through class constants. However, this approach can lead to certain issues:

  1. In some cases, an environment variable may be relevant to a group of classes rather than a single one. In such cases, it can be challenging to determine where to define the constant, resulting in it being placed arbitrarily in a class.
  2. Since the constant's value is loaded when the class is defined, it can be difficult to mock it using RSpec.

What has been done

Summary:
A dedicated module for environment variables has been created. The benefits of this are:

  1. Centralized location: all environment variables and their constants are now located in a single module, eliminating the need to arbitrarily choose a class to define them in.
  2. Enhanced functionality: by using methods, it becomes possible to format or process environment variables as needed. This is a common requirement, given that environment variables are always strings.
  3. Improved testability: by using methods, the environment variables are evaluated at runtime. This makes it easier to mock the constants containing them during testing.

Commits:

  1. Added an environment variables module file to Potassium's assets
  2. Created a recipe for this new module, including tests
  3. Fixed some typos in the contributing guide
  4. Updated changelog

@nicolasguridi nicolasguridi merged commit 86869e8 into master Apr 21, 2023
@nicolasguridi nicolasguridi deleted the feat/environment-variables branch April 21, 2023 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants