{"id":15406758,"url":"https://github.com/dannyben/sting","last_synced_at":"2025-08-04T16:39:46.051Z","repository":{"id":32648306,"uuid":"138779979","full_name":"DannyBen/sting","owner":"DannyBen","description":"Minimal, lightweight, multi-YAML settings library","archived":false,"fork":false,"pushed_at":"2023-06-30T09:08:34.000Z","size":50,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T08:58:40.962Z","etag":null,"topics":["gem","ruby","settings","settings-management","yaml-configuration"],"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/DannyBen.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-26T18:51:44.000Z","updated_at":"2023-11-29T11:56:44.000Z","dependencies_parsed_at":"2024-10-19T12:43:31.735Z","dependency_job_id":null,"html_url":"https://github.com/DannyBen/sting","commit_stats":{"total_commits":50,"total_committers":1,"mean_commits":50.0,"dds":0.0,"last_synced_commit":"bac545e22a6e995f5ed9499864bdfd99fd313ebc"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fsting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fsting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fsting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fsting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DannyBen","download_url":"https://codeload.github.com/DannyBen/sting/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249389125,"owners_count":21262851,"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":["gem","ruby","settings","settings-management","yaml-configuration"],"created_at":"2024-10-01T16:25:15.227Z","updated_at":"2025-08-04T16:39:46.039Z","avatar_url":"https://github.com/DannyBen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sting - Minimal Settings Library\n\nSting is a minimal, lightweight, multi-YAML settings library.\n\n## Installation\n\n```shell\n$ gem install sting\n```\n\n\n## Features\n\n- [Aggressively minimalistic][1].\n- Settings are accessible through a globally available class.\n- Can be used either as a singleton class or as an instance.\n- Load and merge one or more YAML files or hashes.\n- Settings objects are standard ruby hashes, arrays and basic types.\n- Ability to update settings at runtime.\n- [Ability to extend](#extending-yaml-files) (import) other YAML files.\n- ERB code in the YAML files will be evaluated.\n\n\n## Nonfeatures\n\n- No dot notation access to nested values - Use `Settings.server['host']`  instead of `Settings.server.host`.\n- No special generators for Rails. \n  [Usage with rails is still trivial](#using-with-rails).\n\n\n## Usage\n\n### Using as a singleton class\n\n```ruby\nrequire 'sting'\n\n# If you want to use a different name than Sting (optional)\nSettings = Sting\n\n# Load some YAML files. If the provided filename does not end with '.yml' or \n# '.yaml', we will add '.yml' to it.\nSettings \u003c\u003c 'one'\nSettings \u003c\u003c 'two.yml'\n\n# Adding additional files can also be done with `#push`. These two are the \n# same.\nSettings \u003c\u003c 'one'\nSettings.push 'one'\n\n# Merge with another options hash\nSettings \u003c\u003c { port: 3000, host: 'localhost' }\n\n# Load all files from a directory\nSettings \u003c\u003c \"dir/that-contains/yamls\"\n\n# Load all files from a directory, recursively\nSettings \u003c\u003c \"dir/that-contains/yamls/**/*.yml\"\n\n# Access values\np Settings.host\np Settings['host']\np Settings[:host]\n\n# Access nested values\np Settings.server['host']\n\n# Access nested values safely (get nil if any of the keys does not exist)\np Settings[:server, :host]\np Settings[:server, :production, :host]\n\n# Get the hash of all values\np Settings.settings\n\n# Check if a key is defined\np Settings.has_key? :hello\n\n# Access value, but raise an exception if it does not exist\np Settings.host!\n\n# Access boolean values, or check if a key exists\np Settings.host?\n\n# Update a value (in memory only, not in file)\nSettings.port = 3000\n\n# Reset (erase) all values\nSettings.reset!\n```\n\n### Using as an instance\n\nAll the above operations are also available to instances of `Sting`.\n\n```ruby\nrequire 'sting'\n\n# Create an instance.\nconfig = Sting.new\n\n# Or, create an instance, and provide the first source file to it.\nconfig = Sting.new 'settings'\n\n# Load additional YAML files. \nconfig \u003c\u003c 'local_settings'\n```\n\n\n### Extending YAML files\n\nSting uses [ExtendedYAML][2], which means you can use the `extends` key to load\none or more YAML files into your loaded configuration files:\n\n```yaml\n# Extend a single file (extension is optional)\nextends: some-other-file.yml\n\n# Extend multiple files\nextends:\n- some-file\n- another-file\n```\n\n\n## Using with Rails\n\nYou can use this however you wish in Rails. This is the recommended \nimplementation:\n\nAdd sting to your Gemfile:\n\n```ruby\ngem 'sting'\n```\n\nCreate an initializer:\n\n```ruby\n# config/initializers/settings.rb\nSettings = Sting\nSettings \u003c\u003c \"#{Rails.root}/config/settings\"\nSettings \u003c\u003c \"#{Rails.root}/config/settings/#{Rails.env}\"\n```\n\nCreate four config files:\n\n- config/**settings**.yml\n- config/settings/**development**.yml\n- config/settings/**production**.yml\n- config/settings/**test**.yml\n\n\n[1]: https://github.com/DannyBen/sting/blob/master/lib/sting/sting_operations.rb\n[2]: https://github.com/DannyBen/extended_yaml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fsting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdannyben%2Fsting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fsting/lists"}