{"id":22445845,"url":"https://github.com/nxt-insurance/nxt_config","last_synced_at":"2025-08-01T20:31:14.858Z","repository":{"id":36938488,"uuid":"231796382","full_name":"nxt-insurance/nxt_config","owner":"nxt-insurance","description":"Simple configuration objects, loadable from YAML files","archived":false,"fork":false,"pushed_at":"2024-04-25T07:23:30.000Z","size":54,"stargazers_count":6,"open_issues_count":5,"forks_count":0,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-04-25T08:31:14.254Z","etag":null,"topics":["configuration","gem","ruby","yaml"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/nxt_config","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/nxt-insurance.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2020-01-04T16:46:54.000Z","updated_at":"2023-04-05T11:40:49.000Z","dependencies_parsed_at":"2024-02-07T10:51:58.049Z","dependency_job_id":"3d470fed-3454-4786-bef2-764e8ce597a1","html_url":"https://github.com/nxt-insurance/nxt_config","commit_stats":{"total_commits":32,"total_committers":4,"mean_commits":8.0,"dds":0.1875,"last_synced_commit":"e72ad23f5b1567597771348463a8f1ac9cbe6a16"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxt-insurance%2Fnxt_config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxt-insurance%2Fnxt_config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxt-insurance%2Fnxt_config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxt-insurance%2Fnxt_config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nxt-insurance","download_url":"https://codeload.github.com/nxt-insurance/nxt_config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228402239,"owners_count":17914230,"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":["configuration","gem","ruby","yaml"],"created_at":"2024-12-06T03:17:01.634Z","updated_at":"2024-12-06T03:17:02.264Z","avatar_url":"https://github.com/nxt-insurance.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/nxt-insurance/nxt_config.svg?style=svg)](https://circleci.com/gh/nxt-insurance/nxt_config) [![Depfu](https://badges.depfu.com/badges/55572b7950c22f7f472a0adbf81b2ea4/count.svg)](https://depfu.com/github/nxt-insurance/nxt_config?project_id=10455)\n\n# NxtConfig\n\nThis is a very simple tool to load YAML files into strict configuration structs, accessible through global constants. This is inspired by the famous [config](https://github.com/railsconfig/config) gem. The core features are:\n\n* Load the content of a YAML file as a configuration object\n* Strict attribute accessors\n* Infinite amount of YAML files/configuration objects loadable (not just one)\n* Configuration objects can be registered in a given namespace (especially useful when in use in ruby gems loaded by other applications) by calling `NxtConfig::load` in the namespace where the constant lives that its config struct is assigned to.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'nxt_config'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install nxt_config\n\n## Usage\n\nYou can create a configuration object using `NxtConfig.load` from YAML files or directly from a hash. \nIf you are in a rails application, you can do this in an initializer (e.g. `config/initializers/nxt_config.rb`).\n\n```ruby\nmodule MyRailsApp\n  ExternalApiConfig = NxtConfig.load Rails.root.join('config', 'external_api.yml.erb')\nend\n```\n\nOf course you can also load configuration structs everywhere else in the application. \nDepending on where you assign it to a constant, you can have many configuration structs available via constants namespaced all over your application, \nscoped to the context where you need them.\n\n```ruby\n# Use struct like method chaining to access nested data\nMyRailsApp::ExternalApiConfig.http.headers.user_agent\n# =\u003e \"MyRailsApp 1.0.0\"\n\n# The struct methods are strict, so they raise an error if the attribute does not exist\nMyRailsApp::ExternalApiConfig.non_existent_key\n# =\u003e raises NoMethodError\n\n# You can also use hash like #fetch calls with symbols (multiple ones, like with Hash#dig)\nMyRailsApp::ExternalApiConfig.fetch(:http, :headers, :user_agent)\n# =\u003e \"MyRailsApp 1.0.0\"\n\n# You can also use hash like #fetch calls with strings (multiple ones, like with Hash#dig)\nMyRailsApp::ExternalApiConfig.fetch(\"http\", \"headers\", \"user_agent\")\n# =\u003e \"MyRailsApp 1.0.0\"\n\nMyRailsApp::ExternalApiConfig.fetch(:http, :oh_no, :user_agent, \u0026Proc.new { 'Hy!' })\n# =\u003e \"Hy!\"\n\n# You can also pass a block to #fetch in case a key does not exist\n\n# If you don't walk through the struct until its leaves, you will get a sub struct\nMyRailsApp::ExternalApiConfig.http\n# =\u003e #\u003cNxtConfig::Struct:0x00007fe657467680 @hash={\"headers\"=\u003e#\u003cNxtConfig::Struct:0x00007fe657467518 @hash={\"user_agent\"=\u003e\"my cool app\", \"api_key\"=\u003e\"secret123\"}\u003e}\u003e\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\nRun `bin/guard` for [guard](https://github.com/guard/guard) to start watching for file changes and running the corresponding specs accordingly.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/nxt-insurance/nxt_config.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnxt-insurance%2Fnxt_config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnxt-insurance%2Fnxt_config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnxt-insurance%2Fnxt_config/lists"}