{"id":17664442,"url":"https://github.com/tilfin/konfig-yaml-rb","last_synced_at":"2026-04-24T22:38:00.761Z","repository":{"id":56880407,"uuid":"121103274","full_name":"tilfin/konfig-yaml-rb","owner":"tilfin","description":"Loader of YAML configuration for each execution enviroments","archived":false,"fork":false,"pushed_at":"2018-03-16T12:36:08.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-27T00:12:19.657Z","etag":null,"topics":["config","configuration","ruby","settings","yaml"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tilfin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-11T08:39:37.000Z","updated_at":"2018-03-16T12:35:52.000Z","dependencies_parsed_at":"2022-08-21T00:20:23.616Z","dependency_job_id":null,"html_url":"https://github.com/tilfin/konfig-yaml-rb","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/tilfin/konfig-yaml-rb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilfin%2Fkonfig-yaml-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilfin%2Fkonfig-yaml-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilfin%2Fkonfig-yaml-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilfin%2Fkonfig-yaml-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tilfin","download_url":"https://codeload.github.com/tilfin/konfig-yaml-rb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tilfin%2Fkonfig-yaml-rb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32243790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","ruby","settings","yaml"],"created_at":"2024-10-23T20:05:26.753Z","updated_at":"2026-04-24T22:38:00.728Z","avatar_url":"https://github.com/tilfin.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# konfig-yaml for Ruby\n\n[![Gem Version](https://badge.fury.io/rb/konfig-yaml.svg)](https://badge.fury.io/rb/konfig-yaml)\n[![document](https://img.shields.io/badge/document-1.0.0-green.svg)](http://www.rubydoc.info/gems/konfig-yaml/)\n[![Build Status](https://travis-ci.org/tilfin/konfig-yaml-rb.svg?branch=master)](https://travis-ci.org/tilfin/konfig-yaml-rb)\n[![Code Climate](https://codeclimate.com/github/tilfin/konfig-yaml-rb/badges/gpa.svg)](https://codeclimate.com/github/tilfin/konfig-yaml-rb)\n[![Test Coverage](https://codeclimate.com/github/tilfin/konfig-yaml-rb/badges/coverage.svg)](https://codeclimate.com/github/tilfin/konfig-yaml-rb/coverage)\n\nThe loader of YAML configuration for each execution environments like [settingslogic](https://github.com/settingslogic/settingslogic).\n\n- Expand environment variables like bash (ex. `storage-${RUBY_ENV}`)\n    - If an environment variable is not set, it is to be emtpy string.\n    - If `${DB_USER:-user}` or `${DB_USER:user}` is defined, `user` is expanded unless DB_USER does not exists.\n- Deep merge the environment settings and default settings (except array items)\n- Support YAML Anchor `\u0026something` / Reference `\u003c\u003c: *something`\n- Ruby version of [konfig-yaml](https://github.com/tilfin/konfig-yaml)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'konfig-yaml'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install konfig-yaml\n\n## Usage\n\n### Load a configuration instance\n\n```ruby\nrequire 'konfig-yaml'\n\nconfig = KonfigYaml.new([name], [opts]);\n```\n\n* `name` specifys the name of `config/\u003cname\u003e.yml` ( default `app` )\n* `opts`\n  * `:path` config directory path resolved from the process current one ( default `config` )\n  * `:erb` whether expand ERB or not ( default `false` )\n  * `:env` Execution environment ( default **RUBY_ENV** value, **RAILS_ENV** value, **RACK_ENV** value, or `development` )\n\n### Load a configuration as Static class\n\n```ruby\nrequire 'konfig-yaml'\n\nKonfigYaml.setup do |config|\n  config.const_name = 'Config' # default is 'Settings'\nend\n\np Config.log.level\n```\n\n### Access the values\n\n#### by accessor method\n\n```ruby\nport = config.port\nlog_lv = config.log.level\n```\n\n#### by symbol key\n\n```ruby\nport = config[:port]\nlog_lv = config.log[:level]\n```\n\n#### by string key\n\n```ruby\nport = config['port']\nlog_lv = config['log'].level\n```\n\n### Dynamically change settings\n\nSupport only symbol or string key if adding new field\n\n```ruby\nconfig[:port] = 80\nconfig.log['level'] = 'fatal'\nconfig[:backend] = { host: 'cms.example.com', \"port\" =\u003e 7080 }\n\np config.port         # 80\np config.log.level    # \"fatal\"\np config.backend.host # \"cms.example.com\"\np config.backend.port # 7080\n```\n\n## Example\n\n### Setup\n\n#### config/app.yml\n\n```\ndefault:\n  port: 8080\n  log:\n    level: info\n  db:\n    name: ${BRAND:-normal}-app-${RUBY_ENV}\n    user: user\n    pass: pass\n\nproduction:\n  port: 1080\n  log:\n    level: error\n  db:\n    pass: Password\n```\n\n#### main.rb\n\n```\nrequire 'konfig-yaml'\n\nconfig = KonfigYaml.new\n\nputs config.port\nputs config.log.level\nputs config.db.user\nputs config[:db]['name']\nputs config['db'].password\n```\n\n### Run\n\n#### In development\n\n```\n$ RUBY_ENV=development ruby main.rb\n8080\ninfo\nnormal-app-development\nuser\npass\n```\n\n#### In production\n\n```\n$ RUBY_ENV=production BRAND=awesome ruby main.rb\n1080\nerror\nawesome-app-production\nuser\nPassword\n```\n\n## License\n\n  [MIT](LICENSE)\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/tilfin/konfig-yaml-rb.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftilfin%2Fkonfig-yaml-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftilfin%2Fkonfig-yaml-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftilfin%2Fkonfig-yaml-rb/lists"}