{"id":15405687,"url":"https://github.com/zverok/confucius","last_synced_at":"2026-05-01T21:33:31.290Z","repository":{"id":30560471,"uuid":"34115297","full_name":"zverok/confucius","owner":"zverok","description":"Simple framework-agnostic configuration for any Ruby app","archived":false,"fork":false,"pushed_at":"2015-04-17T12:48:18.000Z","size":132,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T19:05:30.865Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/zverok.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":"2015-04-17T12:26:31.000Z","updated_at":"2018-02-26T01:33:42.000Z","dependencies_parsed_at":"2022-08-17T19:45:22.088Z","dependency_job_id":null,"html_url":"https://github.com/zverok/confucius","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zverok/confucius","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Fconfucius","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Fconfucius/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Fconfucius/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Fconfucius/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zverok","download_url":"https://codeload.github.com/zverok/confucius/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Fconfucius/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32513700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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":[],"created_at":"2024-10-01T16:18:15.232Z","updated_at":"2026-05-01T21:33:31.263Z","avatar_url":"https://github.com/zverok.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# confucius\nSimple framework-agnostic configuration for any Ruby app.\n\nConfucius intends to provide dead simple, no dependencies, framework-agnostic\nlibrary for loading config files and storing settings. It wants to be\nsimple, minimal magic, maximal flexibility and usability thing.\n\nAs of version 0.0.1 (aka Not Relased Yet) it is just a small piece of code,\nextracted from other project.\n\n## Usage\n\nAssuming you have `config/myconfig.yml`:\n\n```yaml\ndb:\n  adapter: mysql2\n  database: mydb\n  user: ...\nlogs:\n  path: log\n  level: info\n```\n\nJust load config into any class or module you want:\n\n```ruby\nclass MyClass\n  extend Confucius\nend\n\nMyClass.from_yaml('config/something.yml')\n\n# And here you are:\n\nMyClass.settings.db\n# =\u003e {'adapter' =\u003e 'mysql', 'database' =\u003e 'mydb'}\n\nMyClass.settings.logs\n# =\u003e {'path' =\u003e 'log', 'level' =\u003e 'info'}\n```\n\nNB: Confucius is smart enough to check, if class it's extended with\nalread has `#settings` method, so, you potentiall can use it with, say,\nSinatra app and everything will work fine.\n\nBut what if you want not only load config, but initalize something with it,\nlike DB connections? Confucius already can help you:\n\n```ruby\nclass MyClass\n  extend Confucius\n\n  setup(:db){|config|\n    Sequel.connect(config)\n  }\nend\n\nMyClass.from_yaml('config/something.yml')\n\nMyClass.settings.db\n# =\u003e Sequel::Connection\n\nMyClass.settings.db_config\n# =\u003e {'adapter' =\u003e 'mysql', 'database' =\u003e 'mydb'}\n```\n\nNeat.\n\nAnd even more goodness:\n\n```ruby\nclass MyClass\n  extend Confucius\n\n  setup(:db){|config|\n    Sequel.connect(config)\n  }.then{|db|\n    # you can perform some after-connect operations with the object\n    Sequel::Model.database = db\n  }\nend\n```\n\nThat's all for now, everything else are dreams.\n\n## TODO\n\n* support for environments (`\"dev\", \"prod\"` and so on,\n  flexible like in sinatra-config)\n* load from multiple files at once\n* load not only from YAML\n* support for settings validation (required, optional, default settings)\n  * and therefore, support for sample config generation\n* check, if it really plays well with Sinatra, Grape, Thor and so on\n* tests, code cleanup, docs ...\n\nThe code is one day old (when I write it 2015/04/17), do not expect much.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzverok%2Fconfucius","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzverok%2Fconfucius","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzverok%2Fconfucius/lists"}