{"id":17091316,"url":"https://github.com/aaronlasseigne/tash","last_synced_at":"2025-10-11T23:32:53.885Z","repository":{"id":40266152,"uuid":"497476782","full_name":"AaronLasseigne/tash","owner":"AaronLasseigne","description":"A hash that allows for transformation of its keys.","archived":false,"fork":false,"pushed_at":"2022-12-30T22:44:35.000Z","size":93,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-09T23:08:06.040Z","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/AaronLasseigne.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-29T03:04:25.000Z","updated_at":"2022-07-23T18:41:05.000Z","dependencies_parsed_at":"2023-01-31T17:00:35.964Z","dependency_job_id":null,"html_url":"https://github.com/AaronLasseigne/tash","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/AaronLasseigne/tash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AaronLasseigne%2Ftash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AaronLasseigne%2Ftash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AaronLasseigne%2Ftash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AaronLasseigne%2Ftash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AaronLasseigne","download_url":"https://codeload.github.com/AaronLasseigne/tash/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AaronLasseigne%2Ftash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009394,"owners_count":26084580,"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-10-11T02:00:06.511Z","response_time":55,"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-14T13:58:14.439Z","updated_at":"2025-10-11T23:32:53.871Z","avatar_url":"https://github.com/AaronLasseigne.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Tash][]\n\nTash is a hash that allows for transformation of its keys.\nA transformation block is given to change the key.\nKeys can be looked up with any value that transforms into the same key.\nThis means a hash can be string/symbol insensitive, case insensitive, can convert camel case JSON keys to snake case Ruby keys, or anything else based on the block you provide.\n\n[![Version](https://img.shields.io/gem/v/tash.svg?style=flat-square)](https://rubygems.org/gems/tash)\n[![Test](https://img.shields.io/github/actions/workflow/status/AaronLasseigne/tash/test.yml?label=Test\u0026style=flat-square\u0026branch=main)](https://github.com/AaronLasseigne/tash/actions?query=workflow%3ATest)\n\n---\n\n## Installation\n\nAdd it to your Gemfile:\n\n``` rb\ngem 'tash', '~\u003e 1.0'\n```\n\nOr install it manually:\n\n``` sh\n$ gem install tash --version '~\u003e 1.0'\n```\n\nThis project uses [Semantic Versioning][].\nCheck out [GitHub releases][] for a detailed list of changes.\n\n## Usage\n\nLet's say that you wanted to have a hash where the keys are accessible as strings or symbols (i.e. `ActiveSupport::HashWithIndifferentAccess`).\n\n``` rb\nt = Tash[one: 1, two: 2, \u0026:to_s]\n# =\u003e {\"one\"=\u003e1, \"two\"=\u003e2}\n\nt[:one]\n# =\u003e 1\n\nt['one']\n# =\u003e 1\n\nt[:three] = 9 # oops\n# =\u003e 9\n\nt['three'] = 3\n# =\u003e 3\n\nt[:three]\n# =\u003e 3\n\nt['three']\n# =\u003e 3\n```\n\nLets say that you recieve a series of camel case JSON keys from an API call but want to access the information with Rubys typical snake case style and symbolized.\n\n``` rb\njson = { \"firstName\" =\u003e \"Adam\", \"lastName\" =\u003e \"DeCobray\" }\n\nt = Tash[json] do |key|\n  key\n    .to_s\n    .gsub(/(?\u003c!\\A)([A-Z])/, '_\\1')\n    .downcase\n    .to_sym\nend\n\nt[:first_name]\n# =\u003e \"Adam\"\n\nt['firstName']\n# =\u003e \"Adam\"\n```\n\nThis also works with pattern matching:\n\n``` rb\nt = Tash[ONE: 1, MORE: 200, \u0026:downcase]\n\ncase t\nin { One: 1, More: more }\n  more\nelse\n  nil\nend\n# =\u003e 200\n```\n\nTash implements `to_hash` for implicit hash conversion making it usable nearly everywhere you use a hash.\n\nTash has every instance method Hash has except for `transform_keys` and `transform_keys!`.\n\n[API Documentation][]\n\n## Contributing\n\nIf you want to contribute to Tash, please read [our contribution guidelines][].\nA [complete list of contributors][] is available on GitHub.\n\n## License\n\nTash is licensed under [the MIT License][].\n\n[Tash]: https://github.com/AaronLasseigne/tash\n[semantic versioning]: http://semver.org/spec/v2.0.0.html\n[GitHub releases]: https://github.com/AaronLasseigne/tash/releases\n[API Documentation]: http://rubydoc.info/github/AaronLasseigne/tash\n[our contribution guidelines]: CONTRIBUTING.md\n[complete list of contributors]: https://github.com/AaronLasseigne/tash/graphs/contributors\n[the mit license]: LICENSE.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronlasseigne%2Ftash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faaronlasseigne%2Ftash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronlasseigne%2Ftash/lists"}