{"id":20904662,"url":"https://github.com/sage/hash_kit","last_synced_at":"2025-10-03T21:50:26.551Z","repository":{"id":56875964,"uuid":"61016847","full_name":"Sage/hash_kit","owner":"Sage","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-28T15:38:26.000Z","size":59,"stargazers_count":0,"open_issues_count":1,"forks_count":3,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-10-03T01:14:21.204Z","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/Sage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2016-06-13T07:39:35.000Z","updated_at":"2023-07-28T15:28:17.000Z","dependencies_parsed_at":"2024-11-18T13:30:32.092Z","dependency_job_id":null,"html_url":"https://github.com/Sage/hash_kit","commit_stats":{"total_commits":29,"total_committers":5,"mean_commits":5.8,"dds":"0.24137931034482762","last_synced_commit":"b46019965325c51df3f53985a8c22e15037d9b8c"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/Sage/hash_kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fhash_kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fhash_kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fhash_kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fhash_kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sage","download_url":"https://codeload.github.com/Sage/hash_kit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fhash_kit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278234029,"owners_count":25953075,"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-03T02:00:06.070Z","response_time":53,"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-11-18T13:18:25.469Z","updated_at":"2025-10-03T21:50:26.504Z","avatar_url":"https://github.com/Sage.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HashKit\n\n[![Build Status](https://travis-ci.org/Sage/hash_kit.svg?branch=master)](https://travis-ci.org/Sage/hash_kit)\n[![Maintainability](https://api.codeclimate.com/v1/badges/3ffb56b92ca96c783093/maintainability)](https://codeclimate.com/github/Sage/hash_kit/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/3ffb56b92ca96c783093/test_coverage)](https://codeclimate.com/github/Sage/hash_kit/test_coverage)\n[![Gem Version](https://badge.fury.io/rb/hash_kit.svg)](https://badge.fury.io/rb/hash_kit)\n\nWelcome to your HashKit! HashKit is a toolkit for working with Ruby Hashes.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'hash_kit'\n```\n\nAnd then execute:\n\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n\n```bash\n$ gem install hash_kit\n```\n\n## Usage\n\n\n#HashKit::Helper\n\nThis is class contains helper methods for working with Ruby hashes.\n\n## #indifferent!(hash)\n\nThis method is called to make a hash allow indifferent access to key values. Allowing a valid key to be accessed by either a string or symbol.\n```ruby\nhash = { 'key1' =\u003e 'value1', key2: 'value2' }\n\nhelper.indifferent!(hash)\n\nvalue1 = hash[:key1] #This will return 'value1'\nvalue2 = hash['key2'] #This will return 'value2'\n```\n\n## #symbolize\n\nThis method is called to convert all keys within a hash into symbols to allow consistent usage of hashes within your Ruby application.\n\n```ruby\nhash = helper.symbolize(hash)\n```\n\n## #stringify\n\nThis method is called to convert all keys within a hash into strings to allow consistent usage of hashes within your Ruby application.\n\n```ruby\nhash = helper.stringify(hash)\n```\n\n## #to_hash\n\nThis method is called to convert a object instance into a hash.\n\n```ruby\n    hash = helper.to_hash(obj)\n```\n\n## #from_hash\n\nThis method is called to convert a hash into an object.\n\n```ruby\n#class definition\n\nclass TestEntity\n  attr_accessor :text, :numeric, :time\nend\n```\n\n```ruby\nobj = helper.from_hash(hash, TestEntity)\n```\n\n\nAdditionally an array of HashKit::TransformItems can be specified to allow mapping from nested hashes into child entities, and nested arrays of hashes into nested arrays of entities.\n\nExample:\n\n```ruby\n#class definitions\n\nclass TestEntity\n  attr_accessor :text, :numeric, :time\nend\n\nclass ComplexEntity\n  attr_accessor :nested_entity, :nested_entity_array\nend\n```\n\n```ruby\n# transform method\n\n# transform item definitions\ntransform1 = HashKit::TransformItem.new.tap do |t|\n  t.key = :nested_entity\n  t.klass = TestEntity\nend\ntransform2 = HashKit::TransformItem.new.tap do |t|\n  t.key = :nested_entity_array\n  t.klass = TestEntity\nend\ntransforms = [transform1, transform2]\n\n# hash definition\nhash = {\n  nested_entity: { text: 'abc', numeric: 5 },\n  nested_entity_array: [\n    { text: 'abc', numeric: 5 },\n    { text: 'abc', numeric: 5 }\n  ]\n}\n\n#to hash call\nobj = helper.from_hash(hash, ComplexEntity, transforms)\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. 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\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/sage/hash_kit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThis gem is available as open source under the terms of the\n[MIT licence](LICENSE).\n\nCopyright (c) 2018 Sage Group Plc. All rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsage%2Fhash_kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsage%2Fhash_kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsage%2Fhash_kit/lists"}