commit rubygem-hashie for openSUSE:Factory
![](https://seccdn.libravatar.org/avatar/e2145bc5cf53dda95c308a3c75e8fef3.jpg?s=120&d=mm&r=g)
Hello community, here is the log from the commit of package rubygem-hashie for openSUSE:Factory checked in at 2016-05-29 03:11:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-hashie (Old) and /work/SRC/openSUSE:Factory/.rubygem-hashie.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-hashie" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-hashie/rubygem-hashie.changes 2015-10-30 21:53:04.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-hashie.new/rubygem-hashie.changes 2016-05-29 03:12:46.000000000 +0200 @@ -1,0 +2,6 @@ +Sat Apr 30 04:35:03 UTC 2016 - coolo@suse.com + +- updated to version 3.4.4 + see installed CHANGELOG.md + +------------------------------------------------------------------- Old: ---- hashie-3.4.3.gem New: ---- hashie-3.4.4.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-hashie.spec ++++++ --- /var/tmp/diff_new_pack.z5LvgB/_old 2016-05-29 03:12:46.000000000 +0200 +++ /var/tmp/diff_new_pack.z5LvgB/_new 2016-05-29 03:12:46.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-hashie # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # 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: 3.4.3 +Version: 3.4.4 Release: 0 %define mod_name hashie %define mod_full_name %{mod_name}-%{version} ++++++ hashie-3.4.3.gem -> hashie-3.4.4.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2015-10-25 19:56:06.000000000 +0100 +++ new/CHANGELOG.md 2016-04-29 18:33:16.000000000 +0200 @@ -1,154 +1,320 @@ -## 3.4.2 (10/25/2015) +# Change Log +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. + +[semver]: http://semver.org/spec/v2.0.0.html + +## [3.4.4] - 2016-04-29 + +[3.4.4]: https://github.com/intridea/hashie/compare/v3.4.3...v3.4.4 + +### Added + +* [#349](https://github.com/intridea/hashie/pull/349): Convert `Hashie::Mash#dig` arguments for Ruby 2.3.0 - [@k0kubun](https://github.com/k0kubun). + +### Fixed + +* [#240](https://github.com/intridea/hashie/pull/240): Fixed nesting twice with Clash keys - [@bartoszkopinski](https://github.com/bartoszkopinski). +* [#317](https://github.com/intridea/hashie/pull/317): Ensure `Hashie::Extensions::MethodQuery` methods return boolean values - [@michaelherold](https://github.com/michaelherold). +* [#319](https://github.com/intridea/hashie/pull/319): Fix a regression from 3.4.1 where `Hashie::Extensions::DeepFind` is no longer indifference-aware - [@michaelherold](https://github.com/michaelherold). +* [#322](https://github.com/intridea/hashie/pull/322): Fixed `reverse_merge` issue with `Mash` subclasses - [@marshall-lee](https://github.com/marshall-lee). +* [#346](https://github.com/intridea/hashie/pull/346): Fixed `merge` breaking indifferent access - [@docwhat](https://github.com/docwhat), [@michaelherold](https://github.com/michaelherold). +* [#350](https://github.com/intridea/hashie/pull/350): Fixed from string translations used with `IgnoreUndeclared` - [@marshall-lee](https://github.com/marshall-lee). + +## [3.4.3] - 2015-10-25 + +[3.4.3]: https://github.com/intridea/hashie/compare/v3.4.2...v3.4.3 + +### Added + +* [#306](https://github.com/intridea/hashie/pull/306): Added `Hashie::Extensions::Dash::Coercion` - [@marshall-lee](https://github.com/marshall-lee). * [#314](https://github.com/intridea/hashie/pull/314): Added a `StrictKeyAccess` extension that will raise an error whenever a key is accessed that does not exist in the hash - [@pboling](https://github.com/pboling). + +### Fixed + * [#304](https://github.com/intridea/hashie/pull/304): Ensured compatibility of `Hash` extensions with singleton objects - [@regexident](https://github.com/regexident). -* [#306](https://github.com/intridea/hashie/pull/306): Added `Hashie::Extensions::Dash::Coercion` - [@marshall-lee](https://github.com/marshall-lee). * [#310](https://github.com/intridea/hashie/pull/310): Fixed `Hashie::Extensions::SafeAssignment` bug with private methods - [@marshall-lee](https://github.com/marshall-lee). + +### Miscellaneous + * [#313](https://github.com/intridea/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/intridea/hashie/pull/315): Default `bin/` scripts: `console` and `setup` - [@pboling](https://github.com/pboling). -## 3.4.2 (6/2/2015) +## [3.4.2] - 2015-06-02 + +[3.4.2]: https://github.com/intridea/hashie/compare/v3.4.1...v3.4.2 + +### Added -* [#292](https://github.com/intridea/hashie/pull/292): Removed `Mash#id` and `Mash#type` - [@jrochkind](https://github.com/jrochkind). * [#297](https://github.com/intridea/hashie/pull/297): Extracted `Trash`'s behavior into a new `Dash::PropertyTranslation` extension - [@michaelherold](https://github.com/michaelherold). -## 3.4.1 (3/31/2015) +### Removed + +* [#292](https://github.com/intridea/hashie/pull/292): Removed `Mash#id` and `Mash#type` - [@jrochkind](https://github.com/jrochkind). + +## [3.4.1] - 2015-03-31 + +[3.4.1]: https://github.com/intridea/hashie/compare/v3.4.0...v3.4.1 + +### Added * [#269](https://github.com/intridea/hashie/pull/272): Added Hashie::Extensions::DeepLocate - [@msievers](https://github.com/msievers). -* [#270](https://github.com/intridea/hashie/pull/277): Fixed ArgumentError raised when using IndifferentAccess and HashWithIndifferentAccess - [@gardenofwine](https://github.com/gardenofwine). * [#281](https://github.com/intridea/hashie/pull/281): Added #reverse_merge to Mash to override ActiveSupport's version - [@mgold](https://github.com/mgold). + +### Fixed + +* [#270](https://github.com/intridea/hashie/pull/277): Fixed ArgumentError raised when using IndifferentAccess and HashWithIndifferentAccess - [@gardenofwine](https://github.com/gardenofwine). * [#282](https://github.com/intridea/hashie/pull/282): Fixed coercions in a subclass accumulating in the superclass - [@maxlinc](https://github.com/maxlinc), [@martinstreicher](https://github.com/martinstreicher). -## 3.4.0 (2/02/2015) +## [3.4.0] - 2015-02-02 + +[3.4.0]: https://github.com/intridea/hashie/compare/v3.3.2...v3.4.0 + +### Added -* [#271](https://github.com/intridea/hashie/pull/271): Added ability to define defaults based on current hash - [@gregory](https://github.com/gregory). -* [#247](https://github.com/intridea/hashie/pull/247): Fixed #stringify_keys and #symbolize_keys collision with ActiveSupport - [@bartoszkopinski](https://github.com/bartoszkopinski). -* [#249](https://github.com/intridea/hashie/pull/249): SafeAssignment will now also protect hash-style assignments - [@jrochkind](https://github.com/jrochkind). * [#251](https://github.com/intridea/hashie/pull/251): Added block support to indifferent access #fetch - [@jgraichen](https://github.com/jgraichen). * [#252](https://github.com/intridea/hashie/pull/252): Added support for conditionally required Hashie::Dash attributes - [@ccashwell](https://github.com/ccashwell). +* [#254](https://github.com/intridea/hashie/pull/254): Added public utility methods for stringify and symbolize keys - [@maxlinc](https://github.com/maxlinc). +* [#260](https://github.com/intridea/hashie/pull/260): Added block support to Extensions::DeepMerge - [@galathius](https://github.com/galathius). +* [#271](https://github.com/intridea/hashie/pull/271): Added ability to define defaults based on current hash - [@gregory](https://github.com/gregory). + +### Changed + +* [#249](https://github.com/intridea/hashie/pull/249): SafeAssignment will now also protect hash-style assignments - [@jrochkind](https://github.com/jrochkind). +* [#264](https://github.com/intridea/hashie/pull/264): Methods such as abc? return true/false with Hashie::Extensions::MethodReader - [@Zloy](https://github.com/Zloy). + +### Fixed + +* [#247](https://github.com/intridea/hashie/pull/247): Fixed #stringify_keys and #symbolize_keys collision with ActiveSupport - [@bartoszkopinski](https://github.com/bartoszkopinski). * [#256](https://github.com/intridea/hashie/pull/256): Inherit key coercions - [@Erol](https://github.com/Erol). * [#259](https://github.com/intridea/hashie/pull/259): Fixed handling of default proc values in Mash - [@Erol](https://github.com/Erol). -* [#260](https://github.com/intridea/hashie/pull/260): Added block support to Extensions::DeepMerge - [@galathius](https://github.com/galathius). -* [#254](https://github.com/intridea/hashie/pull/254): Added public utility methods for stringify and symbolize keys - [@maxlinc](https://github.com/maxlinc). * [#261](https://github.com/intridea/hashie/pull/261): Fixed bug where Dash.property modifies argument object - [@d-tw](https://github.com/d-tw). -* [#264](https://github.com/intridea/hashie/pull/264): Methods such as abc? return true/false with Hashie::Extensions::MethodReader - [@Zloy](https://github.com/Zloy). * [#269](https://github.com/intridea/hashie/pull/269): Add #extractable_options? so ActiveSupport Array#extract_options! can extract it - [@ridiculous](https://github.com/ridiculous). -## 3.3.2 (11/26/2014) +## [3.3.2] - 2014-11-26 + +[3.3.2]: https://github.com/intridea/hashie/compare/v3.3.1...v3.3.2 + +### Added -* [#233](https://github.com/intridea/hashie/pull/233): Custom error messages for required properties in Hashie::Dash subclasses - [@joss](https://github.com/joss). * [#231](https://github.com/intridea/hashie/pull/231): Added support for coercion on class type that inherit from Hash - [@gregory](https://github.com/gregory). -* [#228](https://github.com/intridea/hashie/pull/228): Made Hashie::Extensions::Parsers::YamlErbParser pass template filename to ERB - [@jperville](https://github.com/jperville). -* [#224](https://github.com/intridea/hashie/pull/224): Merging Hashie::Mash now correctly only calls the block on duplicate values - [@amysutedja](https://github.com/amysutedja). -* [#221](https://github.com/intridea/hashie/pull/221): Reduce amount of allocated objects on calls with suffixes in Hashie::Mash - [@kubum](https://github.com/kubum). +* [#233](https://github.com/intridea/hashie/pull/233): Custom error messages for required properties in Hashie::Dash subclasses - [@joss](https://github.com/joss). * [#245](https://github.com/intridea/hashie/pull/245): Added Hashie::Extensions::MethodAccessWithOverride to autoloads - [@Fritzinger](https://github.com/Fritzinger). -## 3.3.1 (8/26/2014) +### Fixed + +* [#221](https://github.com/intridea/hashie/pull/221): Reduce amount of allocated objects on calls with suffixes in Hashie::Mash - [@kubum](https://github.com/kubum). +* [#224](https://github.com/intridea/hashie/pull/224): Merging Hashie::Mash now correctly only calls the block on duplicate values - [@amysutedja](https://github.com/amysutedja). +* [#228](https://github.com/intridea/hashie/pull/228): Made Hashie::Extensions::Parsers::YamlErbParser pass template filename to ERB - [@jperville](https://github.com/jperville). + +## [3.3.1] - 2014-08-26 + +[3.3.1]: https://github.com/intridea/hashie/compare/v3.3.0...v3.3.1 + +### Added * [#183](https://github.com/intridea/hashie/pull/183): Added Mash#load with YAML file support - [@gregory](https://github.com/gregory). -* [#195](https://github.com/intridea/hashie/pull/195): Ensure that the same object is returned after injecting IndifferentAccess - [@michaelherold](https://github.com/michaelherold). -* [#201](https://github.com/intridea/hashie/pull/201): Hashie::Trash transforms can be inherited - [@fobocaster](https://github.com/fobocaster). * [#189](https://github.com/intridea/hashie/pull/189): Added Rash#fetch - [@medcat](https://github.com/medcat). -* [#200](https://github.com/intridea/hashie/pull/200): Improved coercion: primitives and error handling - [@maxlinc](https://github.com/maxlinc). * [#204](https://github.com/intridea/hashie/pull/204): Added Hashie::Extensions::MethodOverridingWriter and MethodAccessWithOverride - [@michaelherold](https://github.com/michaelherold). * [#205](http://github.com/intridea/hashie/pull/205): Added Hashie::Extensions::Mash::SafeAssignment - [@michaelherold](https://github.com/michaelherold). -* [#206](http://github.com/intridea/hashie/pull/206): Fixed stack overflow from repetitively including coercion in subclasses - [@michaelherold](https://github.com/michaelherold). -* [#207](http://github.com/intridea/hashie/pull/207): Fixed inheritance of transformations in Trash - [@fobocaster](https://github.com/fobocaster). * [#209](http://github.com/intridea/hashie/pull/209): Added Hashie::Extensions::DeepFind - [@michaelherold](https://github.com/michaelherold). + +### Fixed + * [#69](https://github.com/intridea/hashie/pull/69): Fixed regression in assigning multiple properties in Hashie::Trash - [@michaelherold](https://github.com/michaelherold), [@einzige](https://github.com/einzige), [@dblock](https://github.com/dblock). +* [#195](https://github.com/intridea/hashie/pull/195): Ensure that the same object is returned after injecting IndifferentAccess - [@michaelherold](https://github.com/michaelherold). +* [#201](https://github.com/intridea/hashie/pull/201): Hashie::Trash transforms can be inherited - [@fobocaster](https://github.com/fobocaster). +* [#200](https://github.com/intridea/hashie/pull/200): Improved coercion: primitives and error handling - [@maxlinc](https://github.com/maxlinc). +* [#206](http://github.com/intridea/hashie/pull/206): Fixed stack overflow from repetitively including coercion in subclasses - [@michaelherold](https://github.com/michaelherold). +* [#207](http://github.com/intridea/hashie/pull/207): Fixed inheritance of transformations in Trash - [@fobocaster](https://github.com/fobocaster). -## 3.2.0 (7/10/2014) +## [3.2.0] - 2014-07-10 + +[3.2.0]: https://github.com/intridea/hashie/compare/v3.1.0...v3.2.0 + +### Added -* [#164](https://github.com/intridea/hashie/pull/164), [#165](https://github.com/intridea/hashie/pull/165), [#166](https://github.com/intridea/hashie/pull/166): Fixed stack overflow when coercing mashes that contain ActiveSupport::HashWithIndifferentAccess values - [@numinit](https://github.com/numinit), [@kgrz](https://github.com/kgrz). * [#177](https://github.com/intridea/hashie/pull/177): Added support for coercing enumerables and collections - [@gregory](https://github.com/gregory). + +### Changed + * [#179](https://github.com/intridea/hashie/pull/179): Mash#values_at will convert each key before doing the lookup - [@nahiluhmot](https://github.com/nahiluhmot). * [#184](https://github.com/intridea/hashie/pull/184): Allow ranges on Rash to match all Numeric types - [@medcat](https://github.com/medcat). + +### Fixed + +* [#164](https://github.com/intridea/hashie/pull/164), [#165](https://github.com/intridea/hashie/pull/165), [#166](https://github.com/intridea/hashie/pull/166): Fixed stack overflow when coercing mashes that contain ActiveSupport::HashWithIndifferentAccess values - [@numinit](https://github.com/numinit), [@kgrz](https://github.com/kgrz). * [#187](https://github.com/intridea/hashie/pull/187): Automatically require version - [@medcat](https://github.com/medcat). * [#190](https://github.com/intridea/hashie/issues/190): Fixed `coerce_key` with `from` Trash feature and Coercion extension - [@gregory](https://github.com/gregory). * [#192](https://github.com/intridea/hashie/pull/192): Fixed StringifyKeys#stringify_keys! to recursively stringify keys of embedded ::Hash types - [@dblock](https://github.com/dblock). -## 3.1.0 (6/25/2014) +## [3.1.0] - 2014-06-25 + +[3.1.0]: https://github.com/intridea/hashie/compare/v3.0.0...v3.1.0 + +### Added + +* [#172](https://github.com/intridea/hashie/pull/172): Added Dash and Trash#update_attributes! - [@gregory](https://github.com/gregory). + +### Changed * [#169](https://github.com/intridea/hashie/pull/169): Hash#to_hash will also convert nested objects that implement to_hash - [@gregory](https://github.com/gregory). +* [#173](https://github.com/intridea/hashie/pull/173): Auto include Dash::IndifferentAccess when IndifferentAccess is included in Dash - [@gregory](https://github.com/gregory). + +### Fixed + * [#171](https://github.com/intridea/hashie/pull/171): Include Trash and Dash class name when raising `NoMethodError` - [@gregory](https://github.com/gregory). -* [#172](https://github.com/intridea/hashie/pull/172): Added Dash and Trash#update_attributes! - [@gregory](https://github.com/gregory). -* [#173](https://github.com/intridea/hashie/pull/173): Auto include Dash::IndifferentAccess when IndiferentAccess is included in Dash - [@gregory](https://github.com/gregory). * [#174](https://github.com/intridea/hashie/pull/174): Fixed `from` and `transform_with` Trash features when IndifferentAccess is included - [@gregory](https://github.com/gregory). -## 3.0.0 (6/3/2014) +## [3.0.0] - 2014-06-03 + +[3.0.0]: https://github.com/intridea/hashie/compare/v2.1.2...v3.0.0 **Note:** This version introduces several backward incompatible API changes. See [UPGRADING](UPGRADING.md) for details. -* [#150](https://github.com/intridea/hashie/pull/159): Handle nil intermediate object on deep fetch - [@stephenaument](https://github.com/stephenaument). -* [#146](https://github.com/intridea/hashie/issues/146): Mash#respond_to? inconsistent with #method_missing and does not respond to #permitted? - [@dblock](https://github.com/dblock). +### Added + +* [#149](https://github.com/intridea/hashie/issues/149): Allow IgnoreUndeclared and DeepMerge to be used with undeclared properties - [@jhaesus](https://github.com/jhaesus). + +### Changed + * [#152](https://github.com/intridea/hashie/pull/152): Do not convert keys to String in Hashie::Dash and Hashie::Trash, use Hashie::Extensions::Dash::IndifferentAccess to achieve backward compatible behavior - [@dblock](https://github.com/dblock). * [#152](https://github.com/intridea/hashie/pull/152): Do not automatically stringify keys in Hashie::Hash#to_hash, pass `:stringify_keys` to achieve backward compatible behavior - [@dblock](https://github.com/dblock). + +### Fixed + +* [#146](https://github.com/intridea/hashie/issues/146): Mash#respond_to? inconsistent with #method_missing and does not respond to #permitted? - [@dblock](https://github.com/dblock). * [#148](https://github.com/intridea/hashie/pull/148): Consolidated Hashie::Hash#stringify_keys implementation - [@dblock](https://github.com/dblock). -* [#149](https://github.com/intridea/hashie/issues/149): Allow IgnoreUndeclared and DeepMerge to be used with undeclared properties - [@jhaesus](https://github.com/jhaesus). +* [#159](https://github.com/intridea/hashie/pull/159): Handle nil intermediate object on deep fetch - [@stephenaument](https://github.com/stephenaument). + +## [2.1.2] - 2014-05-12 -## 2.1.2 (5/12/2014) +[2.1.2]: https://github.com/intridea/hashie/compare/v2.1.1...v2.1.2 + +### Changed * [#169](https://github.com/intridea/hashie/pull/169): Hash#to_hash will also convert nested objects that implement `to_hash` - [@gregory](https://github.com/gregory). -## 2.1.1 (4/12/2014) +## [2.1.1] - 2014-04-12 + +[2.1.1]: https://github.com/intridea/hashie/compare/v2.1.0...v2.1.1 + +### Fixed +* [#131](https://github.com/intridea/hashie/pull/131): Added IgnoreUndeclared, an extension to silently ignore undeclared properties at intialization - [@righi](https://github.com/righi). +* [#138](https://github.com/intridea/hashie/pull/138): Added Hashie::Rash, a hash whose keys can be regular expressions or ranges - [@epitron](https://github.com/epitron). * [#144](https://github.com/intridea/hashie/issues/144): Fixed regression invoking `to_hash` with no parameters - [@mbleigh](https://github.com/mbleigh). -## 2.1.0 (4/6/2014) +## [2.1.0] - 2014-04-06 + +[2.1.0]: https://github.com/intridea/hashie/compare/v2.0.5...v2.1.0 + +### Added * [#134](https://github.com/intridea/hashie/pull/134): Add deep_fetch extension for nested access - [@tylerdooling](https://github.com/tylerdooling). + +### Changed + +* [#89](https://github.com/intridea/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). + +### Removed + * Removed support for Ruby 1.8.7 - [@dblock](https://github.com/dblock). -* Ruby style now enforced with Rubocop - [@dblock](https://github.com/dblock). -* [#138](https://github.com/intridea/hashie/pull/138): Added Hashie::Rash, a hash whose keys can be regular expressions or ranges - [@epitron](https://github.com/epitron). -* [#131](https://github.com/intridea/hashie/pull/131): Added IgnoreUndeclared, an extension to silently ignore undeclared properties at intialization - [@righi](https://github.com/righi). * [#136](https://github.com/intridea/hashie/issues/136): Removed Hashie::Extensions::Structure - [@markiz](https://github.com/markiz). -* [#107](https://github.com/intridea/hashie/pull/107): Fixed excessive value conversions, poor performance of deep merge in Hashie::Mash - [@davemitchell](https://github.com/dblock), [@dblock](https://github.com/dblock). + +### Fixed + * [#69](https://github.com/intridea/hashie/issues/69): Fixed assigning multiple properties in Hashie::Trash - [@einzige](https://github.com/einzige). +* [#99](https://github.com/intridea/hashie/issues/99): Hash#deep_merge raises errors when it encounters integers - [@defsprite](https://github.com/defsprite). * [#100](https://github.com/intridea/hashie/pull/100): IndifferentAccess#store will respect indifference - [@jrochkind](https://github.com/jrochkind). * [#103](https://github.com/intridea/hashie/pull/103): Fixed support for Hashie::Dash properties that end in bang - [@thedavemarshall](https://github.com/thedavemarshall). -* [89](https://github.com/intridea/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). +* [#107](https://github.com/intridea/hashie/pull/107): Fixed excessive value conversions, poor performance of deep merge in Hashie::Mash - [@davemitchell](https://github.com/dblock), [@dblock](https://github.com/dblock). * [#110](https://github.com/intridea/hashie/pull/110): Correctly use Hash#default from Mash#method_missing - [@ryansouza](https://github.com/ryansouza). -* [#120](https://github.com/intridea/hashie/pull/120): Pass options to recursive to_hash calls - [@pwillett](https://github.com/pwillett). -* [#113](https://github.com/intridea/hashie/issues/113): Fixed Hash#merge with Hashie::Dash - [@spencer1248](https://github.com/spencer1248). -* [#99](https://github.com/intridea/hashie/issues/99): Hash#deep_merge raises errors when it encounters integers - [@defsprite](https://github.com/defsprite). -* [#133](https://github.com/intridea/hashie/pull/133): Fixed Hash##to_hash with symbolize_keys - [@mhuggins](https://github.com/mhuggins). -* [#130](https://github.com/intridea/hashie/pull/130): IndifferentAccess now works without MergeInitializer - [@npj](https://github.com/npj). * [#111](https://github.com/intridea/hashie/issues/111): Trash#translations correctly maps original to translated names - [@artm](https://github.com/artm). +* [#113](https://github.com/intridea/hashie/issues/113): Fixed Hash#merge with Hashie::Dash - [@spencer1248](https://github.com/spencer1248). +* [#120](https://github.com/intridea/hashie/pull/120): Pass options to recursive to_hash calls - [@pwillett](https://github.com/pwillett). * [#129](https://github.com/intridea/hashie/pull/129): Added Trash#permitted_input_keys and inverse_translations - [@artm](https://github.com/artm). +* [#130](https://github.com/intridea/hashie/pull/130): IndifferentAccess now works without MergeInitializer - [@npj](https://github.com/npj). +* [#133](https://github.com/intridea/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 +[2.0.5]: https://github.com/intridea/hashie/compare/v2.0.4...v2.0.5 + +### Fixed * [#96](https://github.com/intridea/hashie/pull/96): Make coercion work better with non-symbol keys in Hashie::Mash - [@wapcaplet](https://github.com/wapcaplet). -## 2.0.4 +## [2.0.4] - 2013-04-24 + +[2.0.4]: https://github.com/intridea/hashie/compare/v2.0.3...v2.0.4 + +### Fixed + +* [#94](https://github.com/intridea/hashie/pull/94): Make #fetch method consistent with normal Hash - [@markiz](https://github.com/markiz). + +### Miscellaneous -* [#04](https://github.com/intridea/hashie/pull/94): Make #fetch method consistent with normal Hash - [@markiz](https://github.com/markiz). * [#90](https://github.com/intridea/hashie/pull/90): Various doc tweaks - [@craiglittle](https://github.com/craiglittle). -## 2.0.3 +## [2.0.3] - 2013-03-18 + +[2.0.3]: https://github.com/intridea/hashie/compare/v2.0.2...v2.0.3 + +### Fixed -* [#88](https://github.com/intridea/hashie/pull/88): Hashie::Mash.new(abc: true).respond_to?(:abc?) works - [@7even](https://github.com/7even). * [#68](https://github.com/intridea/hashie/pull/68): Fix #replace - [@jimeh](https://github.com/jimeh). +* [#88](https://github.com/intridea/hashie/pull/88): Hashie::Mash.new(abc: true).respond_to?(:abc?) works - [@7even](https://github.com/7even). + +## [2.0.2] - 2013-02-26 -## 2.0.2 +[2.0.2]: https://github.com/intridea/hashie/compare/v2.0.1...v2.0.2 + +### Fixed * [#85](https://github.com/intridea/hashie/pull/85): adding symbolize_keys back to to_hash - [@cromulus](https://github.com/cromulus). -## 2.0.1 +## [2.0.1] - 2013-02-26 + +[2.0.1]: https://github.com/intridea/hashie/compare/v2.0.0...v2.0.1 + +### Removed * [#81](https://github.com/intridea/hashie/pull/81): remove 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). -## 2.0.0 +## [2.0.0] - 2013-02-16 + +[2.0.0]: https://github.com/intridea/hashie/compare/v1.2.0...v2.0.0 + +### Added + +* [#41](https://github.com/intridea/hashie/pull/41): DeepMerge extension - [@nashby](https://github.com/nashby). +* [#78](https://github.com/intridea/hashie/pull/78): Merge and update accepts a block - [@jch](https://github.com/jch). + +### Changed -* [#72](https://github.com/intridea/hashie/pull/72): Updated gemspec with license info - [@jordimassaguerpla](https://github.com/jordimassaguerpla). -* [#27](https://github.com/intridea/hashie/pull/27): Initialized with merge coerces values - [@mattfawcett](https://github.com/mattfawcett). * [#28](https://github.com/intridea/hashie/pull/28): Hashie::Extensions::Coercion coerce_keys takes arguments - [@mattfawcett](https://github.com/mattfawcett). +* [#77](https://github.com/intridea/hashie/pull/77): Remove id, type, and object_id as special allowable keys [@jch](https://github.com/jch). + +### Fixed + +* [#27](https://github.com/intridea/hashie/pull/27): Initialized with merge coerces values - [@mattfawcett](https://github.com/mattfawcett). * [#39](https://github.com/intridea/hashie/pull/39): Trash removes translated values on initialization - [@sleverbor](https://github.com/sleverbor). -* [#66](https://github.com/intridea/hashie/pull/66): Mash#fetch works with symbol or string keys - [@arthwood](https://github.com/arthwood). * [#49](https://github.com/intridea/hashie/pull/49): Hashie::Hash inherits from ::Hash to avoid ambiguity - [@meh](https://github.com/meh), [@orend](https://github.com/orend). * [#62](https://github.com/intridea/hashie/pull/62): update respond_to? method signature to match ruby core definition - [@dlupu](https://github.com/dlupu). -* [#41](https://github.com/intridea/hashie/pull/41): DeepMerge extension - [@nashby](https://github.com/nashby). * [#63](https://github.com/intridea/hashie/pull/63): Dash defaults are dup'ed before assigned - [@ohrite](https://github.com/ohrite). -* [#77](https://github.com/intridea/hashie/pull/77): Remove id, type, and object_id as special allowable keys [@jch](https://github.com/jch). -* [#78](https://github.com/intridea/hashie/pull/78): Merge and update accepts a block - [@jch](https://github.com/jch). +* [#66](https://github.com/intridea/hashie/pull/66): Mash#fetch works with symbol or string keys - [@arthwood](https://github.com/arthwood). + +### Miscellaneous + +* [#72](https://github.com/intridea/hashie/pull/72): Updated gemspec with license info - [@jordimassaguerpla](https://github.com/jordimassaguerpla). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CONTRIBUTING.md new/CONTRIBUTING.md --- old/CONTRIBUTING.md 2015-10-25 19:56:06.000000000 +0100 +++ new/CONTRIBUTING.md 2016-04-29 18:33:16.000000000 +0200 @@ -52,7 +52,17 @@ #### Update Changelog -Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account. +Add a line to [CHANGELOG](CHANGELOG.md) under *Unreleased*. Make it look like every other line, including your name and link to your Github account. + +There are several categorizations of changes that you can choose from. Add your line to the appropriate section, following these conventions: + +* **Added** - When you add a new behavior to any class or module (or add a new extension) that does not break backwards compatibility, you should mark it as "added". This is generally a fully new behavior that does not touch any pre-existing public API. Changes here require a MINOR version bump, following the Semantic Versioning specification. +* **Changed** - You should mark any change to the behavior of a public API on any class or module as "changed". Changes here require a MAJOR version bump, following the Semantic Versioning specification. +* **Deprecated** - Any time you deprecate part of the public API on any class or module you should mark the change as "deprecated". Deprecated behavior will be removed in the next MAJOR version bump, but should be left in until then. Changes here require a MINOR version bump, following the Semantic Versioning specification. +* **Removed** - You should mark any behavior that you removed from a public API on any class or module as "removed". Changes here require a MAJOR version bump, following the Semantic Versioning specification. +* **Fixed** - Any time you fix a bug you should mark as "fixed". Changes here require a PATCH version bump. +* **Security** - You should mark any security issue that you fix as "security". Changes here require a PATCH version bump. +* **Miscellaneous** - Mark any other changes you make (i.e. documentation updates, test harness changes, etc.) as "miscellaneous". Changes here require a PATCH version bump. #### Commit Changes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2015-10-25 19:56:06.000000000 +0100 +++ new/README.md 2016-04-29 18:33:16.000000000 +0200 @@ -18,13 +18,13 @@ $ gem install hashie ``` -## Stable Release +## Upgrading -You're reading the documentation for the stable release [3.4.3](https://github.com/intridea/hashie/blob/v3.4.3/README.md). +You're reading the documentation for the stable release of Hashie, 3.4.4. Please read [UPGRADING](UPGRADING.md) when upgrading from a previous version. ## Hash Extensions -The library is broken up into a number of atomically includeable Hash extension modules as described below. This provides maximum flexibility for users to mix and match functionality while maintaining feature parity with earlier versions of Hashie. +The library is broken up into a number of atomically includable Hash extension modules as described below. This provides maximum flexibility for users to mix and match functionality while maintaining feature parity with earlier versions of Hashie. Any of the extensions listed below can be mixed into a class by `include`-ing `Hashie::Extensions::ExtensionName`. @@ -135,11 +135,11 @@ coerce_key :retweeted, ->(v) do case v when String - return !!(v =~ /^(true|t|yes|y|1)$/i) + !!(v =~ /\A(true|t|yes|y|1)\z/i) when Numeric - return !v.to_i.zero? + !v.to_i.zero? else - return v == true + v == true end end end @@ -237,9 +237,30 @@ ### IndifferentAccess -This extension can be mixed in to instantly give you indifferent access to your Hash subclass. This works just like the params hash in Rails and other frameworks where whether you provide symbols or strings to access keys, you will get the same results. +This extension can be mixed in to your Hash subclass to allow you to use Strings or Symbols interchangeably as keys; similar to the `params` hash in Rails. -A unique feature of Hashie's IndifferentAccess mixin is that it will inject itself recursively into subhashes *without* reinitializing the hash in question. This means you can safely merge together indifferent and non-indifferent hashes arbitrarily deeply without worrying about whether you'll be able to `hash[:other][:another]` properly. +In addition, IndifferentAccess will also inject itself into sub-hashes so they behave the same. + +Example: + +```ruby +class MyHash < Hash + include Hashie::Extensions::MergeInitializer + include Hashie::Extensions::IndifferentAccess +end + +myhash = MyHash.new(:cat => 'meow', 'dog' => 'woof') +myhash['cat'] # => "meow" +myhash[:cat] # => "meow" +myhash[:dog] # => "woof" +myhash['dog'] # => "woof" + +# Auto-Injecting into sub-hashes. +myhash['fishes'] = {} +myhash['fishes'].class # => Hash +myhash['fishes'][:food] = 'flakes' +myhash['fishes']['food'] # => "flakes" +``` ### IgnoreUndeclared diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/UPGRADING.md new/UPGRADING.md --- old/UPGRADING.md 2015-10-25 19:56:06.000000000 +0100 +++ new/UPGRADING.md 2016-04-29 18:33:16.000000000 +0200 @@ -1,6 +1,17 @@ Upgrading Hashie ================ +### Upgrading to 3.4.4 + +#### Mash subclasses and reverse_merge + +```ruby +class MyMash < Hashie::Mash +end +``` + +In versions >= 3.4.4 `MyMash#reverse_merge` returns an instance of `MyMash` but in previous versions it was a `Hashie::Mash` instance. + ### Upgrading to 3.2.2 #### Testing if key defined Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hashie.gemspec new/hashie.gemspec --- old/hashie.gemspec 2015-10-25 19:56:06.000000000 +0100 +++ new/hashie.gemspec 2016-04-29 18:33:16.000000000 +0200 @@ -12,9 +12,9 @@ gem.require_paths = ['lib'] gem.files = %w(.yardopts CHANGELOG.md CONTRIBUTING.md LICENSE README.md UPGRADING.md Rakefile hashie.gemspec) - gem.files += Dir['lib/**/*.rb'] - gem.files += Dir['spec/**/*.rb'] - gem.test_files = Dir['spec/**/*.rb'] + gem.files += Dir['lib/**/*.rb'] + gem.files += Dir['spec/**/*.rb'] + gem.test_files = Dir['spec/**/*.rb'] gem.add_development_dependency 'rake' gem.add_development_dependency 'rspec', '~> 3.0' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/clash.rb new/lib/hashie/clash.rb --- old/lib/hashie/clash.rb 2015-10-25 19:56:06.000000000 +0100 +++ new/lib/hashie/clash.rb 2016-04-29 18:33:16.000000000 +0200 @@ -54,7 +54,7 @@ case args.length when 1 val = args.first - val = self[key].merge(val) if self[key].is_a?(::Hash) && val.is_a?(::Hash) + val = self.class.new(self[key]).merge(val) if self[key].is_a?(::Hash) && val.is_a?(::Hash) else val = args end @@ -64,22 +64,23 @@ end def method_missing(name, *args) #:nodoc: - name = name.to_s - if name.match(/!$/) && args.empty? + if args.empty? && name.to_s.end_with?('!') key = name[0...-1].to_sym - if self[key].nil? - self[key] = Clash.new({}, self) - elsif self[key].is_a?(::Hash) && !self[key].is_a?(Clash) - self[key] = Clash.new(self[key], self) + case self[key] + when NilClass + self[key] = self.class.new({}, self) + when Clash + self[key] + when Hash + self[key] = self.class.new(self[key], self) else fail ChainError, 'Tried to chain into a non-hash key.' end - - self[key] elsif args.any? - key = name.to_sym - merge_store(key, *args) + merge_store(name, *args) + else + super end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/extensions/coercion.rb new/lib/hashie/extensions/coercion.rb --- old/lib/hashie/extensions/coercion.rb 2015-10-25 19:56:06.000000000 +0100 +++ new/lib/hashie/extensions/coercion.rb 2016-04-29 18:33:16.000000000 +0200 @@ -111,7 +111,7 @@ options = { strict: true }.merge(options) if ABSTRACT_CORE_TYPES.key? from - ABSTRACT_CORE_TYPES[from].each do | type | + ABSTRACT_CORE_TYPES[from].each do |type| coerce_value type, into, options end end @@ -130,6 +130,7 @@ def strict_value_coercions @strict_value_coercions ||= {} end + # Return all value coercions that have the :strict rule as false. def lenient_value_coercions @lenient_value_coercions ||= {} @@ -158,7 +159,8 @@ type, key_type, value_type = type.class, *type.first build_hash_coercion(type, key_type, value_type) else # Enumerable but not Hash: Array, Set - type, value_type = type.class, type.first + value_type = type.first + type = type.class build_container_coercion(type, value_type) end elsif CORE_TYPES.key? type diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/extensions/deep_locate.rb new/lib/hashie/extensions/deep_locate.rb --- old/lib/hashie/extensions/deep_locate.rb 2015-10-25 19:56:06.000000000 +0100 +++ new/lib/hashie/extensions/deep_locate.rb 2016-04-29 18:33:16.000000000 +0200 @@ -17,12 +17,7 @@ # Hashie::Extensions::DeepLocate.deep_locate -> (key, value, object) { key == :title }, books # # => [{:title=>"Ruby for beginners", :pages=>120}, ...] def self.deep_locate(comparator, object) - # ensure comparator is a callable - unless comparator.respond_to?(:call) - comparator = lambda do |non_callable_object| - ->(key, _, _) { key == non_callable_object } - end.call(comparator) - end + comparator = _construct_key_comparator(comparator, object) unless comparator.respond_to?(:call) _deep_locate(comparator, object) end @@ -68,17 +63,18 @@ private + def self._construct_key_comparator(search_key, object) + search_key = search_key.to_s if defined?(::ActiveSupport) && object.is_a?(::ActiveSupport::HashWithIndifferentAccess) + search_key = search_key.to_s if object.respond_to?(:indifferent_access?) && object.indifferent_access? + + lambda do |non_callable_object| + ->(key, _, _) { key == non_callable_object } + end.call(search_key) + end + def self._deep_locate(comparator, object, result = []) if object.is_a?(::Enumerable) - if object.any? do |value| - if object.is_a?(::Hash) - key, value = value - else - key = nil - end - - comparator.call(key, value, object) - end + if object.any? { |value| _match_comparator?(value, comparator, object) } result.push object else (object.respond_to?(:values) ? object.values : object.entries).each do |value| @@ -89,6 +85,16 @@ result end + + def self._match_comparator?(value, comparator, object) + if object.is_a?(::Hash) + key, value = value + else + key = nil + end + + comparator.call(key, value, object) + end end end end 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 2015-10-25 19:56:06.000000000 +0100 +++ new/lib/hashie/extensions/ignore_undeclared.rb 2016-04-29 18:33:16.000000000 +0200 @@ -30,10 +30,13 @@ # p.email # => NoMethodError 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 self.class.property?(att) || (self.class.respond_to?(:translations) && self.class.translations.include?(att.to_sym)) + next unless klass.property?(att) || (translations && translations.include?(att)) self[att] = value - end if attributes + end 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 2015-10-25 19:56:06.000000000 +0100 +++ new/lib/hashie/extensions/indifferent_access.rb 2016-04-29 18:33:16.000000000 +0200 @@ -133,6 +133,14 @@ self end + def merge(*) + super.convert! + end + + def merge!(*) + super.convert! + end + protected def hash_lacking_indifference?(other) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hashie/extensions/method_access.rb new/lib/hashie/extensions/method_access.rb --- old/lib/hashie/extensions/method_access.rb 2015-10-25 19:56:06.000000000 +0100 +++ new/lib/hashie/extensions/method_access.rb 2016-04-29 18:33:16.000000000 +0200 @@ -107,16 +107,41 @@ # h.hji? # => NoMethodError module MethodQuery def respond_to?(name, include_private = false) - return true if name.to_s =~ /(.*)\?$/ && (key?(Regexp.last_match[1]) || key?(Regexp.last_match[1].to_sym)) - super + if query_method?(name) && indifferent_key?(key_from_query_method(name)) + true + else + super + end end def method_missing(name, *args) - if args.empty? && name.to_s =~ /(.*)\?$/ && (key?(Regexp.last_match[1]) || key?(Regexp.last_match[1].to_sym)) - return self[Regexp.last_match[1]] || self[Regexp.last_match[1].to_sym] + return super unless args.empty? + + if query_method?(name) + key = key_from_query_method(name) + if indifferent_key?(key) + !!(self[key] || self[key.to_sym]) + else + super + end + else + super end + end + + private + + def indifferent_key?(name) + name = name.to_s + key?(name) || key?(name.to_sym) + end + + def key_from_query_method(query_method) + query_method.to_s[0..-2] + end - super + def query_method?(name) + name.to_s.end_with?('?') end 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 2015-10-25 19:56:06.000000000 +0100 +++ new/lib/hashie/mash.rb 2016-04-29 18:33:16.000000000 +0200 @@ -247,7 +247,13 @@ # another ActiveSupport method, see issue #270 def reverse_merge(other_hash) - Hashie::Mash.new(other_hash).merge(self) + self.class.new(other_hash).merge(self) + end + + if RUBY_VERSION >= '2.3.0' + def dig(*keys) + super(*keys.map { |key| convert_key(key) }) + end end protected 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 2015-10-25 19:56:06.000000000 +0100 +++ new/lib/hashie/version.rb 2016-04-29 18:33:16.000000000 +0200 @@ -1,3 +1,3 @@ module Hashie - VERSION = '3.4.3' + VERSION = '3.4.4' end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2015-10-25 19:56:06.000000000 +0100 +++ new/metadata 2016-04-29 18:33:16.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: hashie version: !ruby/object:Gem::Version - version: 3.4.3 + version: 3.4.4 platform: ruby authors: - Michael Bleigh @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2015-10-25 00:00:00.000000000 Z +date: 2016-04-29 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rake @@ -144,7 +144,7 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.4.8 +rubygems_version: 2.4.6 signing_key: specification_version: 4 summary: Your friendly neighborhood hash library. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/hashie/clash_spec.rb new/spec/hashie/clash_spec.rb --- old/spec/hashie/clash_spec.rb 2015-10-25 19:56:06.000000000 +0100 +++ new/spec/hashie/clash_spec.rb 2016-04-29 18:33:16.000000000 +0200 @@ -1,8 +1,6 @@ require 'spec_helper' describe Hashie::Clash do - subject { Hashie::Clash.new } - it 'is able to set an attribute via method_missing' do subject.foo('bar') expect(subject[:foo]).to eq 'bar' @@ -45,4 +43,28 @@ expect(subject[:foo]).to be_nil expect(subject[:hello]).to be_nil end + + it 'merges multiple bang notation calls' do + subject.where!.foo(123) + subject.where!.bar(321) + expect(subject).to eq(where: { foo: 123, bar: 321 }) + end + + it 'raises an exception when method is missing' do + expect { subject.boo }.to raise_error(NoMethodError) + end + + describe 'when inherited' do + subject { Class.new(described_class).new } + + it 'bang nodes are instances of a subclass' do + subject.where!.foo(123) + expect(subject[:where]).to be_instance_of(subject.class) + end + + it 'merged nodes are instances of a subclass' do + subject.where(abc: 'def').where(hgi: 123) + expect(subject[:where]).to be_instance_of(subject.class) + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/hashie/dash_spec.rb new/spec/hashie/dash_spec.rb --- old/spec/hashie/dash_spec.rb 2015-10-25 19:56:06.000000000 +0100 +++ new/spec/hashie/dash_spec.rb 2016-04-29 18:33:16.000000000 +0200 @@ -511,3 +511,26 @@ expect(my_property).to eq(my_orig) end end + +context 'with method access' do + class DashWithMethodAccess < Hashie::Dash + include Hashie::Extensions::IndifferentAccess + include Hashie::Extensions::MethodQuery + + property :test + end + + subject(:dash) { DashWithMethodAccess.new(test: 'value') } + + describe '#test' do + subject { dash.test } + + it { is_expected.to eq('value') } + end + + describe '#test?' do + subject { dash.test? } + + it { is_expected.to eq true } + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/hashie/extensions/coercion_spec.rb new/spec/hashie/extensions/coercion_spec.rb --- old/spec/hashie/extensions/coercion_spec.rb 2015-10-25 19:56:06.000000000 +0100 +++ new/spec/hashie/extensions/coercion_spec.rb 2016-04-29 18:33:16.000000000 +0200 @@ -87,7 +87,7 @@ ] expect(instance[:nested_list]).to be_a Array expect(instance[:nested_list].size).to eq(3) - instance[:nested_list].each do | nested | + instance[:nested_list].each do |nested| test_nested_object nested end end @@ -100,7 +100,7 @@ } expect(instance[:nested_hash]).to be_a Hash expect(instance[:nested_hash].size).to eq(3) - instance[:nested_hash].each do | key, nested | + instance[:nested_hash].each do |key, nested| expect(key).to be_a(String) test_nested_object nested end @@ -251,9 +251,9 @@ xyz: 987 } expect(instance[:foo]).to eq( - 'abc' => '123', - 'xyz' => '987' - ) + 'abc' => '123', + 'xyz' => '987' + ) end it 'can coerce via a proc' do @@ -571,7 +571,7 @@ float: 2.7, rational: Rational(2, 3), complex: Complex(1) - }.each do | k, v | + }.each do |k, v| instance[k] = v if v.is_a? Integer expect(instance[k]).to be_a(String) @@ -592,7 +592,7 @@ float: 2.7, rational: Rational(2, 3), complex: Complex(1) - }.each do | k, v | + }.each do |k, v| instance[k] = v expect(instance[k]).to be_a(String) expect(instance[k]).to eq(v.to_s) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/hashie/extensions/deep_find_spec.rb new/spec/hashie/extensions/deep_find_spec.rb --- old/spec/hashie/extensions/deep_find_spec.rb 2015-10-25 19:56:07.000000000 +0100 +++ new/spec/hashie/extensions/deep_find_spec.rb 2016-04-29 18:33:16.000000000 +0200 @@ -1,4 +1,5 @@ require 'spec_helper' +require 'active_support/core_ext/hash/indifferent_access' describe Hashie::Extensions::DeepFind do subject { Class.new(Hash) { include Hashie::Extensions::DeepFind } } @@ -42,4 +43,71 @@ expect(instance.deep_find_all(:wahoo)).to be_nil end end + + context 'on an ActiveSupport::HashWithIndifferentAccess' do + subject(:instance) { hash.with_indifferent_access.extend(Hashie::Extensions::DeepFind) } + + describe '#deep_find' do + it 'indifferently detects a value from a nested hash' do + expect(instance.deep_find(:address)).to eq('123 Library St.') + expect(instance.deep_find('address')).to eq('123 Library St.') + end + + it 'indifferently detects a value from a nested array' do + expect(instance.deep_find(:title)).to eq('Call of the Wild') + expect(instance.deep_find('title')).to eq('Call of the Wild') + end + + it 'indifferently returns nil if it does not find a match' do + expect(instance.deep_find(:wahoo)).to be_nil + expect(instance.deep_find('wahoo')).to be_nil + end + end + + describe '#deep_find_all' do + it 'indifferently detects all values from a nested hash' do + expect(instance.deep_find_all(:title)).to eq(['Call of the Wild', 'Moby Dick', 'Main Library']) + expect(instance.deep_find_all('title')).to eq(['Call of the Wild', 'Moby Dick', 'Main Library']) + end + + it 'indifferently returns nil if it does not find any matches' do + expect(instance.deep_find_all(:wahoo)).to be_nil + expect(instance.deep_find_all('wahoo')).to be_nil + end + end + end + + context 'on a Hash including Hashie::Extensions::IndifferentAccess' do + let(:klass) { Class.new(Hash) { include Hashie::Extensions::IndifferentAccess } } + subject(:instance) { klass[hash.dup].extend(Hashie::Extensions::DeepFind) } + + describe '#deep_find' do + it 'indifferently detects a value from a nested hash' do + expect(instance.deep_find(:address)).to eq('123 Library St.') + expect(instance.deep_find('address')).to eq('123 Library St.') + end + + it 'indifferently detects a value from a nested array' do + expect(instance.deep_find(:title)).to eq('Call of the Wild') + expect(instance.deep_find('title')).to eq('Call of the Wild') + end + + it 'indifferently returns nil if it does not find a match' do + expect(instance.deep_find(:wahoo)).to be_nil + expect(instance.deep_find('wahoo')).to be_nil + end + end + + describe '#deep_find_all' do + it 'indifferently detects all values from a nested hash' do + expect(instance.deep_find_all(:title)).to eq(['Call of the Wild', 'Moby Dick', 'Main Library']) + expect(instance.deep_find_all('title')).to eq(['Call of the Wild', 'Moby Dick', 'Main Library']) + end + + it 'indifferently returns nil if it does not find any matches' do + expect(instance.deep_find_all(:wahoo)).to be_nil + expect(instance.deep_find_all('wahoo')).to be_nil + end + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/hashie/extensions/deep_locate_spec.rb new/spec/hashie/extensions/deep_locate_spec.rb --- old/spec/hashie/extensions/deep_locate_spec.rb 2015-10-25 19:56:07.000000000 +0100 +++ new/spec/hashie/extensions/deep_locate_spec.rb 2016-04-29 18:33:16.000000000 +0200 @@ -1,4 +1,5 @@ require 'spec_helper' +require 'active_support/core_ext/hash/indifferent_access' describe Hashie::Extensions::DeepLocate do let(:hash) do @@ -121,4 +122,16 @@ expect(instance.deep_locate(:bool)).to eq([hash[:query]]) end end + + context 'on an ActiveSupport::HashWithIndifferentAccess' do + let(:instance) { hash.dup.with_indifferent_access } + + it 'can locate symbolic keys' do + expect(described_class.deep_locate(:lsr10, instance)).to eq ['lsr10' => { 'gte' => 2014 }] + end + + it 'can locate string keys' do + expect(described_class.deep_locate('lsr10', instance)).to eq ['lsr10' => { 'gte' => 2014 }] + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/hashie/extensions/ignore_undeclared_spec.rb new/spec/hashie/extensions/ignore_undeclared_spec.rb --- old/spec/hashie/extensions/ignore_undeclared_spec.rb 2015-10-25 19:56:07.000000000 +0100 +++ new/spec/hashie/extensions/ignore_undeclared_spec.rb 2016-04-29 18:33:16.000000000 +0200 @@ -6,6 +6,7 @@ include Hashie::Extensions::IgnoreUndeclared property :city property :state, from: :provence + property :str_state, from: 'str_provence' end subject { ForgivingTrash } @@ -19,7 +20,7 @@ end it 'works with translated properties (with string keys)' do - expect(subject.new(provence: 'Ontario').state).to eq('Ontario') + expect(subject.new('str_provence' => 'Ontario').str_state).to eq('Ontario') end it 'requires properties to be declared on assignment' do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/hashie/extensions/indifferent_access_spec.rb new/spec/hashie/extensions/indifferent_access_spec.rb --- old/spec/hashie/extensions/indifferent_access_spec.rb 2015-10-25 19:56:07.000000000 +0100 +++ new/spec/hashie/extensions/indifferent_access_spec.rb 2016-04-29 18:33:16.000000000 +0200 @@ -31,6 +31,32 @@ property :foo end + describe '#merge' do + it 'indifferently merges in a hash' do + indifferent_hash = Class.new(::Hash) do + include Hashie::Extensions::IndifferentAccess + end.new + + merged_hash = indifferent_hash.merge(:cat => 'meow') + + expect(merged_hash[:cat]).to eq('meow') + expect(merged_hash['cat']).to eq('meow') + end + end + + describe '#merge!' do + it 'indifferently merges in a hash' do + indifferent_hash = Class.new(::Hash) do + include Hashie::Extensions::IndifferentAccess + end.new + + indifferent_hash.merge!(:cat => 'meow') + + expect(indifferent_hash[:cat]).to eq('meow') + expect(indifferent_hash['cat']).to eq('meow') + end + end + describe 'when included in dash' do let(:params) { { foo: 'bar' } } subject { IndifferentHashWithDash.new(params) } @@ -54,13 +80,13 @@ end it 'returns the same instance of the hash that was set' do - hash = Hash.new + hash = {} h = subject.build(foo: hash) expect(h.values_at(:foo)[0]).to be(hash) end it 'returns the same instance of the array that was set' do - array = Array.new + array = [] h = subject.build(foo: array) expect(h.values_at(:foo)[0]).to be(array) end @@ -86,13 +112,13 @@ end it 'returns the same instance of the hash that was set' do - hash = Hash.new + hash = {} h = subject.build(foo: hash) expect(h.fetch(:foo)).to be(hash) end it 'returns the same instance of the array that was set' do - array = Array.new + array = [] h = subject.build(foo: array) expect(h.fetch(:foo)).to be(array) end @@ -156,7 +182,7 @@ it 'does not change the ancestors of the injected object class' do h.update(baz: { qux: 'abc' }) - expect(Hash.new).not_to be_respond_to(:indifferent_access?) + expect({}).not_to be_respond_to(:indifferent_access?) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/hashie/extensions/indifferent_access_with_rails_hwia_spec.rb new/spec/hashie/extensions/indifferent_access_with_rails_hwia_spec.rb --- old/spec/hashie/extensions/indifferent_access_with_rails_hwia_spec.rb 2015-10-25 19:56:07.000000000 +0100 +++ new/spec/hashie/extensions/indifferent_access_with_rails_hwia_spec.rb 2016-04-29 18:33:16.000000000 +0200 @@ -118,7 +118,7 @@ it 'does not change the ancestors of the injected object class' do h.update(baz: { qux: 'abc' }) - expect(Hash.new).not_to be_respond_to(:indifferent_access?) + expect({}).not_to be_respond_to(:indifferent_access?) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/hashie/extensions/method_access_spec.rb new/spec/hashie/extensions/method_access_spec.rb --- old/spec/hashie/extensions/method_access_spec.rb 2015-10-25 19:56:07.000000000 +0100 +++ new/spec/hashie/extensions/method_access_spec.rb 2016-04-29 18:33:16.000000000 +0200 @@ -92,15 +92,19 @@ subject { QueryHash } it 'is true for non-nil string key values' do - expect(subject.new('abc' => 123)).to be_abc + expect(subject.new('abc' => 123).abc?).to eq true end it 'is true for non-nil symbol key values' do - expect(subject.new(abc: 123)).to be_abc + expect(subject.new(abc: 123).abc?).to eq true + end + + it 'is false for false key values' do + expect(subject.new(abc: false).abc?).to eq false end it 'is false for nil key values' do - expect(subject.new(abc: false)).not_to be_abc + expect(subject.new(abc: nil).abc?).to eq false end it 'raises a NoMethodError for non-set keys' do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/hashie/hash_spec.rb new/spec/hashie/hash_spec.rb --- old/spec/hashie/hash_spec.rb 2015-10-25 19:56:07.000000000 +0100 +++ new/spec/hashie/hash_spec.rb 2016-04-29 18:33:16.000000000 +0200 @@ -8,21 +8,21 @@ end it '#stringify_keys! turns all keys into strings' do - hash = Hashie::Hash[:a => 'hey', 123 => 'bob'] + hash = Hashie::Hash[a: 'hey', 123 => 'bob'] hash.stringify_keys! expect(hash).to eq Hashie::Hash['a' => 'hey', '123' => 'bob'] end it '#stringify_keys! turns all keys into strings recursively' do - hash = Hashie::Hash[:a => 'hey', 123 => { 345 => 'hey' }] + hash = Hashie::Hash[a: 'hey', 123 => { 345 => 'hey' }] hash.stringify_keys! expect(hash).to eq Hashie::Hash['a' => 'hey', '123' => { '345' => 'hey' }] end it '#stringify_keys returns a hash with stringified keys' do - hash = Hashie::Hash[:a => 'hey', 123 => 'bob'] + hash = Hashie::Hash[a: 'hey', 123 => 'bob'] stringified_hash = hash.stringify_keys - expect(hash).to eq Hashie::Hash[:a => 'hey', 123 => 'bob'] + expect(hash).to eq Hashie::Hash[a: 'hey', 123 => 'bob'] expect(stringified_hash).to eq Hashie::Hash['a' => 'hey', '123' => 'bob'] end @@ -41,7 +41,7 @@ it '#to_hash with symbolize_keys set to true returns a hash with symbolized keys' do hash = Hashie::Hash['a' => 'hey', 123 => 'bob', 'array' => [1, 2, 3]] symbolized_hash = hash.to_hash(symbolize_keys: true) - expect(symbolized_hash).to eq(:a => 'hey', :"123" => 'bob', :array => [1, 2, 3]) + expect(symbolized_hash).to eq(a: 'hey', :"123" => 'bob', array: [1, 2, 3]) end it "#to_hash should not blow up when #to_hash doesn't accept arguments" do @@ -78,7 +78,7 @@ it '#to_hash with symbolize_keys set to true returns a hash with symbolized keys' do hash = Hashie::Hash['a' => 'hey', 123 => 'bob', 'array' => [1, 2, 3], subhash: ClassRespondsToHash.new] symbolized_hash = hash.to_hash(symbolize_keys: true) - expect(symbolized_hash).to eq(:a => 'hey', :"123" => 'bob', :array => [1, 2, 3], subhash: { :a => 'hey', :b => 'bar', :'123' => 'bob', :array => [1, 2, 3] }) + expect(symbolized_hash).to eq(a: 'hey', :"123" => 'bob', array: [1, 2, 3], subhash: { a: 'hey', b: 'bar', :'123' => 'bob', array: [1, 2, 3] }) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/hashie/mash_spec.rb new/spec/hashie/mash_spec.rb --- old/spec/hashie/mash_spec.rb 2015-10-25 19:56:07.000000000 +0100 +++ new/spec/hashie/mash_spec.rb 2016-04-29 18:33:16.000000000 +0200 @@ -676,5 +676,25 @@ it 'does not overwrite values' do expect(subject.reverse_merge(a: 5).a).to eq subject.a end + + context 'when using with subclass' do + let(:subclass) { Class.new(Hashie::Mash) } + subject { subclass.new(a: 1) } + + it 'creates an instance of subclass' do + expect(subject.reverse_merge(a: 5)).to be_kind_of(subclass) + end + end + end + + if RUBY_VERSION >= '2.3.0' + describe '#dig' do + subject { described_class.new(a: { b: 1 }) } + + it 'accepts both string and symbol as key' do + expect(subject.dig(:a, :b)).to eq(1) + expect(subject.dig('a', 'b')).to eq(1) + end + end end end
participants (1)
-
root@hilbert.suse.de