Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Ranges on Rash to match all Numerics #184

Merged
merged 1 commit into from
Jul 6, 2014

Conversation

teliosdev
Copy link
Contributor

Previously, it checked only for Integers; unfortunately, that left Floats out, so passing in a float would cause it to look it up normally. This also changes the range checking to cover? instead of include?. Also adds a line to a test to check for float availability.

@bartoszkopinski
Copy link
Member

Hi @medcat,
thanks for this PR. Looks good to me.
cover? is much faster indeed, nice catch.

B.

@@ -34,6 +34,7 @@
expect(subject[250]).to eq 'rangey'
expect(subject[999]).to eq 'rangey'
expect(subject[1000]).to eq 'rangey'
expect(subject[10.1]).to eq 'rangey'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should extract this into a separate test, please.

@dblock
Copy link
Member

dblock commented Jul 6, 2014

This needs a CHANGELOG update (with squash), please. And thank you.

Previously, it checked only for Integers; unfortunately,
that left Floats out, so passing in a float would cause
it to look it up normally.  This also changes the range
checking to `cover?` instead of `include?`.  Also
adds a line to a test to check for float availability.
@dblock
Copy link
Member

dblock commented Jul 6, 2014

Thanks, merging.

dblock added a commit that referenced this pull request Jul 6, 2014
Allow Ranges on Rash to match all Numerics
@dblock dblock merged commit 57f9499 into hashie:master Jul 6, 2014
jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Feb 6, 2015
## 3.4.0 (02/02/2014)

* [#271](hashie/hashie#271): Added ability to define defaults based on current hash - [@gregory](https://github.com/gregory).
* [#247](hashie/hashie#247): Fixed #stringify_keys and #symbolize_keys collision with ActiveSupport - [@bartoszkopinski](https://github.com/bartoszkopinski).
* [#249](hashie/hashie#249): SafeAssignment will now also protect hash-style assignments - [@jrochkind](https://github.com/jrochkind).
* [#251](hashie/hashie#251): Added block support to indifferent access #fetch - [@jgraichen](https://github.com/jgraichen).
* [#252](https://github.com/intridia/hashie/pull/252): Added support for conditionally required Hashie::Dash attributes - [@ccashwell](https://github.com/ccashwell).
* [#256](https://github.com/intridia/hashie/pull/256): Inherit key coercions - [@Erol](https://github.com/Erol).
* [#259](https://github.com/intridia/hashie/pull/259): Fixed handling of default proc values in Mash - [@Erol](https://github.com/Erol).
* [#260](https://github.com/intridia/hashie/pull/260): Added block support to Extensions::DeepMerge - [@Galathius](https://github.com/galathius).
* [#254](hashie/hashie#254): Added public utility methods for stringify and symbolize keys - [@maxlinc](https://github.com/maxlinc).
* [#261](hashie/hashie#261): Fixed bug where Dash.property modifies argument object - [@d_tw](https://github.com/d_tw).
* [#264](hashie/hashie#264): Methods such as abc? return true/false with Hashie::Extensions::MethodReader - [@Zloy](https://github.com/Zloy).
* [#269](hashie/hashie#269): Add #extractable_options? so ActiveSupport Array#extract_options! can extract it - [@ridiculous](https://github.com/ridiculous).
* Your contribution here.

## 3.3.2 (11/26/2014)

* [#233](hashie/hashie#233): Custom error messages for required properties in Hashie::Dash subclasses - [@Joss](https://github.com/joss).
* [#231](hashie/hashie#231): Added support for coercion on class type that inherit from Hash - [@gregory](https://github.com/gregory).
* [#228](hashie/hashie#228): Made Hashie::Extensions::Parsers::YamlErbParser pass template filename to ERB - [@jperville](https://github.com/jperville).
* [#224](hashie/hashie#224): Merging Hashie::Mash now correctly only calls the block on duplicate values - [@amysutedja](https://github.com/amysutedja).
* [#221](hashie/hashie#221): Reduce amount of allocated objects on calls with suffixes in Hashie::Mash - [@kubum](https://github.com/kubum).
* [#245](hashie/hashie#245): Added Hashie::Extensions::MethodAccessWithOverride to autoloads - [@Fritzinger](https://github.com/Fritzinger).

## 3.3.1 (8/26/2014)

* [#183](hashie/hashie#183): Added Mash#load with YAML file support - [@gregory](https://github.com/gregory).
* [#195](hashie/hashie#195): Ensure that the same object is returned after injecting IndifferentAccess - [@michaelherold](https://github.com/michaelherold).
* [#201](hashie/hashie#201): Hashie::Trash transforms can be inherited - [@FoboCasteR](https://github.com/fobocaster).
* [#189](hashie/hashie#189): Added Rash#fetch - [@medcat](https://github.com/medcat).
* [#200](hashie/hashie#200): Improved coercion: primitives and error handling - [@maxlinc](https://github.com/maxlinc).
* [#204](hashie/hashie#204): Added Hashie::Extensions::MethodOverridingWriter and Hashie::Extensions::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).
* [#69](hashie/hashie#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).

## 3.2.0 (7/10/2014)

* [#164](hashie/hashie#164), [#165](hashie/hashie#165), [#166](hashie/hashie#166): Fixed stack overflow when coercing mashes that contain ActiveSupport::HashWithIndifferentAccess values - [@numinit](https://github.com/numinit), [@kgrz](https://github.com/kgrz).
* [#177](hashie/hashie#177): Added support for coercing enumerables and collections - [@gregory](https://github.com/gregory).
* [#179](hashie/hashie#179): Mash#values_at will convert each key before doing the lookup - [@nahiluhmot](https://github.com/nahiluhmot).
* [#184](hashie/hashie#184): Allow ranges on Rash to match all Numeric types - [@medcat](https://github.com/medcat).
* [#187](hashie/hashie#187): Automatically require version - [@medcat](https://github.com/medcat).
* [#190](hashie/hashie#190): Fixed `coerce_key` with `from` Trash feature and Coercion extension - [@gregory](https://github.com/gregory).
* [#192](hashie/hashie#192): Fixed StringifyKeys#stringify_keys! to recursively stringify keys of embedded ::Hash types - [@dblock](https://github.com/dblock).

## 3.1.0 (6/25/2014)

* [#169](hashie/hashie#169): Hash#to_hash will also convert nested objects that implement to_hash - [@gregory](https://github.com/gregory).
* [#171](hashie/hashie#171): Include Trash and Dash class name when raising `NoMethodError` - [@gregory](https://github.com/gregory).
* [#172](hashie/hashie#172): Added Dash and Trash#update_attributes! - [@gregory](https://github.com/gregory).
* [#173](hashie/hashie#173): Auto include Dash::IndifferentAccess when IndiferentAccess is included in Dash - [@gregory](https://github.com/gregory).
* [#174](hashie/hashie#174): Fixed `from` and `transform_with` Trash features when IndifferentAccess is included - [@gregory](https://github.com/gregory).

## 3.0.0 (6/3/2014)

**Note:** This version introduces several backward incompatible API changes. See [UPGRADING](UPGRADING.md) for details.

* [#150](hashie/hashie#159): Handle nil intermediate object on deep fetch - [@stephenaument](https://github.com/stephenaument).
* [#146](hashie/hashie#146): Mash#respond_to? inconsistent with #method_missing and does not respond to #permitted? - [@dblock](https://github.com/dblock).
* [#152](hashie/hashie#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](hashie/hashie#152): Do not automatically stringify keys in Hashie::Hash#to_hash, pass `:stringify_keys` to achieve backward compatible behavior - [@dblock](https://github.com/dblock).
* [#148](hashie/hashie#148): Consolidated Hashie::Hash#stringify_keys implementation - [@dblock](https://github.com/dblock).
* [#149](hashie/hashie#149): Allow IgnoreUndeclared and DeepMerge to be used with undeclared properties - [@jhaesus](https://github.com/jhaesus).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants