{"id":16068366,"url":"https://github.com/mssola/cconfig","last_synced_at":"2025-10-24T20:51:32.067Z","repository":{"id":47303226,"uuid":"99568923","full_name":"mssola/cconfig","owner":"mssola","description":"Container-aware configuration management gem","archived":false,"fork":false,"pushed_at":"2024-08-02T00:13:28.000Z","size":102,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-27T05:24:22.464Z","etag":null,"topics":["config","configuration-files","containers","environment-variables","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mssola.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-07T11:01:35.000Z","updated_at":"2023-01-13T08:22:54.000Z","dependencies_parsed_at":"2023-02-01T02:45:17.820Z","dependency_job_id":null,"html_url":"https://github.com/mssola/cconfig","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mssola%2Fcconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mssola%2Fcconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mssola%2Fcconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mssola%2Fcconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mssola","download_url":"https://codeload.github.com/mssola/cconfig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806032,"owners_count":20350773,"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","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-files","containers","environment-variables","ruby"],"created_at":"2024-10-09T06:20:54.912Z","updated_at":"2025-10-24T20:51:27.047Z","avatar_url":"https://github.com/mssola.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/mssola/cconfig/actions/workflows/ruby.yml\" title=\"CI status for the main branch\"\u003e\u003cimg src=\"https://github.com/mssola/cconfig/actions/workflows/ruby.yml/badge.svg?branch=main\" alt=\"Build Status for main branch\" /\u003e\u003c/a\u003e\n  \u003ca href=\"http://www.gnu.org/licenses/lgpl-3.0.txt\" rel=\"nofollow\"\u003e\u003cimg alt=\"License LGPL 3+\" src=\"https://img.shields.io/badge/license-LGPL_3-blue.svg\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nCConfig (Container Config) is a container-aware configuration management\ngem. This is useful for applications that want to keep a reference configuration\nand add modifications to it in two different ways:\n\n- An alternative configuration file that lists all the modifications.\n- A list of environment variables that follow a given naming policy.\n\n## Basic usage\n\nLet's assume that our application has a `config.yml` file that contains all the\npossible configurable values with their defaults:\n\n```yaml\noption:\n  enabled: true\n\nanother:\n  value: 5\n```\n\nThen, you will have the following (irb prompt):\n\n```\n\u003e\u003e require \"cconfig/cconfig\"\n\u003e\u003e cfg = ::CConfig::Config.new(default: \"config.yml\", local: \"\", prefix: \"\")\n\u003e\u003e obj = cfg.fetch\n\u003e\u003e puts obj\n=\u003e {\"option\"=\u003e{\"enabled\"=\u003etrue}, \"another\"=\u003e{\"value\"=\u003e5}}\n```\n\nMoreover, this gem also adds an `enabled?` method to this hash returned by\n`#fetch`. With this method, configurable values with an `enabled` boolean value\nwill have this shorthand available. For example:\n\n```\n\u003e\u003e obj.enabled?(\"option\")\n=\u003e true\n\u003e\u003e obj.enabled?(\"another\")\n=\u003e false\n```\n\nThis also works for embedded configurable options. From the above example, let's\nassume that we update the `config.yml` file with these contents:\n\n```yaml\noption:\n  enabled: true\n\n  embedded:\n    enabled: false\n\nanother:\n  value: 5\n```\n\nLet's also add an alternative configuration file with these contents:\n\n```yaml\noption:\n  embedded:\n    enabled: true\n```\n\nThen we have the following:\n\n```\n\u003e\u003e cfg = ::CConfig::Config.new(default: \"config.yml\", local: \"config-local.yml\", prefix: \"\")\n\u003e\u003e obj = cfg.fetch\n=\u003e {\"option\"=\u003e{\"enabled\"=\u003etrue, \"embedded\"=\u003e{\"enabled\"=\u003etrue}}, \"another\"=\u003e{\"value\"=\u003e5}}\n\u003e\u003e obj.enabled?(\"option.embedded\")\n=\u003e true\n```\n\nAs you can see, the contents from the `config-local.yml` file that are available\nin the `config.yml` have been overwritten.\n\nThat being said, mounting a volume for changing some default values inside of a\nDocker container is a bit of an overkill. So, instead you can use **environment\nvariables**. In the above example we can add an environment variable (shell prompt):\n\n```\n$ export APPLICATION_ANOTHER_VALUE=2\n```\n\nThen (irb prompt):\n\n```\n\u003e\u003e cfg = ::CConfig::Config.new(default: \"config.yml\", local: \"config-local.yml\", prefix: \"application\")\n\u003e\u003e cfg.fetch\n=\u003e {\"option\"=\u003e{\"enabled\"=\u003etrue, \"embedded\"=\u003e{\"enabled\"=\u003etrue}}, \"another\"=\u003e{\"value\"=\u003e2}}\n```\n\nMoreover, the environment variable value takes precedence over the\n`config-local.yml` file.\n\n## Ruby on Rails integration\n\nThis gem also provides a Railtie, so it can be better used inside of a Ruby on\nRails application.\n\nFirst of all, this Railtie will initialize a global constant named `APP_CONFIG`\nautomatically with the merged contents of the configuration files and\nenvironment variables. Some notes:\n\n- The *prefix* is taken from the Rails' application name. If you don't want\n  this, set the `CCONFIG_PREFIX` environment variable.\n- The file with the default values has to be located in `config/config.yml` from\n  your Ruby on Rails root directory. Moreover, the other file is located in\n  `config/config-local.yml`, but this can be changed by setting the\n  `#{prefix}_LOCAL_CONFIG_PATH` environment variable.\n\nLast but not least, this Railtie also offers a rake task called\n`cconfig:info`. This rake task prints to standard output the evaluated\nconfiguration.\n\nThis gem supports Ruby on Rails `5.x`, `6.x` and `7.x`.\n\n## Contributing\n\nRead the [CONTRIBUTING.md](./CONTRIBUTING.md) file.\n\n## [Changelog](https://pbs.twimg.com/media/DJDYCcLXcAA_eIo?format=jpg\u0026name=small)\n\nRead the [CHANGELOG.md](./CHANGELOG.md) file.\n\n## License\n\nThis project is based on work I did for the\n[Portus](https://github.com/SUSE/Portus) project. I've extracted my code into a\ngem so it can be also used for other projects that might be interested in this.\n\n```\nCopyright (C) 2017-2023 Miquel Sabaté Solà \u003cmsabate@suse.com\u003e\n\nCConfig is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nCConfig is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with CConfig.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmssola%2Fcconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmssola%2Fcconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmssola%2Fcconfig/lists"}