{"id":19446052,"url":"https://github.com/stitchfix/fittings","last_synced_at":"2025-08-22T08:10:14.941Z","repository":{"id":25243512,"uuid":"103539082","full_name":"stitchfix/fittings","owner":"stitchfix","description":"Fork of mc-settings, which is a “convenient way to manage ruby application settings/configuration across multiple environments”","archived":false,"fork":false,"pushed_at":"2025-06-03T14:22:52.000Z","size":445,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":79,"default_branch":"main","last_synced_at":"2025-07-27T17:24:56.657Z","etag":null,"topics":["gem","opensource","ruby"],"latest_commit_sha":null,"homepage":"https://stitchfix.github.io/fittings/","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/stitchfix.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-09-14T13:58:52.000Z","updated_at":"2025-06-03T14:22:52.000Z","dependencies_parsed_at":"2023-02-13T23:25:20.661Z","dependency_job_id":"db0ad012-4396-4db8-a911-d239a28407e1","html_url":"https://github.com/stitchfix/fittings","commit_stats":{"total_commits":139,"total_committers":26,"mean_commits":5.346153846153846,"dds":0.7122302158273381,"last_synced_commit":"0460d8528c28e43458d526a43a764d400ef73756"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/stitchfix/fittings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stitchfix%2Ffittings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stitchfix%2Ffittings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stitchfix%2Ffittings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stitchfix%2Ffittings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stitchfix","download_url":"https://codeload.github.com/stitchfix/fittings/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stitchfix%2Ffittings/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271606595,"owners_count":24788979,"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-08-22T02:00:08.480Z","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":["gem","opensource","ruby"],"created_at":"2024-11-10T16:12:42.532Z","updated_at":"2025-08-22T08:10:14.913Z","avatar_url":"https://github.com/stitchfix.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= fittings\n\nThis is a fork of ModCloth's mc-settings gem which has gone unmaintained and has deprecation warnings.  This modernizes that and will be maintained.\n\n== Install\n\nAdd to your +Gemfile+:\n\n    gem \"fittings\"\n\nFor Rails, create +config/settings/default.yml+ as well as +config/settings/environments/{development,testing,production}.yml+.\n\nThen, in +config/environment.rb+, before the call to +initialize!+:\n\n    Setting.load(path:  \"#{Rails.root}/config/settings\",\n                 files: [\"default.yml\", \"environments/#{Rails.env}.yml\"])\n\n=== Why is it +Setting+?\n\nThis is a fork of the mc-settings gem that is intended to be backwards-compatible.\n\n== Summary \n\nThis gem provides an easy and Capistrano-friendly way to manage application configuration across \nmultiple environments, such as development, QA, staging, production, etc.\n\nApplications typically rely on configuration settings, such as host names, URLs, usernames and many\nmore. Some change between environments, some do not.  This gem assumes that application configuration \nis represented by a Hash of arbitrary depth, and provides convenient and compact syntax to access the \nsettings through a singleton instance inside Setting class.\n\nConfiguration is stored in one or more YAML files with the top-level data structure being a Hash, \nwith keys being the names of individual settings. For example, consider the following sample \napplication configuration file:\n\n tax:\n   default: 0.0\n   california: 7.5\n states:\n   default: \n     - 'CA'\n     - 'WA'\n     - 'NY'\n   ship_to:\n     - 'CA'\n     - 'NY'\n math_pi: 3.14159526\n\nSetting Gem provides Setting.load(..) method to load configuration from files in a way that allows \nsome configuration files to override previously loaded values, and then offers a simple method API \nto access the values, for example Setting.tax(:california) or Setting.tax.  Supporting default values\nin 2nd, 3rd, .. - level hashes is one of the advantages of using this gem.\n\nBy loading configuration from YAML files, Setting gem is inherently compatible with Capistrano deployment \nmethodology, where a certain set of files may become \"activated\" by simply sym-linking them into \nthe appropriate settings folder.\n\nNote: using example above, \"1st level\" hash is the one with keys \"tax\", \"states\" and \"math_pi\".  \n2nd-level hash is, for example, the tax definition one, with keys \"default\" and \"california\".  \n\n== Usage in Code\n\nOnce configuration is initialized using Setting#load or Setting#reload methods (see below), they can be used in \ncode in the following way:\n\n* Setting.key_name is optimized to return default value if available instead of a Hash. \n* Setting.key_name(:sub_key_name) returns a value from the 2nd level hash.\n* Setting.key_name(:sub_key_name, :sub_sub_key_name) returns value from the 3rd level hash if available. The algorithm is recursive, so only the maximum method stack depth will limit the number of nested hash values you can access this way.\n* Special syntax Setting[:key_name], Setting[:key_name][:sub_key_name], etc also supported. This method, however, does not support default values (see below).\n\nMethod notation is recommended over square bracket notation for accessing single values. However, \nsquare bracket notation may be useful when you want to fetch the entire 2nd level hash that \nincludes the default value, instead of the default value itself.\n\nFor example, given the above YAML file, you can access the settings in your code as follows:\n\n  Setting.tax =\u003e 0.0\n  Setting.tax(:california) =\u003e 7.5\n  Setting.math_pi =\u003e 3.14159526\n  Setting[:math_pi] =\u003e 3.14159526\n  Setting.states =\u003e [ 'CA', 'WA', 'NY' ]\n  Setting.states['ship_to'] =\u003e [ 'CA', 'NY' ]\n\nMethod-calling notation allows passing an array of keys to fetch a value from a nested hash.  \nThis method also supports returning a default value, stored against the \"default\" key.\n\n  Setting.tax =\u003e 0.0\n\nSquare bracket syntax returns the actual nested hash, without any regard for the default value:\n\n  Setting[:tax] =\u003e { 'default' =\u003e 0.0, 'california' =\u003e 7.5 } \n\n== Loading Settings\n\nThe gem should be initialized in your environment.rb (if using Rails), or in any other\napplication initialization block.  Setting.load() method is provided for loading settings, and it\ncan be called only once in application lifecycle, or it will throw an exception.  If you need to reload\nsettings completely, you can use reload() method with similar arguments.\n\nConsider an example:\n\n  Setting.load(:path  =\u003e \"#{Rails.root}/config/settings\",\n               :files =\u003e [\"default.yml\", \"environments/#{Rails.env}.yml\"],\n               :local =\u003e true)\n\nThe argument is an options hash that configures which YAML files to load, in what order, and from where.\n\n* path specifies the \"root\" folder where settings files will be loaded from\n* files is an array that lists file names relative to the :path. In the example above, settings folder contains subfolder \"environments\" where Rails-specific environment files are located (such as \"development.yml\", \"staging.yml\", \"production.yml\", etc)\n* local can be optionally specified as a true value, and if specified Setting gem will load all *.yml files that live under the :path/local folder. \n\nBelow is list of YAML files loaded in order specified in the above example, assuming that \"development\" is\nthe Rails environment, and \"local\" folder exists with 3 additional YAML files in it:\n\n  config/settings/default.yml\n  config/settings/environments/development.yml\n  config/settings/local/authorize-net.yml\n  config/settings/local/paypal.yml\n  config/settings/local/other.yml\n\nEach YML file defines a ruby Hash.  During file loading, the hashes are merged, \nso that values loaded in early files may be overwritten by values in subsequent \nfiles. This is deliberate and by design: it allows you to create small \"override\" \nfiles for each environment, or even each machine you want to deploy to. Exactly \nhow you split your application settings in files is up to you.\n\n== Nested Hashes and Default Values\n\nMC Setting gem provides a convenient way to access nested values, including full \nsupport for the default values within nested hashes (as of 0.1.1).\n\nConsider the following nested hash example:\n\ndefault.yml:\n\n  services: \n    inventory:\n      url: http://ims.mycompany.com:3443/inventory_manager\n      name: Inventory Management\n    shipping:\n      url: http://ship.mycompany.com:3443/shipper\n      name: Shipping\n\n  Setting.load(:files =\u003e ['default.yml'], :path =\u003e ...)\n\n  Setting.services(:inventory)       =\u003e { :url =\u003e \"http://localhost:3443/inventory_manager\" :name =\u003e \"Inventory Management\"}\n  Setting.services(:inventory, :url) =\u003e \"http://localhost:3443/inventory_manager\"\n\nstaging.yml \n\nWe are changing URLs for services in staging.yml, so they work in the staging environment.  Service URLs have been updated\nto use localhost:\n\n  services: \n    inventory:\n      url: http://localhost:8009/inventory_manager\n    shipping:\n      url: http://localhost:8008/shipper\n\n\n  Setting.load(:files =\u003e ['default.yml', 'staging.yml'], :path =\u003e ...)\n\n  Setting.services(:inventory)       =\u003e { :url =\u003e \"http://localhost:8009/inventory_manager\" :name =\u003e \"Inventory Management\"}\n  Setting.services(:inventory, :url) =\u003e \"http://localhost:8008/inventory_manager\"\n\n== Capistrano Recommendations\n\nAssume the directory structure of your Rails application is as follows:\n\n  config/settings/default.yml\n  config/settings/environments/development.yml\n  config/settings/environments/staging.yml\n  config/settings/environments/production.yml\n  config/settings/local\n  config/settings/systems/reporting.yml\n  config/settings/systems/admin.yml\n\nNote that the \"local\" directory is empty, and that \"systems\" directory contains several YAML files that provide alternative \nconfiguration for a reporting server, and an admin server (both of which run in \"production\" rails environment).\n\nWhen deploying to the main production site, neither YAML files inside \"systems\" folder are activated or used.\n\nBut upon deployment to the admin server, Capistrano could symlink \"admin.yml\" from config/settings/local folder, so the Setting gem\nwould load these values. So for each Capistrano role, you can define which files need to be symlinked into local, thus creating\na very flexible configuration scheme that's easily managed by Capistrano.\n\n== Copyright\n\nCopyright 2010 (c) ModCloth Inc.\n\nAuthors: 2010 Edwin Cruz \u0026 Konstantin Gredeskoul\n\nSee LICENSE.txt for further details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstitchfix%2Ffittings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstitchfix%2Ffittings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstitchfix%2Ffittings/lists"}