{"id":13483612,"url":"https://github.com/varvet/econfig","last_synced_at":"2025-11-11T19:07:34.374Z","repository":{"id":6257954,"uuid":"7490755","full_name":"varvet/econfig","owner":"varvet","description":"Flexible configuration for Ruby applications","archived":false,"fork":false,"pushed_at":"2021-04-15T20:32:56.000Z","size":59,"stargazers_count":66,"open_issues_count":0,"forks_count":13,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-10-07T16:45:29.356Z","etag":null,"topics":[],"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/varvet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-07T22:02:54.000Z","updated_at":"2025-05-13T04:10:16.000Z","dependencies_parsed_at":"2022-09-15T12:51:41.505Z","dependency_job_id":null,"html_url":"https://github.com/varvet/econfig","commit_stats":null,"previous_names":["elabs/econfig"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/varvet/econfig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varvet%2Feconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varvet%2Feconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varvet%2Feconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varvet%2Feconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/varvet","download_url":"https://codeload.github.com/varvet/econfig/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varvet%2Feconfig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283910574,"owners_count":26915212,"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-11-11T02:00:06.610Z","response_time":65,"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-07-31T17:01:13.306Z","updated_at":"2025-11-11T19:07:34.334Z","avatar_url":"https://github.com/varvet.png","language":"Ruby","readme":"# Econfig\n\nEconfig is a gem which allows you to easily configure your Ruby applications\nin a multitude of ways.\n\n## This project is not actively maintained!\n\nWe at Varvet are not currently using this gem and are not actively maintaining it. We will gratefully accept pull requests which fix bugs or update dependencies, but not functional changes. \n\n## Installation\n\nAdd this to your Gemfile:\n\n``` ruby\ngem \"econfig\"\n```\n\nIf you're using Rails, you'll want to require the Rails extension:\n\n``` ruby\ngem \"econfig\", require: \"econfig/rails\"\n```\n\n## Accessing config options\n\nExtend your main application module with the Econfig shortcut.\n\nIn Rails, you'll want to add this in `config/application.rb`:\n\n``` ruby\nmodule MyApp\n  extend Econfig::Shortcut\n\n  class Application \u003c Rails::Application\n    # …\n  end\nend\n```\n\nIn a modular Sinatra application, extend your controller class and copy its settings to Econfig in `app.rb`:\n``` ruby\nrequire 'sinatra'\nrequire 'econfig'\n\nclass MyApp \u003c Sinatra::Base\n  extend Econfig::Shortcut\n\n  Econfig.env = settings.environment.to_s\n  Econfig.root = settings.root\n\n  # …\nend\n```\n\nIn either case, you can now you can access configuration like this:\n\n``` ruby\nMyApp.config.aws_access_key_id\n```\n\nIf the key you accessed is not configured, Econfig will raise an error. To\naccess optional configuration, which can be nil, use brackets:\n\n``` ruby\nMyApp.config[:aws_access_key_id]\n```\n\nSometimes you might want to bypass the strictness requirement in econfig, for\nexample if you're running the application as part of a build process.  In that\ncase you can set the environment variable `ECONFIG_PERMISSIVE`, and econfig\nwill not raise errors on missing keys, instead returning `nil`.\n\n## Configuring options.\n\nYou can specify configuration through:\n\n1. ENV variables\n2. Redis\n3. Relational database\n4. YAML files\n5. OSX Keychain\n\nThis allows you to set up Econfig on most kinds of hosting solutions\n(EngineYard, Heroku, etc) without any additional effort, and to switch between\nthem easily.\n\n### ENV variables\n\nJust set an environment variable whose name is the name of the option being\naccessed uppercased.\n\nFor example:\n\n``` sh\nAWS_ACCESS_KEY_ID=xyz rails server\n```\n\nYou can now read it like this:\n\n``` ruby\nMyApp.config.aws_access_key_id # =\u003e \"xyz\"\n```\n\nThis is especially convenient for Heroku.\n\n### YAML\n\nAdd a yaml file to `config/app.yml`. This should have a similar layout to `config/database.yml`:\n\n``` yaml\ndevelopment:\n  aws_access_key_id: \"xyz\"\n  aws_secret_access_key: \"xyz\"\nproduction:\n  aws_access_key_id: \"xyz\"\n  aws_secret_access_key: \"xyz\"\n```\n\nEconfig also reads configuration from `config/secret.yml` which is the new\nstandard for secret configuration parameters in Rails 4.1.\n\n### Relational database\n\nThis needs to be explicitly enabled. In `config/application.rb` add this code:\n\n``` ruby\nrequire \"econfig/active_record\"\nEconfig.backends.insert_after :env, :db, Econfig::ActiveRecord.new\n```\n\nYou probably want environment variables to take precendence over configuration\nfrom ActiveRecord, hence the `insert_after`. If you'd rather have ActiveRecord\nconfiguration take precendence you can use this instead:\n\n``` ruby\nrequire \"econfig/active_record\"\nEconfig.backends.unshift :db, Econfig::ActiveRecord.new\n```\n\nYou will also need to create a migration to create the necessary database tables:\n\n``` sh\nrails generate econfig:migration\nrake db:migrate\n```\n\n### Redis\n\nThis needs to be explicitly enabled. In `config/application.rb` add this code:\n\n``` ruby\nrequire \"econfig/redis\"\nredis = Redis.new(:host =\u003e \"myredis.com\")\nEconfig.backends.insert_after :env, :redis, Econfig::Redis.new(redis)\n```\n\nIf you wish to namespace your keys in Redis, you can use [redis namespace](http://rubygems.org/gems/redis-namespace).\n\n### OSX Keychain\n\nFor the OSX keychain backend, see [econfig-keychain](https://github.com/elabs/econfig-keychain).\n\n## Setting values\n\nYou can set options by simply assigning them:\n\n``` ruby\nMyApp.config[:aws_access_key_id] = \"xyz\"\n```\n\nThis will set the value in the default write backend, which by default is\n`:memory`. This means that by default, configuration which is set like this is\nnot persisted in any way.\n\nIf you always want to assign values to a different backend, for example the\ndatabase backend, you can set the default write backend like this:\n\n``` ruby\nEconfig.default_write_backend = :db\n```\n\nYou can also explicitly supply the backend when setting a configuration value:\n\n``` ruby\nMyApp.config[:db, :aws_access_key_id] = \"xyz\"\n```\n\n## License\n\nMIT, see separate LICENSE.txt file\n","funding_links":[],"categories":["Configuration","Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarvet%2Feconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvarvet%2Feconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarvet%2Feconfig/lists"}