Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package rubygem-hashie for openSUSE:Factory checked in at 2022-02-02 22:41:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-hashie (Old) and /work/SRC/openSUSE:Factory/.rubygem-hashie.new.1898 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-hashie" Wed Feb 2 22:41:25 2022 rev:24 rq:950630 version:5.0.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-hashie/rubygem-hashie.changes 2021-01-21 21:55:45.277810615 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-hashie.new.1898/rubygem-hashie.changes 2022-02-02 22:42:26.307115103 +0100 @@ -1,0 +2,7 @@ +Tue Jan 25 07:02:27 UTC 2022 - Stephan Kulow <co...@suse.com> + +updated to version 5.0.0 + see installed CHANGELOG.md + + +------------------------------------------------------------------- Old: ---- hashie-4.1.0.gem New: ---- hashie-5.0.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-hashie.spec ++++++ --- /var/tmp/diff_new_pack.p96oBq/_old 2022-02-02 22:42:26.827111579 +0100 +++ /var/tmp/diff_new_pack.p96oBq/_new 2022-02-02 22:42:26.831111552 +0100 @@ -1,7 +1,7 @@ # # spec file for package rubygem-hashie # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-hashie -Version: 4.1.0 +Version: 5.0.0 Release: 0 %define mod_name hashie %define mod_full_name %{mod_name}-%{version} ++++++ hashie-4.1.0.gem -> hashie-5.0.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2020-02-01 15:36:16.000000000 +0100 +++ new/CHANGELOG.md 2021-11-08 20:46:03.000000000 +0100 @@ -1,10 +1,43 @@ -# Change Log +# Changelog -All notable changes to this project will be documented in this file. This -project adheres to [Semantic Versioning 2.0.0][semver]. Any violations of this -scheme are considered to be bugs. +All notable changes to this project will be documented in this file. -[semver]: http://semver.org/spec/v2.0.0.html +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +Any violations of this scheme are considered to be bugs. + +## [5.0.0] - 2021-11-08 + +[5.0.0]: https://github.com/hashie/hashie/compare/v4.1.0...v5.0.0 + +### Added + +* [#523](https://github.com/hashie/hashie/pull/523): Added TOC, ensure a keep-a-changelog formatted CHANGELOG - [@dblock](https://github.com/dblock). +* [#522](https://github.com/hashie/hashie/pull/522): Added eierlegende Wollmilchsau mascot graphic - [@carolineartz](https://github.com/carolineartz). +* [#530](https://github.com/hashie/hashie/pull/530): Added Hashie::Extensions::Dash::PredefinedValues - [@caalberts](https://github.com/caalberts). +* [#536](https://github.com/hashie/hashie/pull/536): Added exporting a normal Hash from an indifferent one through the `#to_hash` method - [@michaelherold](https://github.com/michaelherold). +* [#539](https://github.com/hashie/hashie/pull/539): Run 2.7 tests once - [@anakinj](https://github.com/anakinj). + +### Changed + +* [#521](https://github.com/hashie/hashie/pull/499): Do not convert keys that cannot be represented as symbols to `String` in `Mash` initialization - [@carolineartz](https://github.com/carolineartz). +* [#524](https://github.com/hashie/hashie/pull/524): Test with Ruby 2.7 - [@aried3r](https://github.com/aried3r). +* [#525](https://github.com/hashie/hashie/pull/525): Use `indifferent_writer` in `IndifferentAccess#convert!` - [@yogeshjain999](https://github.com/yogeshjain999). +* [#527](https://github.com/hashie/hashie/pull/527): Updated Copyright to (c) 2009-2020 Intridea, Inc., and Contributors - [@dblock](https://github.com/dblock). +* [#555](https://github.com/hashie/hashie/pull/555): Test with Ruby 3.0 - [@dblock](https://github.com/dblock). + +### Removed + +* [#538](https://github.com/hashie/hashie/pull/538): Dropped testing for JRuby 9.0, though not support - [@michaelherold](https://github.com/michaelherold). + +### Fixed + +* [#516](https://github.com/hashie/hashie/issues/516): Fixed `NoMethodError` raised when including `Hashie::Extensions::Mash::SymbolizeKeys` and `Hashie::Extensions::SymbolizeKeys` in mashes/hashes with non string or symbol keys - [@carolineartz](https://github.com/carolineartz). +* [#531](https://github.com/hashie/hashie/pull/531): Fixed [slice doesn't work using symbols](https://github.com/hashie/hashie/issues/529) using hash with `IndifferentAccess` extension - [@gnomex](https://github.com/gnomex). +* [#533](https://github.com/hashie/hashie/pull/533): Fixed `NoMethodError: undefined method 'to_json'` at `hashie/dash_spec` - [@gnomex](https://github.com/gnomex). +* [#535](https://github.com/hashie/hashie/pull/535): Restored the exporting of all properties as part of `Dash#to_h` and `Dash#to_hash` - [@michaelherold](https://github.com/michaelherold). +* [#537](https://github.com/hashie/hashie/pull/537): Fixed inconsistencies with handling defaults in `Dash` with and without `IgnoreUnclared` mixed in - [@michaelherold](https://github.com/michaelherold). +* [#547](https://github.com/hashie/hashie/pull/547): Fixed issue where a source hash key can be used in translating multiple properties - [@danwa5](https://github.com/danwa5). ## [4.1.0] - 2020-02-01 @@ -12,8 +45,13 @@ ### Added +* [#545](https://github.com/hashie/hashie/pull/545): Add `Hashie::Mash#except` and `Hashie::Extensions::IndifferentAccess#except` when running under Ruby 3 to match newly added Ruby stdlib method - [@jackjennings](https://github.com/jackjennings). * [#499](https://github.com/hashie/hashie/pull/499): Add `Hashie::Extensions::Mash::PermissiveRespondTo` to make specific subclasses of Mash fully respond to messages for use with `SimpleDelegator` - [@michaelherold](https://github.com/michaelherold). +### Changed + +* [#498](https://github.com/hashie/hashie/pull/498): Exclude tests from the gem release to reduce installation size and improve installation speed - [@michaelherold](https://github.com/michaelherold). + ### Fixed * [#467](https://github.com/intridea/hashie/pull/467): Fixed `DeepMerge#deep_merge` mutating nested values within the receiver - [@michaelherold](https://github.com/michaelherold). @@ -27,11 +65,6 @@ * [#512](https://github.com/hashie/hashie/pull/512): Suppress an integer unification warning for using Ruby 2.4.0+ - [@koic](https://github.com/koic). * [#513](https://github.com/hashie/hashie/pull/513): Suppress a Ruby's warning when using Ruby 2.6.0+ - [@koic](https://github.com/koic). -### Miscellaneous - -* [#981](https://github.com/hashie/hashie/pull/981): Exclude tests from the gem release to reduce installation size and improve installation speed - [@michaelherold](https://github.com/michaelherold). -* Your contribution here. - ## [4.0.0] - 2019-10-30 [4.0.0]: https://github.com/hashie/hashie/compare/v3.6.0...v4.0.0 @@ -47,6 +80,7 @@ ### Changed * [#481](https://github.com/hashie/hashie/pull/481): Implement non-destructive standard Hash methods - [@bobbymcwho](https://github.com/bobbymcwho). +* [#482](https://github.com/hashie/hashie/pull/482): Update Travis configs to make jruby builds run on trusty dist - [@BobbyMcWho](https://github.com/BobbyMcWho). ### Fixed @@ -54,11 +88,7 @@ * [#465](https://github.com/hashie/hashie/pull/465): Fixed `deep_update` to call any readers when a key exists - [@laertispappas](https://github.com/laertispappas). * [#479](https://github.com/hashie/hashie/pull/479): Fixed an issue with `Hash#except` not returning a `Mash` in Rails 6 - [@bobbymcwho](https://github.com/bobbymcwho). * [#489](https://github.com/hashie/hashie/pull/489): Updated the documentation to exlain the behavior of `Mash` and keyword arguments - [@Bhacaz](https://github.com/Bhacaz). - -### Miscellaneous - * [#465](https://github.com/hashie/hashie/pull/465): Clean up our RuboCop configuration and fix the outstanding line length violations. This involved some minor refactoring on `Hashie::Extensions::Coercion`, `Hashie::Extensions::Dash::IndifferentAccess`, `Hashie::Extensions::DeepLocate`, `Hashie::Extensions::Mash::SafeAssignment`, and `Hashie::Hash`, but none that were detectable via the test suite - [@michaelherold](https://github.com/michaelherold). -* [#482](https://github.com/hashie/hashie/pull/482): Update Travis configs to make jruby builds run on trusty dist. - [@BobbyMcWho](https://github.com/BobbyMcWho). ## [3.6.0] - 2018-08-13 @@ -67,6 +97,12 @@ ### Added * [#455](https://github.com/hashie/hashie/pull/455): Allow overriding methods when passing in a hash - [@lnestor](https://github.com/lnestor). +* [#434](https://github.com/hashie/hashie/pull/434): Add documentation around Mash sub-Hashes - [@michaelherold](https://github.com/michaelherold). +* [#439](https://github.com/hashie/hashie/pull/439): Add an integration spec for Elasticsearch - [@michaelherold](https://github.com/michaelherold). + +### Changed + +* [#433](https://github.com/hashie/hashie/pull/433): Update Rubocop to the most recent version - [@michaelherold](https://github.com/michaelherold). ### Fixed @@ -76,21 +112,15 @@ * [#438](https://github.com/hashie/hashie/pull/438): Fix: `NameError (uninitialized constant Hashie::Extensions::Parsers::YamlErbParser::Pathname)` in `Hashie::Mash.load` - [@onk](https://github.com/onk). * [#457](https://github.com/hashie/hashie/pull/457): Fix `Trash` to allow it to copy properties from other properties - [@michaelherold](https://github.com/michaelherold). -### Miscellaneous - -* [#433](https://github.com/hashie/hashie/pull/433): Update Rubocop to the most recent version - [@michaelherold](https://github.com/michaelherold). -* [#434](https://github.com/hashie/hashie/pull/434): Add documentation around Mash sub-Hashes - [@michaelherold](https://github.com/michaelherold). -* [#439](https://github.com/hashie/hashie/pull/439): Add an integration spec for Elasticsearch - [@michaelherold](https://github.com/michaelherold). - ## [3.5.7] - 2017-12-19 [3.5.7]: https://github.com/hashie/hashie/compare/v3.5.6...v3.5.7 ### Fixed -[#430](https://github.com/hashie/hashie/pull/430): Fix Hashie::Rash randomly losing items - [@Antti](https://github.com/Antti) +* [#430](https://github.com/hashie/hashie/pull/430): Fix Hashie::Rash randomly losing items - [@Antti](https://github.com/Antti). -### Miscellaneous +### Changed * [#425](https://github.com/hashie/hashie/pull/425): Update rubies in CI - [@kachick](https://github.com/kachick). @@ -98,7 +128,7 @@ [3.5.6]: https://github.com/hashie/hashie/compare/v3.5.5...v3.5.6 -### Miscellaneous +### Fixed * [#416](https://github.com/hashie/hashie/pull/416): Fix `warning: instance variable @disable_warnings not initialized` - [@axfcampos](https://github.com/axfcampos). @@ -145,16 +175,13 @@ * [#395](https://github.com/hashie/hashie/pull/395): Add the ability to disable warnings in Mash subclasses - [@michaelherold](https://github.com/michaelherold). * [#400](https://github.com/hashie/hashie/pull/400): Fix Hashie.logger load and set the Hashie logger to the Rails logger in a Rails environment - [@michaelherold](https://github.com/michaelherold). +* [#397](https://github.com/hashie/hashie/pull/397): Add the integration specs harness into the main test tasks - [@michaelherold](https://github.com/michaelherold). ### Fixed * [#396](https://github.com/hashie/hashie/pull/396): Fix for specs in #381: Incorrect use of shared context meant example was not being run - [@biinari](https://github.com/biinari). * [#399](https://github.com/hashie/hashie/pull/399): Fix passing Pathname object to Hashie::Mesh.load() - [@albb0920](https://github.com/albb0920). -### Miscellanous - -* [#397](https://github.com/hashie/hashie/pull/397): Add the integration specs harness into the main test tasks - [@michaelherold](https://github.com/michaelherold). - ## [3.5.1] - 2017-01-31 * [#392](https://github.com/hashie/hashie/pull/392): Fix for #391: Require all dependencies of Hashie::Mash - [@dblock](https://github.com/dblock). @@ -183,10 +210,7 @@ * [#377](https://github.com/hashie/hashie/pull/377): Dont use Rubygems to check ruby version - [@sazor](https://github.com/sazor). * [#378](https://github.com/hashie/hashie/pull/378): Deep find all searches inside all nested hashes - [@sazor](https://github.com/sazor). * [#380](https://github.com/hashie/hashie/pull/380): Evaluate procs default values of Dash in object initialization - [@sazor](https://github.com/sazor). - -### Miscellanous - -* [#387](https://github.com/hashie/hashie/pull/387): Fix builds failing due to Rake 11 having a breaking change - [@michaelherold](https://github.com/michaelherold). +* [#387](https://github.com/hashie/hashie/pull/387): Fixed builds failing due to Rake 11 having a breaking change - [@michaelherold](https://github.com/michaelherold). ## [3.4.6] - 2016-09-16 @@ -203,6 +227,7 @@ ### Added * [#337](https://github.com/hashie/hashie/pull/337), [#331](https://github.com/hashie/hashie/issues/331): `Hashie::Mash#load` accepts a `Pathname` object - [@gipcompany](https://github.com/gipcompany). +* [#366](https://github.com/hashie/hashie/pull/366): Added Danger, PR linter - [@dblock](https://github.com/dblock). ### Deprecated @@ -213,10 +238,6 @@ * [#358](https://github.com/hashie/hashie/pull/358): Fixed support for Array#dig - [@modosc](https://github.com/modosc). * [#365](https://github.com/hashie/hashie/pull/365): Ensured ActiveSupport::HashWithIndifferentAccess is defined before use in #deep_locate - [@mikejarema](https://github.com/mikejarema). -### Miscellanous - -* [#366](https://github.com/hashie/hashie/pull/366): Added Danger, PR linter - [@dblock](https://github.com/dblock). - ## [3.4.4] - 2016-04-29 [3.4.4]: https://github.com/hashie/hashie/compare/v3.4.3...v3.4.4 @@ -248,7 +269,7 @@ * [#304](https://github.com/hashie/hashie/pull/304): Ensured compatibility of `Hash` extensions with singleton objects - [@regexident](https://github.com/regexident). * [#310](https://github.com/hashie/hashie/pull/310): Fixed `Hashie::Extensions::SafeAssignment` bug with private methods - [@marshall-lee](https://github.com/marshall-lee). -### Miscellaneous +### Changed * [#313](https://github.com/hashie/hashie/pull/313): Restrict pending spec to only Ruby versions 2.2.0-2.2.2 - [@pboling](https://github.com/pboling). * [#315](https://github.com/hashie/hashie/pull/315): Default `bin/` scripts: `console` and `setup` - [@pboling](https://github.com/pboling). @@ -383,8 +404,6 @@ [3.0.0]: https://github.com/hashie/hashie/compare/v2.1.2...v3.0.0 -Note: This version introduces several backward incompatible API changes. See [UPGRADING](UPGRADING.md) for details. - ### Added * [#149](https://github.com/hashie/hashie/issues/149): Allow IgnoreUndeclared and DeepMerge to be used with undeclared properties - [@jhaesus](https://github.com/jhaesus). @@ -429,6 +448,7 @@ ### Changed * [#89](https://github.com/hashie/hashie/issues/89): Do not respond to every method with suffix in Hashie::Mash, fixes Rails strong_parameters - [@Maxim-Filimonov](https://github.com/Maxim-Filimonov). +* Ruby style now enforced with Rubocop - [@dblock](https://github.com/dblock). ### Removed @@ -450,10 +470,6 @@ * [#130](https://github.com/hashie/hashie/pull/130): IndifferentAccess now works without MergeInitializer - [@npj](https://github.com/npj). * [#133](https://github.com/hashie/hashie/pull/133): Fixed Hash##to_hash with symbolize_keys - [@mhuggins](https://github.com/mhuggins). -### Miscellaneous - -* Ruby style now enforced with Rubocop - [@dblock](https://github.com/dblock). - ## [2.0.5] - 2013-05-10 [2.0.5]: https://github.com/hashie/hashie/compare/v2.0.4...v2.0.5 @@ -470,7 +486,7 @@ * [#94](https://github.com/hashie/hashie/pull/94): Made #fetch method consistent with normal Hash - [@markiz](https://github.com/markiz). -### Miscellaneous +### Changed * [#90](https://github.com/hashie/hashie/pull/90): Various doc tweaks - [@craiglittle](https://github.com/craiglittle). @@ -498,10 +514,7 @@ ### Removed * [#81](https://github.com/hashie/hashie/pull/81): Removed Mash#object_id override - [@matschaffer](https://github.com/matschaffer). - -### Miscellaneous - -* Gem cleanup: removed VERSION, Gemfile.lock - [@jch](https://github.com/jch), [@mbleigh](https://github.com/mbleigh). +* Removed VERSION and Gemfile.lock - [@jch](https://github.com/jch), [@mbleigh](https://github.com/mbleigh). ## [2.0.0] - 2013-02-16 @@ -511,6 +524,7 @@ * [#41](https://github.com/hashie/hashie/pull/41): DeepMerge extension - [@nashby](https://github.com/nashby). * [#78](https://github.com/hashie/hashie/pull/78): Merge and update accepts a block - [@jch](https://github.com/jch). +* [#72](https://github.com/hashie/hashie/pull/72): Updated gemspec with license info - [@jordimassaguerpla](https://github.com/jordimassaguerpla). ### Changed @@ -525,7 +539,3 @@ * [#62](https://github.com/hashie/hashie/pull/62): Updated respond_to? method signature to match ruby core definition - [@dlupu](https://github.com/dlupu). * [#63](https://github.com/hashie/hashie/pull/63): Dash defaults are dup'ed before assigned - [@ohrite](https://github.com/ohrite). * [#66](https://github.com/hashie/hashie/pull/66): Mash#fetch works with symbol or string keys - [@arthwood](https://github.com/arthwood). - -### Miscellaneous - -* [#72](https://github.com/hashie/hashie/pull/72): Updated gemspec with license info - [@jordimassaguerpla](https://github.com/jordimassaguerpla). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/LICENSE new/LICENSE --- old/LICENSE 2020-02-01 15:36:16.000000000 +0100 +++ new/LICENSE 2021-11-08 20:46:03.000000000 +0100 @@ -1,4 +1,4 @@ -Copyright (c) 2009 Intridea, Inc., and Contributors +Copyright (c) 2009-2020 Intridea, Inc., and Contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2020-02-01 15:36:16.000000000 +0100 +++ new/README.md 2021-11-08 20:46:03.000000000 +0100 @@ -2,11 +2,55 @@ [](https://gitter.im/hashie/hashie?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](http://badge.fury.io/rb/hashie) -[](https://travis-ci.org/hashie/hashie) -[](https://codeclimate.com/github/hashie/hashie/test_coverage) -[](https://codeclimate.com/github/hashie/hashie/maintainability) +[](https://github.com/hashie/hashie/actions/workflows/main.yml) -Hashie is a growing collection of tools that extend Hashes and make them more useful. +[](#mascot) Hashie is a growing collection of tools that extend Hashes and make them more useful. + +# Table of Contents + +- [Hashie](#hashie) +- [Table of Contents](#table-of-contents) + - [Installation](#installation) + - [Stable Release](#stable-release) + - [Hash Extensions](#hash-extensions) + - [Logging](#logging) + - [Coercion](#coercion) + - [Coercing Collections](#coercing-collections) + - [Coercing Hashes](#coercing-hashes) + - [Coercing Core Types](#coercing-core-types) + - [Coercion Proc](#coercion-proc) + - [A note on circular coercion](#a-note-on-circular-coercion) + - [KeyConversion](#keyconversion) + - [MergeInitializer](#mergeinitializer) + - [MethodAccess](#methodaccess) + - [MethodAccessWithOverride](#methodaccesswithoverride) + - [MethodOverridingInitializer](#methodoverridinginitializer) + - [IndifferentAccess](#indifferentaccess) + - [IgnoreUndeclared](#ignoreundeclared) + - [DeepMerge](#deepmerge) + - [DeepFetch](#deepfetch) + - [DeepFind](#deepfind) + - [DeepLocate](#deeplocate) + - [StrictKeyAccess](#strictkeyaccess) + - [Mash](#mash) + - [KeepOriginalKeys](#keeporiginalkeys) + - [PermissiveRespondTo](#permissiverespondto) + - [SafeAssignment](#safeassignment) + - [SymbolizeKeys](#symbolizekeys) + - [DefineAccessors](#defineaccessors) + - [Dash](#dash) + - [Potential Gotchas](#potential-gotchas) + - [PropertyTranslation](#propertytranslation) + - [Mash and Rails 4 Strong Parameters](#mash-and-rails-4-strong-parameters) + - [Coercion](#coercion-1) + - [PredefinedValues](#predefinedvalues) + - [Trash](#trash) + - [Clash](#clash) + - [Rash](#rash) + - [Auto-Optimized](#auto-optimized) + - [Mascot](#mascot) + - [Contributing](#contributing) + - [Copyright](#copyright) ## Installation @@ -18,7 +62,7 @@ ## Stable Release -You're reading the documentation for the stable release of Hashie, 4.1.0.(https://github.com/hashie/hashie/blob/v4.1.0/README.md). +You're reading the documentation for the stable release of Hashie, v5.0.0. ## Hash Extensions @@ -190,13 +234,13 @@ ### KeyConversion -The KeyConversion extension gives you the convenience methods of `symbolize_keys` and `stringify_keys` along with their bang counterparts. You can also include just stringify or just symbolize with `Hashie::Extensions::StringifyKeys` or [`Hashie::Extensions::SymbolizeKeys`](#mash-extension-symbolizekeys). +The KeyConversion extension gives you the convenience methods of `symbolize_keys` and `stringify_keys` along with their bang counterparts. You can also include just stringify or just symbolize with `Hashie::Extensions::StringifyKeys` or `Hashie::Extensions::SymbolizeKeys`. Hashie also has a utility method for converting keys on a Hash without a mixin: ```ruby -Hashie.symbolize_keys! hash # => Symbolizes keys of hash. -Hashie.symbolize_keys hash # => Returns a copy of hash with keys symbolized. +Hashie.symbolize_keys! hash # => Symbolizes all string keys of hash. +Hashie.symbolize_keys hash # => Returns a copy of hash with string keys symbolized. Hashie.stringify_keys! hash # => Stringifies keys of hash. Hashie.stringify_keys hash # => Returns a copy of hash with keys stringified. ``` @@ -269,8 +313,6 @@ In addition, IndifferentAccess will also inject itself into sub-hashes so they behave the same. -Example: - ```ruby class MyHash < Hash include Hashie::Extensions::MergeInitializer @@ -290,6 +332,18 @@ myhash['fishes']['food'] # => "flakes" ``` +To get back a normal, not-indifferent Hash, you can use `#to_hash` on the indifferent hash. It exports the keys as strings, not symbols: + +```ruby +myhash = MyHash.new +myhash["foo"] = "bar" +myhash[:foo] #=> "bar" + +normal_hash = myhash.to_hash +myhash["foo"] #=> "bar" +myhash[:foo] #=> nil +``` + ### IgnoreUndeclared This extension can be mixed in to silently ignore undeclared properties on initialization instead of raising an error. This is useful when using a Trash to capture a subset of a larger hash. @@ -445,8 +499,6 @@ This extension can be mixed in to allow a Hash to raise an error when attempting to extract a value using a non-existent key. -### Example: - ```ruby class StrictKeyAccessHash < Hash include Hashie::Extensions::StrictKeyAccess @@ -464,8 +516,6 @@ Mash is an extended Hash that gives simple pseudo-object functionality that can be built from hashes and easily extended. It is intended to give the user easier access to the objects within the Mash through a property-like syntax, while still retaining all Hash functionality. -### Example: - ```ruby mash = Hashie::Mash.new mash.name? # => false @@ -488,12 +538,10 @@ **Note:** The `?` method will return false if a key has been set to false or nil. In order to check if a key has been set at all, use the `mash.key?('some_key')` method instead. -### How does Mash handle conflicts with pre-existing methods? +_How does Mash handle conflicts with pre-existing methods?_ Please note that a Mash will not override methods through the use of the property-like syntax. This can lead to confusion if you expect to be able to access a Mash value through the property-like syntax for a key that conflicts with a method name. However, it protects users of your library from the unexpected behavior of those methods being overridden behind the scenes. -#### Example: - ```ruby mash = Hashie::Mash.new mash.name = "My Mash" @@ -564,12 +612,10 @@ Hashie::Mash.quiet(:zip).new(zip: '90210', compact: true) # error logged for compact ``` -### How does the wrapping of Mash sub-Hashes work? +_How does the wrapping of Mash sub-Hashes work?_ Mash duplicates any sub-Hashes that you add to it and wraps them in a Mash. This allows for infinite chaining of nested Hashes within a Mash without modifying the object(s) that are passed into the Mash. When you subclass Mash, the subclass wraps any sub-Hashes in its own class. This preserves any extensions that you mixed into the Mash subclass and allows them to work within the sub-Hashes, in addition to the main containing Mash. -#### Example: - ```ruby mash = Hashie::Mash.new(name: "Hashie", dependencies: { rake: "< 11", rspec: "~> 3.0" }) mash.dependencies.class #=> Hashie::Mash @@ -579,11 +625,20 @@ my_gem.dependencies.class #=> MyGem ``` -### What else can Mash do? +_How does Mash handle key types which cannot be symbolized?_ -Mash allows you also to transform any files into a Mash objects. +Mash preserves keys which cannot be converted *directly* to both a string and a symbol, such as numeric keys. Since Mash is conceived to provide psuedo-object functionality, handling keys which cannot represent a method call falls outside its scope of value. + +```ruby +Hashie::Mash.new('1' => 'one string', :'1' => 'one sym', 1 => 'one num') +# => {"1"=>"one sym", 1=>"one num"} +``` + +The symbol key `:'1'` is converted the string `'1'` to support indifferent access and consequently its value `'one sym'` will override the previously set `'one string'`. However, the subsequent key of `1` cannot directly convert to a symbol and therefore **not** converted to the string `'1'` that would otherwise override the previously set value of `'one sym'`. -#### Example: +_What else can Mash do?_ + +Mash allows you also to transform any files into a Mash objects. ```yml #/etc/config/settings/twitter.yml @@ -639,9 +694,9 @@ Mash.load('data/user.csv', permitted_classes: [Symbol], permitted_symbols: [], aliases: false) ``` -### Mash Extension: KeepOriginalKeys +### KeepOriginalKeys -This extension can be mixed into a Mash to keep the form of any keys passed directly into the Mash. By default, Mash converts keys to strings to give indifferent access. This extension still allows indifferent access, but keeps the form of the keys to eliminate confusion when you're not expecting the keys to change. +This extension can be mixed into a Mash to keep the form of any keys passed directly into the Mash. By default, Mash converts symbol keys to strings to give indifferent access. This extension still allows indifferent access, but keeps the form of the keys to eliminate confusion when you're not expecting the keys to change. ```ruby class KeepingMash < ::Hashie::Mash @@ -658,7 +713,7 @@ mash[:string_key] #=> 'string' ``` -### Mash Extension: PermissiveRespondTo +### PermissiveRespondTo By default, Mash only states that it responds to built-in methods, affixed methods (e.g. setters, underbangs, etc.), and keys that it currently contains. That means it won't state that it responds to a getter for an unset key, as in the following example: @@ -682,12 +737,10 @@ This comes at the cost of approximately 20% performance for initialization and setters and 19KB of permanent memory growth for each such class that you create. -### Mash Extension: SafeAssignment +### SafeAssignment This extension can be mixed into a Mash to guard the attempted overwriting of methods by property setters. When mixed in, the Mash will raise an `ArgumentError` if you attempt to write a property with the same name as an existing method. -#### Example: - ```ruby class SafeMash < ::Hashie::Mash include Hashie::Extensions::Mash::SafeAssignment @@ -698,9 +751,9 @@ safe_mash[:zip] = 'test' # => still ArgumentError ``` -### Mash Extension: SymbolizeKeys +### SymbolizeKeys -This extension can be mixed into a Mash to change the default behavior of converting keys to strings. After mixing this extension into a Mash, the Mash will convert all keys to symbols. It can be useful to use with keywords argument, which required symbol keys. +This extension can be mixed into a Mash to change the default behavior of converting keys to strings. After mixing this extension into a Mash, the Mash will convert all string keys to symbols. It can be useful to use with keywords argument, which required symbol keys. ```ruby class SymbolizedMash < ::Hashie::Mash @@ -731,7 +784,7 @@ However, on Rubies less than 2.0, this means that every key you send to the Mash will generate a symbol. Since symbols are not garbage-collected on older versions of Ruby, this can cause a slow memory leak when using a symbolized Mash with data generated from user input. -### Mash Extension: DefineAccessors +### DefineAccessors This extension can be mixed into a Mash so it makes it behave like `OpenStruct`. It reduces the overhead of `method_missing?` magic by lazily defining field accessors when they're requested. @@ -762,8 +815,6 @@ You can also conditionally require certain properties by passing a Proc or Symbol. If a Proc is provided, it will be run in the context of the Dash instance. If a Symbol is provided, the value returned for the property or method of the same name will be evaluated. The property will be required if the result of the conditional is truthy. -### Example: - ```ruby class Person < Hashie::Dash property :name, required: true @@ -800,8 +851,6 @@ Properties defined as symbols are not the same thing as properties defined as strings. -### Example: - ```ruby class Tricky < Hashie::Dash property :trick @@ -825,7 +874,28 @@ p.trick # => NoMethodError ``` -### Potential gotchas +If you would like to update a Dash and use any default values set in the case of a `nil` value, use `#update_attributes!`. + +```ruby +class WithDefaults < Hashie::Dash + property :description, default: 'none' +end + +dash = WithDefaults.new +dash.description #=> 'none' + +dash.description = 'You committed one of the classic blunders!' +dash.description #=> 'You committed one of the classic blunders!' + +dash.description = nil +dash.description #=> nil + +dash.description = 'Only slightly less known is ...' +dash.update_attributes!(description: nil) +dash.description #=> 'none' +``` + +### Potential Gotchas Because Dashes are subclasses of the built-in Ruby Hash class, the double-splat operator takes the Dash as-is without any conversion. This can lead to strange behavior when you use the double-splat operator on a Dash as the first part of a keyword list or built Hash. For example: @@ -857,13 +927,11 @@ qux[:quux] #=> "corge" ``` -### Dash Extension: PropertyTranslation +### PropertyTranslation The `Hashie::Extensions::Dash::PropertyTranslation` mixin extends a Dash with the ability to remap keys from a source hash. -### Example from inconsistent APIs - Property translation is useful when you need to read data from another application -- such as a Java API -- where the keys are named differently from Ruby conventions. @@ -883,8 +951,6 @@ person[:last_name] #=> 'Bleigh ``` -### Example using translation lambdas - You can also use a lambda to translate the value. This is particularly useful when you want to ensure the type of data you're wrapping. @@ -905,7 +971,7 @@ To enable compatibility with Rails 4 use the [hashie-forbidden_attributes](https://github.com/Maxim-Filimonov/hashie-forbidden_attributes) gem. -### Dash Extension: Coercion. +### Coercion If you want to use `Hashie::Extensions::Coercion` together with `Dash` then you may probably want to use `Hashie::Extensions::Dash::Coercion` instead. @@ -935,6 +1001,20 @@ end ``` +### PredefinedValues + +The `Hashie::Extensions::Dash::PredefinedValues` mixin extends a Dash with +the ability to accept predefined values on a property. + +```ruby +class UserHash < Hashie::Dash + include Hashie::Extensions::Dash::PredefinedValues + + property :gender, values: %i[male female prefer_not_to_say] + property :age, values: (0..150) +end +``` + ## Trash A Trash is a Dash that allows you to translate keys on initialization. It mixes @@ -976,8 +1056,6 @@ Essentially, a Clash is a generalized way to provide much of the same kind of "chainability" that libraries like Arel or Rails 2.x's named_scopes provide. -### Example: - ```ruby c = Hashie::Clash.new c.where(abc: 'def').order(:created_at) @@ -1003,8 +1081,6 @@ If the Rash's value is a `proc`, the `proc` will be automatically called with the regexp's MatchData (matched groups) as a block argument. -### Example: - ```ruby # Mapping names to appropriate greetings @@ -1021,18 +1097,21 @@ mapper["Get off my lawn!"] # => "Forget your lawn, old man!" ``` -### Auto-optimized +### Auto-Optimized **Note:** The Rash is automatically optimized every 500 accesses (which means that it sorts the list of Regexps, putting the most frequently matched ones at the beginning). If this value is too low or too high for your needs, you can tune it by setting: `rash.optimize_every = n`. +## Mascot +[](https://en.wiktionary.org/wiki/eierlegende_Wollmilchsau) Meet Hashie's "offical" mascot, the [eierlegende Wollmilchsau](https://en.wiktionary.org/wiki/eierlegende_Wollmilchsau)! + ## Contributing See [CONTRIBUTING.md](CONTRIBUTING.md) ## Copyright -Copyright (c) 2009-2014 Intridea, Inc. (http://intridea.com/) and [contributors](https://github.com/hashie/hashie/graphs/contributors). +Copyright (c) 2009-2020 [Intridea, Inc.](http://intridea.com), and [contributors](https://github.com/hashie/hashie/graphs/contributors). MIT License. See [LICENSE](LICENSE) for details. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/UPGRADING.md new/UPGRADING.md --- old/UPGRADING.md 2020-02-01 15:36:16.000000000 +0100 +++ new/UPGRADING.md 2021-11-08 20:46:03.000000000 +0100 @@ -1,6 +1,44 @@ Upgrading Hashie ================ +### Upgrading to 5.0.0 + +#### Mash initialization key conversion + +Mash initialization now only converts to string keys which can be represented as symbols. + +```ruby +Hashie::Mash.new( + {foo: "bar"} => "baz", + "1" => "one string", + :"1" => "one sym", + 1 => "one num" +) + +# Before +{"{:foo=>\"bar\"}"=>"baz", "1"=>"one num"} + +# After +{{:foo=>"bar"}=>"baz", "1"=>"one sym", 1=>"one num"} +``` + +#### Mash#dig with numeric keys + +`Hashie::Mash#dig` no longer considers numeric keys for indifferent access. + +```ruby +my_mash = Hashie::Mash.new("1" => "a") # => {"1"=>"a"} + +my_mash.dig("1") # => "a" +my_mash.dig(:"1") # => "a" + +# Before +my_mash.dig(1) # => "a" + +# After +my_mash.dig(1) # => nil +``` + ### Upgrading to 4.0.0 #### Non-destructive Hash methods called on Mash Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/dash.rb new/lib/hashie/dash.rb --- old/lib/hashie/dash.rb 2020-02-01 15:36:16.000000000 +0100 +++ new/lib/hashie/dash.rb 2021-11-08 20:46:03.000000000 +0100 @@ -104,19 +104,6 @@ def initialize(attributes = {}, &block) super(&block) - self.class.defaults.each_pair do |prop, value| - self[prop] = begin - val = value.dup - if val.is_a?(Proc) - val.arity == 1 ? val.call(self) : val.call - else - val - end - rescue TypeError - value - end - end - initialize_attributes(attributes) assert_required_attributes_set! end @@ -169,17 +156,30 @@ self end + def to_h + defaults = ::Hash[self.class.properties.map { |prop| [prop, self.class.defaults[prop]] }] + + defaults.merge(self) + end + alias to_hash to_h + def update_attributes!(attributes) update_attributes(attributes) self.class.defaults.each_pair do |prop, value| - next unless self[prop].nil? + next unless fetch(prop, nil).nil? self[prop] = begin - value.dup + val = value.dup + if val.is_a?(Proc) + val.arity == 1 ? val.call(self) : val.call + else + val + end rescue TypeError value end end + assert_required_attributes_set! end @@ -189,7 +189,7 @@ return unless attributes cleaned_attributes = attributes.reject { |_attr, value| value.nil? } - update_attributes(cleaned_attributes) + update_attributes!(cleaned_attributes) end def update_attributes(attributes) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/extensions/dash/indifferent_access.rb new/lib/hashie/extensions/dash/indifferent_access.rb --- old/lib/hashie/extensions/dash/indifferent_access.rb 2020-02-01 15:36:16.000000000 +0100 +++ new/lib/hashie/extensions/dash/indifferent_access.rb 2021-11-08 20:46:03.000000000 +0100 @@ -19,6 +19,15 @@ end private_class_method :requires_class_methods? + def to_h + defaults = ::Hash[self.class.properties.map do |prop| + [Hashie::Extensions::IndifferentAccess.convert_key(prop), self.class.defaults[prop]] + end] + + defaults.merge(self) + end + alias to_hash to_h + module ClassMethods # Check to see if the specified property has already been # defined. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/extensions/dash/predefined_values.rb new/lib/hashie/extensions/dash/predefined_values.rb --- old/lib/hashie/extensions/dash/predefined_values.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hashie/extensions/dash/predefined_values.rb 2021-11-08 20:46:03.000000000 +0100 @@ -0,0 +1,88 @@ +module Hashie + module Extensions + module Dash + # Extends a Dash with the ability to accept only predefined values on a property. + # + # == Example + # + # class PersonHash < Hashie::Dash + # include Hashie::Extensions::Dash::PredefinedValues + # + # property :gender, values: [:male, :female, :prefer_not_to_say] + # property :age, values: (0..150) # a Range + # end + # + # person = PersonHash.new(gender: :male, age: -1) + # # => ArgumentError: The value '-1' is not accepted for property 'age' + module PredefinedValues + def self.included(base) + base.instance_variable_set(:@values_for_properties, {}) + base.extend(ClassMethods) + base.include(InstanceMethods) + end + + module ClassMethods + attr_reader :values_for_properties + + def inherited(klass) + super + klass.instance_variable_set(:@values_for_properties, values_for_properties.dup) + end + + def property(property_name, options = {}) + super + + return unless (predefined_values = options[:values]) + + assert_predefined_values!(predefined_values) + set_predefined_values(property_name, predefined_values) + end + + private + + def assert_predefined_values!(predefined_values) + return if supported_type?(predefined_values) + + raise ArgumentError, %(`values` accepts an Array or a Range.) + end + + def supported_type?(predefined_values) + [::Array, ::Range].any? { |klass| predefined_values.is_a?(klass) } + end + + def set_predefined_values(property_name, predefined_values) + @values_for_properties[property_name] = predefined_values + end + end + + module InstanceMethods + def initialize(*) + super + + assert_property_values! + end + + private + + def assert_property_values! + self.class.values_for_properties.each_key do |property| + value = send(property) + + if value && !values_for_properties(property).include?(value) + fail_property_value_error!(property) + end + end + end + + def fail_property_value_error!(property) + raise ArgumentError, "Invalid value for property '#{property}'" + end + + def values_for_properties(property) + self.class.values_for_properties[property] + end + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/extensions/dash/property_translation.rb new/lib/hashie/extensions/dash/property_translation.rb --- old/lib/hashie/extensions/dash/property_translation.rb 2020-02-01 15:36:16.000000000 +0100 +++ new/lib/hashie/extensions/dash/property_translation.rb 2021-11-08 20:46:03.000000000 +0100 @@ -153,7 +153,12 @@ def []=(property, value) if self.class.translation_exists? property send("#{property}=", value) - super(property, value) if self.class.properties.include?(property) + + if self.class.transformation_exists? property + super property, self.class.transformed_property(property, value) + elsif self.class.properties.include?(property) + super(property, value) + end elsif self.class.transformation_exists? property super property, self.class.transformed_property(property, value) elsif property_exists? property diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/extensions/ignore_undeclared.rb new/lib/hashie/extensions/ignore_undeclared.rb --- old/lib/hashie/extensions/ignore_undeclared.rb 2020-02-01 15:36:16.000000000 +0100 +++ new/lib/hashie/extensions/ignore_undeclared.rb 2021-11-08 20:46:03.000000000 +0100 @@ -31,12 +31,11 @@ module IgnoreUndeclared def initialize_attributes(attributes) return unless attributes + klass = self.class - translations = klass.respond_to?(:translations) && klass.translations - attributes.each_pair do |att, value| - next unless klass.property?(att) || (translations && translations.include?(att)) - self[att] = value - end + translations = klass.respond_to?(:translations) && klass.translations || [] + + super(attributes.select { |attr, _| klass.property?(attr) || translations.include?(attr) }) end def property_exists?(property) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/extensions/indifferent_access.rb new/lib/hashie/extensions/indifferent_access.rb --- old/lib/hashie/extensions/indifferent_access.rb 2020-02-01 15:36:16.000000000 +0100 +++ new/lib/hashie/extensions/indifferent_access.rb 2021-11-08 20:46:03.000000000 +0100 @@ -23,6 +23,13 @@ # h['baz'] # => 'blip' # module IndifferentAccess + include Hashie::Extensions::RubyVersionCheck + + # @api private + def self.convert_key(key) + key.to_s + end + def self.included(base) Hashie::Extensions::Dash::IndifferentAccess.maybe_extend(base) @@ -66,7 +73,7 @@ end def convert_key(key) - key.to_s + IndifferentAccess.convert_key(key) end # Iterates through the keys and values, reconverting them to @@ -74,7 +81,7 @@ # is injecting itself into member hashes. def convert! keys.each do |k| # rubocop:disable Performance/HashEachMethods - regular_writer convert_key(k), indifferent_value(regular_delete(k)) + indifferent_writer k, regular_delete(k) end self end @@ -133,7 +140,7 @@ def merge(*args) result = super - IndifferentAccess.inject!(result) if hash_lacking_indifference?(result) + return IndifferentAccess.inject!(result) if hash_lacking_indifference?(result) result.convert! end @@ -141,6 +148,32 @@ super.convert! end + def to_hash + {}.tap do |result| + each_pair { |key, value| result[key] = value } + + if default_proc + result.default_proc = default_proc + else + result.default = default + end + end + end + + with_minimum_ruby('2.5.0') do + def slice(*keys) + string_keys = keys.map { |key| convert_key(key) } + super(*string_keys) + end + end + + with_minimum_ruby('3.0.0') do + def except(*keys) + string_keys = keys.map { |key| convert_key(key) } + super(*string_keys) + end + end + protected def hash_lacking_indifference?(other) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/extensions/mash/symbolize_keys.rb new/lib/hashie/extensions/mash/symbolize_keys.rb --- old/lib/hashie/extensions/mash/symbolize_keys.rb 2020-02-01 15:36:16.000000000 +0100 +++ new/lib/hashie/extensions/mash/symbolize_keys.rb 2021-11-08 20:46:03.000000000 +0100 @@ -5,7 +5,7 @@ # # @example # class LazyResponse < Hashie::Mash - # include Hashie::Extensions::Mash::SymbolizedKeys + # include Hashie::Extensions::Mash::SymbolizeKeys # end # # response = LazyResponse.new("id" => 123, "name" => "Rey").to_h @@ -24,13 +24,13 @@ private - # Converts a key to a symbol + # Converts a key to a symbol, if possible # # @api private - # @param [String, Symbol] key the key to convert to a symbol - # @return [void] + # @param [<K>] key the key to attempt convert to a symbol + # @return [Symbol, K] def convert_key(key) - key.to_sym + key.respond_to?(:to_sym) ? key.to_sym : key end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/extensions/symbolize_keys.rb new/lib/hashie/extensions/symbolize_keys.rb --- old/lib/hashie/extensions/symbolize_keys.rb 2020-02-01 15:36:16.000000000 +0100 +++ new/lib/hashie/extensions/symbolize_keys.rb 2021-11-08 20:46:03.000000000 +0100 @@ -46,7 +46,7 @@ hash.extend(Hashie::Extensions::SymbolizeKeys) unless hash.respond_to?(:symbolize_keys!) hash.keys.each do |k| # rubocop:disable Performance/HashEachMethods symbolize_keys_recursively!(hash[k]) - hash[k.to_sym] = hash.delete(k) + hash[convert_key(k)] = hash.delete(k) end hash end @@ -61,6 +61,17 @@ symbolize_keys!(new_hash) end end + + private + + # Converts a key to a symbol, if possible + # + # @api private + # @param [<K>] key the key to attempt convert to a symbol + # @return [Symbol, K] + def convert_key(key) + key.respond_to?(:to_sym) ? key.to_sym : key + end end class << self diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/hash.rb new/lib/hashie/hash.rb --- old/lib/hashie/hash.rb 2020-02-01 15:36:16.000000000 +0100 +++ new/lib/hashie/hash.rb 2021-11-08 20:46:03.000000000 +0100 @@ -21,8 +21,8 @@ assignment_key = if options[:stringify_keys] k.to_s - elsif options[:symbolize_keys] - k.to_s.to_sym + elsif options[:symbolize_keys] && k.respond_to?(:to_sym) + k.to_sym else k end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/mash.rb new/lib/hashie/mash.rb --- old/lib/hashie/mash.rb 2020-02-01 15:36:16.000000000 +0100 +++ new/lib/hashie/mash.rb 2021-11-08 20:46:03.000000000 +0100 @@ -62,7 +62,6 @@ # mash.author # => <Mash> # class Mash < Hash - include Hashie::Extensions::PrettyInspect include Hashie::Extensions::RubyVersionCheck extend Hashie::Extensions::KeyConflictWarning @@ -121,8 +120,8 @@ alias regular_reader [] alias regular_writer []= - # Retrieves an attribute set in the Mash. Will convert - # any key passed in to a string before retrieving. + # Retrieves an attribute set in the Mash. Will convert a key passed in + # as a symbol to a string before retrieving. def custom_reader(key) default_proc.call(self, key) if default_proc && !key?(key) value = regular_reader(convert_key(key)) @@ -130,14 +129,12 @@ value end - # Sets an attribute in the Mash. Key will be converted to - # a string before it is set, and Hashes will be converted - # into Mashes for nesting purposes. + # Sets an attribute in the Mash. Symbol keys will be converted to + # strings before being set, and Hashes will be converted into Mashes + # for nesting purposes. def custom_writer(key, value, convert = true) #:nodoc: - key_as_symbol = (key = convert_key(key)).to_sym - - log_built_in_message(key_as_symbol) if log_collision?(key_as_symbol) - regular_writer(key, convert ? convert_value(value) : value) + log_built_in_message(key) if key.respond_to?(:to_sym) && log_collision?(key.to_sym) + regular_writer(convert_key(key), convert ? convert_value(value) : value) end alias [] custom_reader @@ -354,6 +351,13 @@ end end + with_minimum_ruby('3.0.0') do + def except(*keys) + string_keys = keys.map { |key| convert_key(key) } + self.class.new(super(*string_keys)) + end + end + protected def method_name_and_suffix(method_name) @@ -371,7 +375,7 @@ end def convert_key(key) #:nodoc: - key.to_s + key.respond_to?(:to_sym) ? key.to_s : key end def convert_value(val, duping = false) #:nodoc: @@ -406,6 +410,7 @@ end def log_collision?(method_key) + return unless method_key.is_a?(String) || method_key.is_a?(Symbol) return unless respond_to?(method_key) _, suffix = method_name_and_suffix(method_key) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/version.rb new/lib/hashie/version.rb --- old/lib/hashie/version.rb 2020-02-01 15:36:16.000000000 +0100 +++ new/lib/hashie/version.rb 2021-11-08 20:46:03.000000000 +0100 @@ -1,3 +1,3 @@ module Hashie - VERSION = '4.1.0'.freeze + VERSION = '5.0.0'.freeze end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie.rb new/lib/hashie.rb --- old/lib/hashie.rb 2020-02-01 15:36:16.000000000 +0100 +++ new/lib/hashie.rb 2021-11-08 20:46:03.000000000 +0100 @@ -41,6 +41,7 @@ autoload :IndifferentAccess, 'hashie/extensions/dash/indifferent_access' autoload :PropertyTranslation, 'hashie/extensions/dash/property_translation' autoload :Coercion, 'hashie/extensions/dash/coercion' + autoload :PredefinedValues, 'hashie/extensions/dash/predefined_values' end module Mash diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2020-02-01 15:36:16.000000000 +0100 +++ new/metadata 2021-11-08 20:46:03.000000000 +0100 @@ -1,15 +1,15 @@ --- !ruby/object:Gem::Specification name: hashie version: !ruby/object:Gem::Version - version: 4.1.0 + version: 5.0.0 platform: ruby authors: - Michael Bleigh - Jerry Cheung -autorequire: +autorequire: bindir: bin cert_chain: [] -date: 2020-02-01 00:00:00.000000000 Z +date: 2021-11-08 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler @@ -50,6 +50,7 @@ - lib/hashie/extensions/coercion.rb - lib/hashie/extensions/dash/coercion.rb - lib/hashie/extensions/dash/indifferent_access.rb +- lib/hashie/extensions/dash/predefined_values.rb - lib/hashie/extensions/dash/property_translation.rb - lib/hashie/extensions/deep_fetch.rb - lib/hashie/extensions/deep_find.rb @@ -89,7 +90,7 @@ changelog_uri: https://github.com/hashie/hashie/blob/master/CHANGELOG.md documentation_uri: https://www.rubydoc.info/gems/hashie source_code_uri: https://github.com/hashie/hashie -post_install_message: +post_install_message: rdoc_options: [] require_paths: - lib @@ -104,8 +105,8 @@ - !ruby/object:Gem::Version version: '0' requirements: [] -rubygems_version: 3.0.3 -signing_key: +rubygems_version: 3.1.3 +signing_key: specification_version: 4 summary: Your friendly neighborhood hash library. test_files: []