{"id":13427990,"url":"https://github.com/rubyconfig/config","last_synced_at":"2025-11-11T18:31:05.632Z","repository":{"id":846346,"uuid":"572993","full_name":"rubyconfig/config","owner":"rubyconfig","description":"Easiest way to add multi-environment yaml settings to Rails, Sinatra, Padrino and other Ruby projects.","archived":false,"fork":false,"pushed_at":"2025-08-29T05:33:02.000Z","size":727,"stargazers_count":2153,"open_issues_count":23,"forks_count":233,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-10-02T22:08:07.986Z","etag":null,"topics":["config","configuration","configuration-management","environment-variables","environments","padrino","rails","ruby","ruby-on-rails","settings","sinatra"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubyconfig.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/funding.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["pkuczynski"],"open_collective":"rubyconfig"}},"created_at":"2010-03-21T20:03:30.000Z","updated_at":"2025-09-24T19:12:36.000Z","dependencies_parsed_at":"2023-10-15T16:53:09.985Z","dependency_job_id":"864a76d3-e0eb-4d31-b3b0-1bacc0a0957e","html_url":"https://github.com/rubyconfig/config","commit_stats":{"total_commits":509,"total_committers":101,"mean_commits":5.03960396039604,"dds":0.6620825147347741,"last_synced_commit":"25bc414a188cb05d2558d2e7f6035f6d9430b29c"},"previous_names":["railsconfig/rails_config","railsconfig/config","railsjedi/rails_config"],"tags_count":63,"template":false,"template_full_name":null,"purl":"pkg:github/rubyconfig/config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyconfig%2Fconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyconfig%2Fconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyconfig%2Fconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyconfig%2Fconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubyconfig","download_url":"https://codeload.github.com/rubyconfig/config/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyconfig%2Fconfig/sbom","scorecard":{"id":788949,"data":{"date":"2025-08-11","repo":{"name":"github.com/rubyconfig/config","commit":"5e192a5ede17f90f972131f976ea69f3473c8c92"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":6.5,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":10,"reason":"15 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/tests.yml:4","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":4,"reason":"Found 12/30 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":8,"reason":"branch protection is not maximal on development and all release branches","details":["Info: 'allow deletion' disabled on branch 'master'","Info: 'force pushes' disabled on branch 'master'","Warn: 'branch protection settings apply to administrators' is disabled on branch 'master'","Info: 'stale review dismissal' is required to merge on branch 'master'","Warn: required approving review count is 1 on branch 'master'","Warn: codeowners review is required - but no codeowners file found in repo","Info: 'last push approval' is required to merge on branch 'master'","Info: 'up-to-date branches' is required to merge on branch 'master'","Info: status check found to merge onto on branch 'master'","Info: PRs are required in order to make changes on branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":1,"reason":"SAST tool is not run on all commits -- score normalized to 1","details":["Warn: 3 commits out of 22 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/rubyconfig/config/tests.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/tests.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/rubyconfig/config/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/rubyconfig/config/tests.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/tests.yml:60: update your workflow using https://app.stepsecurity.io/secureworkflow/rubyconfig/config/tests.yml/master?enable=pin","Warn: containerImage not pinned by hash: spec/app/rails_7.1/Dockerfile:5","Warn: containerImage not pinned by hash: spec/app/rails_7.1/Dockerfile:18","Warn: containerImage not pinned by hash: spec/app/rails_7.1/Dockerfile:41","Warn: containerImage not pinned by hash: spec/app/rails_7.2/Dockerfile:9","Warn: containerImage not pinned by hash: spec/app/rails_7.2/Dockerfile:26","Warn: containerImage not pinned by hash: spec/app/rails_7.2/Dockerfile:52","Warn: containerImage not pinned by hash: spec/app/rails_8.0/Dockerfile:12","Warn: containerImage not pinned by hash: spec/app/rails_8.0/Dockerfile:29","Warn: containerImage not pinned by hash: spec/app/rails_8.0/Dockerfile:55","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   9 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}}]},"last_synced_at":"2025-08-23T06:54:38.153Z","repository_id":846346,"created_at":"2025-08-23T06:54:38.154Z","updated_at":"2025-08-23T06:54:38.154Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278517916,"owners_count":26000175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","configuration","configuration-management","environment-variables","environments","padrino","rails","ruby","ruby-on-rails","settings","sinatra"],"created_at":"2024-07-31T01:00:44.008Z","updated_at":"2025-10-08T17:18:50.275Z","avatar_url":"https://github.com/rubyconfig.png","language":"Ruby","readme":"# Config\n\n[![Version](https://img.shields.io/gem/v/config)](https://rubygems.org/gems/config)\n[![Downloads Total](https://img.shields.io/gem/dt/config)](https://rubygems.org/gems/config)\n[![Tests](https://github.com/rubyconfig/config/workflows/tests/badge.svg)](https://github.com/rubyconfig/config/actions?query=branch%3Amaster)\n[![Financial Contributors on Open Collective](https://opencollective.com/rubyconfig/all/badge.svg?label=backers)](https://opencollective.com/rubyconfig)\n\n## Summary\n\nConfig helps you easily manage environment specific settings in an easy and usable manner.\n\n## Features\n\n* simple YAML config files\n* config files support ERB\n* config files support inheritance and multiple environments\n* access config information via convenient object member notation\n* support for multi-level settings (`Settings.group.subgroup.setting`)\n* local developer settings ignored when committing the code\n\n## Compatibility\n\nCurrent version supports and is [tested](.github/workflows/tests.yml#L19) for the following interpreters and frameworks:\n\n* Interpreters\n  * [Ruby](https://www.ruby-lang.org) `\u003e= 2.6`\n  * [JRuby](https://www.jruby.org) `\u003e= 9.2`\n  * [TruffleRuby](https://github.com/oracle/truffleruby) `\u003e= 19.3`\n* Application frameworks\n  * Rails `\u003e= 5.2`\n  * Padrino\n  * Sinatra\n\nFor Ruby `2.0` to `2.3` or Rails `3` to `4.1` use version `1.x` of this gem. For older versions of Rails or Ruby use [AppConfig](http://github.com/fredwu/app_config).\n\nFor Ruby `2.4` or `2.5` or Rails `4.2`, `5.0`, or `5.1` use version `3.x` of this gem.\n\n## Installing\n\n### Installing on Rails\n\nAdd `gem 'config'` to your `Gemfile` and run `bundle install` to install it. Then run\n\n    rails g config:install\n\nwhich will generate customizable config file `config/initializers/config.rb` and set of default settings files:\n\n    config/settings.yml\n    config/settings.local.yml\n    config/settings/development.yml\n    config/settings/production.yml\n    config/settings/test.yml\n\nYou can now edit them to adjust to your needs.\n\n\u003e Note: By default, the config environment will match the Rails environment (`Rails.env`). This can be changed by setting `config.environment`.\n\n### Installing on Padrino\n\nAdd the gem to your `Gemfile` and run `bundle install` to install it. Then edit `app.rb` and register `Config`\n\n```ruby\nregister Config\n```\n\n### Installing on Sinatra\n\nAdd the gem to your `Gemfile` and run `bundle install` to install it. Afterwards in need to register `Config` in your app and give it a root so it can find the config files.\n\n```ruby\nset :root, File.dirname(__FILE__)\nregister Config\n```\n\n### Installing on other ruby projects\n\nAdd the gem to your `Gemfile` and run `bundle install` to install it. Then initialize `Config` manually within your configure block.\n\n```ruby\nConfig.load_and_set_settings(Config.setting_files(\"/path/to/config_root\", \"your_project_environment\"))\n```\n\nIt's also possible to initialize `Config` manually within your configure block if you want to just give it some yml paths to load from.\n\n```ruby\nConfig.load_and_set_settings(\"/path/to/yaml1\", \"/path/to/yaml2\", ...)\n```\n\n## Accessing the Settings object\n\nAfter installing the gem, `Settings` object will become available globally and by default will be compiled from the files listed below. Settings defined in files that are lower in the list override settings higher.\n\n    config/settings.yml\n    config/settings/#{environment}.yml\n    config/environments/#{environment}.yml\n\n    config/settings.local.yml\n    config/settings/#{environment}.local.yml\n    config/environments/#{environment}.local.yml\n\nEntries can be accessed via object member notation:\n\n```ruby\nSettings.my_config_entry\n```\n\nNested entries are supported:\n\n```ruby\nSettings.my_section.some_entry\n```\n\nAlternatively, you can also use the `[]` operator if you don't know which exact setting you need to access ahead of time.\n\n```ruby\n# All the following are equivalent to Settings.my_section.some_entry\nSettings.my_section[:some_entry]\nSettings.my_section['some_entry']\nSettings[:my_section][:some_entry]\n```\n\n### Reloading settings\n\nYou can reload the Settings object at any time by running `Settings.reload!`.\n\n### Reloading settings and config files\n\nYou can also reload the `Settings` object from different config files at runtime.\n\nFor example, in your tests if you want to test the production settings, you can:\n\n```ruby\nRails.env = \"production\"\nSettings.reload_from_files(\n  Rails.root.join(\"config\", \"settings.yml\").to_s,\n  Rails.root.join(\"config\", \"settings\", \"#{Rails.env}.yml\").to_s,\n  Rails.root.join(\"config\", \"environments\", \"#{Rails.env}.yml\").to_s\n)\n```\n\n### Environment specific config files\n\nYou can have environment specific config files. Environment specific config entries take precedence over common config entries.\n\nExample development environment config file:\n\n```ruby\n#{Rails.root}/config/environments/development.yml\n```\n\nExample production environment config file:\n\n```ruby\n#{Rails.root}/config/environments/production.yml\n```\n\n### Extra sources\n\nYou can load extra sources during initialization by setting the `extra_sources` configuration option.\n\n```ruby\nConfig.setup do |config|\n  config.extra_sources = [\n    'path/to/extra_source.yml',          # String: loads extra_source.yml\n    { api_key: ENV['API_KEY'] },         # Hash: direct hash source\n    MyCustomSource.new,                  # Object: custom source object that responds to `load`\n  ]\nend\n```\n\nThis will also overwrite the same config entries from the main file.\n\n### Developer specific config files\n\nIf you want to have local settings, specific to your machine or development environment, you can use the following files, which are automatically `.gitignore` :\n\n```ruby\nRails.root.join(\"config\", \"settings.local.yml\").to_s,\nRails.root.join(\"config\", \"settings\", \"#{Rails.env}.local.yml\").to_s,\nRails.root.join(\"config\", \"environments\", \"#{Rails.env}.local.yml\").to_s\n```\n\n**NOTE:** The file `settings.local.yml` will not be loaded in tests to prevent local configuration from causing flaky or non-deterministic tests. Environment-specific files (e.g. `settings/test.local.yml`) will still be loaded to allow test-specific credentials.\n\n### Adding sources at runtime\n\nYou can add new YAML config files at runtime. Just use:\n\n```ruby\nSettings.add_source!(\"/path/to/source.yml\")\nSettings.reload!\n```\n\nThis will use the given source.yml file and use its settings to overwrite any previous ones.\n\nOn the other hand, you can prepend a YML file to the list of configuration files:\n\n```ruby\nSettings.prepend_source!(\"/path/to/source.yml\")\nSettings.reload!\n```\n\nThis will do the same as `add_source`, but the given YML file will be loaded first (instead of last) and its settings will be overwritten by any other configuration file. This is especially useful if you want to define defaults.\n\nOne thing I like to do for my Rails projects is provide a local.yml config file that is .gitignored (so its independent per developer). Then I create a new initializer in `config/initializers/add_local_config.rb` with the contents\n\n```ruby\nSettings.add_source!(\"#{Rails.root}/config/settings/local.yml\")\nSettings.reload!\n```\n\n\u003e Note: this is an example usage, it is easier to just use the default local\n\u003e files `settings.local.yml`, `settings/#{Rails.env}.local.yml` and\n\u003e `environments/#{Rails.env}.local.yml` for your developer specific settings.\n\nYou also have the option to add a raw hash as a source. One use case might be storing settings in the database or in environment variables that overwrite what is in the YML files.\n\n```ruby\nSettings.add_source!({some_secret: ENV['some_secret']})\nSettings.reload!\n```\n\nYou may pass a hash to `prepend_source!` as well.\n\n## Embedded Ruby (ERB)\n\nEmbedded Ruby is allowed in the YAML configuration files. ERB will be evaluated at load time by default, and when the `evaluate_erb_in_yaml` configuration is set to `true`.\n\nConsider the two following config files.\n\n* ```#{Rails.root}/config/settings.yml```\n\n```yaml\nsize: 1\nserver: google.com\n```\n\n* ```#{Rails.root}/config/environments/development.yml```\n\n```yaml\nsize: 2\ncomputed: \u003c%= 1 + 2 + 3 %\u003e\nsection:\n  size: 3\n  servers: [ {name: yahoo.com}, {name: amazon.com} ]\n```\n\nNotice that the environment specific config entries overwrite the common entries.\n\n```ruby\nSettings.size   # =\u003e 2\nSettings.server # =\u003e google.com\n```\n\nNotice the embedded Ruby.\n\n```ruby\nSettings.computed # =\u003e 6\n```\n\nNotice that object member notation is maintained even in nested entries.\n\n```ruby\nSettings.section.size # =\u003e 3\n```\n\nNotice array notation and object member notation is maintained.\n\n```ruby\nSettings.section.servers[0].name # =\u003e yahoo.com\nSettings.section.servers[1].name # =\u003e amazon.com\n```\n\n## Configuration\n\nThere are multiple configuration options available, however you can customize `Config` only once, preferably during application initialization phase:\n\n```ruby\nConfig.setup do |config|\n  config.const_name = 'Settings'\n  # ...\nend\n```\n\nAfter installing `Config` in Rails, you will find automatically generated file that contains default configuration located at `config/initializers/config.rb`.\n\n### General\n\n* `const_name` - name of the object holding your settings. Default: `'Settings'`\n* `evaluate_erb_in_yaml` - evaluate ERB in YAML config files. Set to false if the config file contains ERB that should not be evaluated at load time. Default: `true`\n* `file_name` - name of the file to store general keys accessible in all environments. Default: `'settings'` - located at `config/settings.yml`\n* `dir_name` - name of the directory to store environment-specific files. Default: `'settings'` - located at `config/settings/`\n\n### Merge customization\n\n* `overwrite_arrays` - overwrite arrays found in previously loaded settings file. Default: `true`\n* `merge_hash_arrays` - merge hashes inside of arrays from previously loaded settings files. Makes sense only when `overwrite_arrays = false`. Default: `false`\n* `knockout_prefix` - ability to remove elements of the array set in earlier loaded settings file. Makes sense only when `overwrite_arrays = false`, otherwise array settings would be overwritten by default. Default: `nil`\n* `merge_nil_values` - `nil` values will overwrite an existing value when merging configs. Default: `true`.\n\n```ruby\n# merge_nil_values is true by default\nc = Config.load_files(\"./spec/fixtures/development.yml\") # =\u003e #\u003cConfig::Options size=2, ...\u003e\nc.size # =\u003e 2\nc.merge!(size: nil) =\u003e #\u003cConfig::Options size=nil, ...\u003e\nc.size # =\u003e nil\n```\n\n```ruby\n# To reject nil values when merging settings:\nConfig.setup do |config|\n  config.merge_nil_values = false\nend\n\nc = Config.load_files(\"./spec/fixtures/development.yml\") # =\u003e #\u003cConfig::Options size=2, ...\u003e\nc.size # =\u003e 2\nc.merge!(size: nil) =\u003e #\u003cConfig::Options size=nil, ...\u003e\nc.size # =\u003e 2\n```\n\nCheck [Deep Merge](https://github.com/danielsdeleo/deep_merge) for more details.\n\n### Validation\n\nWith Ruby 2.1 or newer, you can optionally define a [schema](https://github.com/dry-rb/dry-schema) or [contract](https://github.com/dry-rb/dry-validation) (added in `config-2.1`) using [dry-rb](https://github.com/dry-rb) to validate presence (and type) of specific config values. Generally speaking contracts allow to describe more complex validations with depencecies between fields.\n\nIf you provide either validation option (or both) it will automatically be used to validate your config. If validation fails it will raise a `Config::Validation::Error` containing information about all the mismatches between the schema and your config.\n\nBoth examples below demonstrates how to ensure that the configuration has an optional `email` and the `youtube` structure with the `api_key` field filled. The contract adds an additional rule.\n\n#### Contract\n\nLeverage dry-validation, you can create a contract with a params schema and rules:\n\n```ruby\nclass ConfigContract \u003c Dry::Validation::Contract\n  params do\n    optional(:email).maybe(:str?)\n\n    required(:youtube).schema do\n      required(:api_key).filled\n    end\n  end\n\n  rule(:email) do\n    unless /\\A[\\w+\\-.]+@[a-z\\d\\-]+(\\.[a-z\\d\\-]+)*\\.[a-z]+\\z/i.match?(value)\n      key.failure('has invalid format')\n    end\n  end\nend\n\nConfig.setup do |config|\n  config.validation_contract = ConfigContract.new\nend\n```\n\nThe above example adds a rule to ensure the `email` is valid by matching it against the provided regular expression.\n\nCheck [dry-validation](https://github.com/dry-rb/dry-validation) for more details.\n\n#### Schema\n\nYou may also specify a schema using [dry-schema](https://github.com/dry-rb/dry-schema):\n\n```ruby\nConfig.setup do |config|\n  # ...\n  config.schema do\n    optional(:email).maybe(:str?)\n\n    required(:youtube).schema do\n      required(:api_key).filled\n    end\n  end\nend\n```\n\nCheck [dry-schema](https://github.com/dry-rb/dry-schema) for more details.\n\n### Missing keys\n\nFor an example settings file:\n\n```yaml\nsize: 1\nserver: google.com\n```\n\nYou can test if a value was set for a given key using `key?` and its alias `has_key?`:\n\n```ruby\nSettings.key?(:path)\n# =\u003e false\nSettings.key?(:server)\n# =\u003e true\n```\n\nBy default, accessing to a missing key returns `nil`:\n\n```ruby\nSettings.key?(:path)\n# =\u003e false\nSettings.path\n# =\u003e nil\n```\n\nThis is not \"typo-safe\". To solve this problem, you can configure the `fail_on_missing` option:\n\n```ruby\nConfig.setup do |config|\n  config.fail_on_missing = true\n  # ...\nend\n```\n\nSo it will raise a `KeyError` when accessing a non-existing key (similar to `Hash#fetch` behaviour):\n\n```ruby\nSettings.path\n# =\u003e raises KeyError: key not found: :path\n```\n\n### Environment variables\n\nSee section below for more details.\n\n## Working with environment variables\n\nTo load environment variables from the `ENV` object, that will override any settings defined in files, set the `use_env` to true in your `config/initializers/config.rb` file:\n\n```ruby\nConfig.setup do |config|\n  config.const_name = 'Settings'\n  config.use_env = true\nend\n```\n\nNow config would read values from the ENV object to the settings. For the example above it would look for keys starting with `Settings`:\n\n```ruby\nENV['Settings.section.size'] = 1\nENV['Settings.section.server'] = 'google.com'\n```\n\nIt won't work with arrays, though.\n\nIt is considered an error to use environment variables to simultaneously assign a \"flat\" value and a multi-level value to a key.\n\n```ruby\n# Raises an error when settings are loaded\nENV['BACKEND_DATABASE'] = 'development'\nENV['BACKEND_DATABASE_USER'] = 'postgres'\n```\n\nInstead, specify keys of equal depth in the environment variable names:\n\n```ruby\nENV['BACKEND_DATABASE_NAME'] = 'development'\nENV['BACKEND_DATABASE_USER'] = 'postgres'\n```\n\n### Working with Heroku\n\nHeroku uses ENV object to store sensitive settings. You cannot upload such files to Heroku because it's ephemeral filesystem gets recreated from the git sources on each instance refresh. To use config with Heroku just set the `use_env` var to `true` as mentioned above.\n\nTo upload your local values to Heroku you could ran `bundle exec rake config:heroku`.\n\n### Fine-tuning\n\nYou can customize how environment variables are processed:\n\n* `env_prefix` (default: `const_name`) - load only ENV variables starting with this prefix (case-sensitive)\n* `env_separator` (default: `'.'`)  - what string to use as level separator - default value of `.` works well with   Heroku, but you might want to change it for example for `__` to easy override settings from command line, where using   dots in variable names might not be allowed (eg. Bash)\n* `env_converter` (default: `:downcase`)  - how to process variables names:\n  * `nil` - no change\n  * `:downcase` - convert to lower case\n* `env_parse_values` (default: `true`) - try to parse values to a correct type (`Boolean`, `Integer`, `Float`, `String`)\n\nFor instance, given the following environment:\n\n```bash\nSETTINGS__SECTION__SERVER_SIZE=1\nSETTINGS__SECTION__SERVER=google.com\nSETTINGS__SECTION__SSL_ENABLED=false\n```\n\nAnd the following configuration:\n\n```ruby\nConfig.setup do |config|\n  config.use_env = true\n  config.env_prefix = 'SETTINGS'\n  config.env_separator = '__'\n  config.env_converter = :downcase\n  config.env_parse_values = true\nend\n```\n\nThe following settings will be available:\n\n```ruby\nSettings.section.server_size # =\u003e 1\nSettings.section.server # =\u003e 'google.com'\nSettings.section.ssl_enabled # =\u003e false\n```\n\n### Working with AWS Secrets Manager\n\nIt is possible to parse variables stored in an AWS Secrets Manager Secret as if they were environment variables by using `Config::Sources::EnvSource`.\n\nFor example, the plaintext secret might look like this:\n\n```json\n{\n  \"Settings.foo\": \"hello\",\n  \"Settings.bar\": \"world\",\n}\n```\n\nIn order to load those settings, fetch the settings from AWS Secrets Manager, parse the plaintext as JSON, pass the resulting `Hash` into a new `EnvSource`, load the new source, and reload.\n\n```ruby\n# fetch secrets from AWS\nclient = Aws::SecretsManager::Client.new\nresponse = client.get_secret_value(secret_id: \"#{ENV['ENVIRONMENT']}/my_application\")\nsecrets = JSON.parse(response.secret_string)\n\n# load secrets into config\nsecret_source = Config::Sources::EnvSource.new(secrets)\nSettings.add_source!(secret_source)\nSettings.reload!\n```\n\nIn this case, the following settings will be available:\n\n```ruby\nSettings.foo # =\u003e \"hello\"\nSettings.bar # =\u003e \"world\"\n```\n\nBy default, `EnvSource` will use configuration for `env_prefix`, `env_separator`, `env_converter`, and `env_parse_values`, but any of these can be overridden in the constructor.\n\n```ruby\nsecret_source = Config::Sources::EnvSource.new(secrets,\n                                               prefix: 'MyConfig',\n                                               separator: '__',\n                                               converter: nil,\n                                               parse_values: false)\n```\n\n## Contributing\n\nYou are very warmly welcome to help. Please follow our [contribution guidelines](CONTRIBUTING.md)\n\nAny and all contributions offered in any form, past present or future are understood to be in complete agreement and acceptance with [MIT](LICENSE) license.\n\n### Running specs\n\nSetup\n\n```sh\nbundle install\nbundle exec appraisal install\n```\n\nList defined appraisals:\n\n```sh\nbundle exec appraisal list\n```\n\nRun specs for specific appraisal:\n\n```sh\nbundle exec appraisal rails-6.1 rspec\n```\n\nRun specs for all appraisals:\n\n```sh\nbundle exec appraisal rspec\n```\n\n## Authors\n\n* [Piotr Kuczynski](http://github.com/pkuczynski)\n* [Fred Wu](http://github.com/fredwu)\n* [Jacques Crocker](http://github.com/railsjedi)\n* Inherited from [AppConfig](http://github.com/cjbottaro/app_config) by [Christopher J. Bottaro](http://github.com/cjbottaro)\n\n## Contributors\n\n### Code Contributors\n\nThis project exists thanks to all the people who contribute and you are very warmly welcome to help. Please follow our [contribution guidelines](CONTRIBUTING.md).\n\nAny and all contributions offered in any form, past present or future are understood to be in complete agreement and acceptance with the [MIT](LICENSE) license.\n\n[![Contributors](https://opencollective.com/rubyconfig/contributors.svg?width=890\u0026button=false)](https://github.com/rubyconfig/config/graphs/contributors)\n\n### Financial Contributors\n\n[Become a backer](https://opencollective.com/rubyconfig#backer) and support us with a small monthly donation to help us continue our activities. Thank you if you already one! 🙏\n\n[![Backers](https://opencollective.com/rubyconfig/backers.svg?width=890)](https://opencollective.com/rubyconfig)\n\n#### Sponsors\n\nSupport this project by becoming a [sponsor](https://opencollective.com/rubyconfig#sponsor). Your logo will show up here with a link to your website.\n\n[![Sponsors](https://opencollective.com/rubyconfig/sponsors.svg?width=890)](https://opencollective.com/rubyconfig)\n\n## License\n\nCopyright (C) Piotr Kuczynski. Released under the [MIT License](LICENSE.md).\n","funding_links":["https://github.com/sponsors/pkuczynski","https://opencollective.com/rubyconfig"],"categories":["Environment Variables","Ruby","ruby"],"sub_categories":["Omniauth"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyconfig%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyconfig%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyconfig%2Fconfig/lists"}