{"id":26647243,"url":"https://github.com/offirmo/hash-deep-merge","last_synced_at":"2025-04-11T02:34:27.866Z","repository":{"id":1519987,"uuid":"1778850","full_name":"Offirmo/hash-deep-merge","owner":"Offirmo","description":"For Ruby / Ruby on Rails : Add the deep merge (or recursive merge) feature to class Hash.","archived":false,"fork":false,"pushed_at":"2011-05-23T10:52:00.000Z","size":99,"stargazers_count":17,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T23:51:37.540Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Offirmo.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-05-20T22:57:38.000Z","updated_at":"2023-10-24T00:54:17.000Z","dependencies_parsed_at":"2022-08-16T13:35:13.349Z","dependency_job_id":null,"html_url":"https://github.com/Offirmo/hash-deep-merge","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Offirmo%2Fhash-deep-merge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Offirmo%2Fhash-deep-merge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Offirmo%2Fhash-deep-merge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Offirmo%2Fhash-deep-merge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Offirmo","download_url":"https://codeload.github.com/Offirmo/hash-deep-merge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248329991,"owners_count":21085630,"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":[],"created_at":"2025-03-24T23:51:28.078Z","updated_at":"2025-04-11T02:34:27.846Z","avatar_url":"https://github.com/Offirmo.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= hash-deep-merge\n\n== Introduction\nThis little gem add a method to the Hash class, allowing to merge hashes containing other hashes. (This is known as \"deep merge\" or \"recursive merge\".)\n\nYou (may) already know the standard hash merge :\n   h1 = { 'a' =\u003e 1, 'b' =\u003e 2,  'c' =\u003e 3}\n   h2 = {           'b' =\u003e 33,           'd' =\u003e 42 }\n   h1.merge(h2)\n     -\u003e { 'a' =\u003e 1, 'b' =\u003e 33, 'c' =\u003e 3, 'd' =\u003e 42 }\n \nBut now, what if the hash contains other hashes ?\n   h1 = { :option1 =\u003e true, :option2 =\u003e false, :option_group1 =\u003e { :sub_option1 =\u003e 23, :sub_option2 =\u003e \"hey !\" } }\n   h2 = { :option2 =\u003e true,    :option3 =\u003e 27, :option_group1 =\u003e { :sub_option1 =\u003e 18 } }\ntraditional merge doesn't handle that... Here come deep_merge !\n   h1.deep_merge(h2)\n     -\u003e { :option1 =\u003e true, :option2 =\u003e true,  :option_group1 =\u003e { :sub_option1 =\u003e 18, :sub_option2 =\u003e \"hey !\" }, :option3 =\u003e 27 }\n\nOf course, a deep_merge! (note the !) is available, like merge!\n\nThis should be included in Ruby, but there are some discussions about extra features that prevent it from going forward, cf. http://www.misuse.org/science/2008/05/19/deep_merge-ruby-recursive-merging-for-hashes/\n\nThe version I give you is the simplest one, doing what you need 99% of the time.\n\nThere are plenty of code snippets for deep merge :\n* http://snippets.dzone.com/posts/show/4706\n* http://rexchung.com/2007/02/01/hash-recursive-merge-in-ruby/\n* https://gist.github.com/6391\n\nBut they were not packaged it into a gem. It's done now for your convenience (and mine).\n\nNOTE : I since found a gem containing a more powerful deep merge, able to not only merge hashes but arrays and strings as well with many options. You may want to look at it :\nhttps://github.com/peritor/deep_merge\n\n== Installation\n\nIf you use bundler, just throw that in your gemfile :\n  gem 'hash-deep-merge'\n\nYou may also install the gem manually :\n  gem install hash-deep-merge\n\nIsn't it so easy ?\n\n== Contributing to hash-deep-merge\n \n* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet\n* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it\n* Fork the project\n* Start a feature/bugfix branch\n* Commit and push until you are happy with your contribution\n* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.\n* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.\n\n== Copyright\n\nCopyright (c) 2011 Offirmo. See LICENSE.txt for\nfurther details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foffirmo%2Fhash-deep-merge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foffirmo%2Fhash-deep-merge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foffirmo%2Fhash-deep-merge/lists"}