palkan / anyway_config

Configuration library for Ruby gems and applications
MIT License
778 stars 52 forks source link

Support environments in pure Ruby apps #94

Closed fargelus closed 2 years ago

fargelus commented 2 years ago

What is the purpose of this pull request?

Closes https://github.com/palkan/anyway_config/issues/87

What changes did you make? (overview)

Added environments to non-Rails apps.

  1. Add parameter current_environment to Anyway::Settings class. Provide default value for this, maybe ENV["RAILS_ENV"]?
  2. Change method Anyway::Loaders::YAML.call. Add method environmental? and fetch all values from Anyway::Settings.current_environment config file's section. Merge default values into resulting config keys.
  3. Add specs for environments in spec/loaders/yaml_spec.rb.
  4. Extend rbs signature for required, required_attributes class methods of Anyway::Config.
  5. Inside method validate_required_attributes! of Anyway::Config class check if current key has option env and this env matches Anyway::Settings.current_environment and then raise validation error when key value is missed.

Is there anything you'd like reviewers to focus on?

Time

Work time: 7 hours
Delivery date: 27.12.21

Checklist

fargelus commented 2 years ago

Strange errors occurs in ci rspec stage. I don't see them running test locally. @palkan could you look?

skryukov commented 2 years ago

@fargelus try running bundle exec rake or bundle exec rake spec:norails do you see the same output as from CI?

palkan commented 2 years ago

I don't see them running test locally

Try running everything with bundle exec rake (and take a look at the CI configs and Rakefile; we have different test configurations to test with different environments, e.g., Rails and No-Rails).

fargelus commented 2 years ago

@fargelus try running bundle exec rake or bundle exec rake spec:norails do you see the same output as from CI? Unfortunately yes(