hashie 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -2
- data/README.md +49 -48
- data/Rakefile +3 -0
- data/hashie.gemspec +4 -0
- data/lib/hashie/dash.rb +1 -1
- data/lib/hashie/extensions/coercion.rb +1 -8
- data/lib/hashie/extensions/deep_locate.rb +1 -1
- data/lib/hashie/extensions/method_access.rb +1 -1
- data/lib/hashie/mash.rb +10 -14
- data/lib/hashie/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1292246547719e837e23614580afa9f7a86f5289f2853f7ea357ec2f47865b0e
|
|
4
|
+
data.tar.gz: 31ef91ffd52a01456dc265d5905a40a7dde661034ffc6df70fc1f3e946be3889
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 183d5309171cd3adb28decf8295cb08c47566d1ae7a551a94e4a77a9a9395d26f2e46bfac0b1ebf39744ae5f43249debec7a96b061c3cef5293df36c5991317a
|
|
7
|
+
data.tar.gz: b4124bd8447025f7be8bd8f4d7f19f29e209dc4f7ac2829feda89182cbe38bfa571ffa525ac3a1dd9487ee89dd9caa26c12988e328877b79b184217cf1d4c03e
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
Any violations of this scheme are considered to be bugs.
|
|
8
8
|
|
|
9
|
+
## [5.1.0] - 2025-12-24
|
|
10
|
+
|
|
11
|
+
[5.1.0]: https://github.com/hashie/hashie/compare/v5.0.0...v5.1.0
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
* [#569](https://github.com/hashie/hashie/pull/569): Added support for Rails 7 - [@aflansburg](https://github.com/aflansburg).
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
* [#571](https://github.com/hashie/hashie/pull/571): Test with Ruby 3.2 - [@petergoldstein](https://github.com/petergoldstein).
|
|
20
|
+
* [#558](https://github.com/hashie/hashie/pull/558): Test with Ruby 3.1 - [@petergoldstein](https://github.com/petergoldstein).
|
|
21
|
+
* [#582](https://github.com/hashie/hashie/pull/582): Test with Ruby 3.3 and 3.4 - [@btalayeminaei](https://github.com/btalayeminaei).
|
|
22
|
+
* [#589](https://github.com/hashie/hashie/pull/589): Requires Ruby 2.7+ and upgraded Rubocop to 1.82.0 - [@sue445](https://github.com/sue445).
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
* [#583](https://github.com/hashie/hashie/pull/583): Fix a warning about the `logger` gem on Ruby 3.4 - [@earlopain](https://github.com/earlopain).
|
|
27
|
+
|
|
9
28
|
## [5.0.0] - 2021-11-08
|
|
10
29
|
|
|
11
30
|
[5.0.0]: https://github.com/hashie/hashie/compare/v4.1.0...v5.0.0
|
|
@@ -154,7 +173,7 @@ Any violations of this scheme are considered to be bugs.
|
|
|
154
173
|
|
|
155
174
|
### Fixed
|
|
156
175
|
|
|
157
|
-
* [#409](https://github.com/hashie/hashie/pull/409): Fixed Railtie detection for projects where Rails is defined but Railties are not
|
|
176
|
+
* [#409](https://github.com/hashie/hashie/pull/409): Fixed Railtie detection for projects where Rails is defined but Railties are not available - [@CallumD](https://github.com/callumd).
|
|
158
177
|
* [#411](https://github.com/hashie/hashie/pull/411): Fixed a performance regression from 3.4.3 that caused a 10x slowdown in OmniAuth - [@michaelherold](https://github.com/michaelherold).
|
|
159
178
|
|
|
160
179
|
## [3.5.3] - 2017-02-11
|
|
@@ -433,7 +452,7 @@ Any violations of this scheme are considered to be bugs.
|
|
|
433
452
|
|
|
434
453
|
### Fixed
|
|
435
454
|
|
|
436
|
-
* [#131](https://github.com/hashie/hashie/pull/131): Added IgnoreUndeclared, an extension to silently ignore undeclared properties at
|
|
455
|
+
* [#131](https://github.com/hashie/hashie/pull/131): Added IgnoreUndeclared, an extension to silently ignore undeclared properties at initialization - [@righi](https://github.com/righi).
|
|
437
456
|
* [#138](https://github.com/hashie/hashie/pull/138): Added Hashie::Rash, a hash whose keys can be regular expressions or ranges - [@epitron](https://github.com/epitron).
|
|
438
457
|
* [#144](https://github.com/hashie/hashie/issues/144): Fixed regression invoking `to_hash` with no parameters - [@mbleigh](https://github.com/mbleigh).
|
|
439
458
|
|
data/README.md
CHANGED
|
@@ -2,55 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://gitter.im/hashie/hashie?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
4
4
|
[](http://badge.fury.io/rb/hashie)
|
|
5
|
-
[](https://github.com/hashie/hashie/actions/workflows/test.yml)
|
|
6
6
|
|
|
7
7
|
[](#mascot) Hashie is a growing collection of tools that extend Hashes and make them more useful.
|
|
8
8
|
|
|
9
9
|
# Table of Contents
|
|
10
10
|
|
|
11
|
-
- [
|
|
12
|
-
- [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- [
|
|
35
|
-
- [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
- [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- [Contributing](#contributing)
|
|
53
|
-
- [Copyright](#copyright)
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Stable Release](#stable-release)
|
|
13
|
+
- [Hash Extensions](#hash-extensions)
|
|
14
|
+
- [Logging](#logging)
|
|
15
|
+
- [Coercion](#coercion)
|
|
16
|
+
- [Coercing Collections](#coercing-collections)
|
|
17
|
+
- [Coercing Hashes](#coercing-hashes)
|
|
18
|
+
- [Coercing Core Types](#coercing-core-types)
|
|
19
|
+
- [Coercion Proc](#coercion-proc)
|
|
20
|
+
- [A note on circular coercion](#a-note-on-circular-coercion)
|
|
21
|
+
- [KeyConversion](#keyconversion)
|
|
22
|
+
- [MergeInitializer](#mergeinitializer)
|
|
23
|
+
- [MethodAccess](#methodaccess)
|
|
24
|
+
- [MethodAccessWithOverride](#methodaccesswithoverride)
|
|
25
|
+
- [MethodOverridingInitializer](#methodoverridinginitializer)
|
|
26
|
+
- [IndifferentAccess](#indifferentaccess)
|
|
27
|
+
- [IgnoreUndeclared](#ignoreundeclared)
|
|
28
|
+
- [DeepMerge](#deepmerge)
|
|
29
|
+
- [DeepFetch](#deepfetch)
|
|
30
|
+
- [DeepFind](#deepfind)
|
|
31
|
+
- [DeepLocate](#deeplocate)
|
|
32
|
+
- [StrictKeyAccess](#strictkeyaccess)
|
|
33
|
+
- [Mash](#mash)
|
|
34
|
+
- [KeepOriginalKeys](#keeporiginalkeys)
|
|
35
|
+
- [PermissiveRespondTo](#permissiverespondto)
|
|
36
|
+
- [SafeAssignment](#safeassignment)
|
|
37
|
+
- [SymbolizeKeys](#symbolizekeys)
|
|
38
|
+
- [DefineAccessors](#defineaccessors)
|
|
39
|
+
- [Dash](#dash)
|
|
40
|
+
- [Potential Gotchas](#potential-gotchas)
|
|
41
|
+
- [PropertyTranslation](#propertytranslation)
|
|
42
|
+
- [Mash and Rails 4 Strong Parameters](#mash-and-rails-4-strong-parameters)
|
|
43
|
+
- [Coercion](#coercion-1)
|
|
44
|
+
- [PredefinedValues](#predefinedvalues)
|
|
45
|
+
- [Trash](#trash)
|
|
46
|
+
- [Clash](#clash)
|
|
47
|
+
- [Rash](#rash)
|
|
48
|
+
- [Auto-Optimized](#auto-optimized)
|
|
49
|
+
- [Mascot](#mascot)
|
|
50
|
+
- [Contributing](#contributing)
|
|
51
|
+
- [Copyright](#copyright)
|
|
54
52
|
|
|
55
53
|
## Installation
|
|
56
54
|
|
|
@@ -62,7 +60,7 @@ $ gem install hashie
|
|
|
62
60
|
|
|
63
61
|
## Stable Release
|
|
64
62
|
|
|
65
|
-
You're reading the documentation for the stable release of Hashie,
|
|
63
|
+
You're reading the documentation for the stable release of Hashie, 5.1.0.
|
|
66
64
|
|
|
67
65
|
## Hash Extensions
|
|
68
66
|
|
|
@@ -627,7 +625,7 @@ my_gem.dependencies.class #=> MyGem
|
|
|
627
625
|
|
|
628
626
|
_How does Mash handle key types which cannot be symbolized?_
|
|
629
627
|
|
|
630
|
-
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
|
|
628
|
+
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 pseudo-object functionality, handling keys which cannot represent a method call falls outside its scope of value.
|
|
631
629
|
|
|
632
630
|
```ruby
|
|
633
631
|
Hashie::Mash.new('1' => 'one string', :'1' => 'one sym', 1 => 'one num')
|
|
@@ -811,7 +809,7 @@ mash = ::Hashie::Mash.new.with_accessors!
|
|
|
811
809
|
|
|
812
810
|
## Dash
|
|
813
811
|
|
|
814
|
-
Dash is an extended Hash that has a discrete set of defined properties and only those properties may be set on the hash. Additionally, you can set defaults for each property. You can also flag a property as required. Required properties will raise an exception if unset. Another option is message for required properties, which allow you to add custom messages for required property.
|
|
812
|
+
Dash is an extended Hash that has a discrete set of defined properties and only those properties may be set on the hash. Additionally, you can set defaults for each property. You can also flag a property as required. Required properties will raise an exception if unset. Another option is message for required properties, which allow you to add custom messages for required property. A property with a proc value will be evaluated lazily upon retrieval.
|
|
815
813
|
|
|
816
814
|
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.
|
|
817
815
|
|
|
@@ -823,6 +821,7 @@ class Person < Hashie::Dash
|
|
|
823
821
|
property :phone, required: -> { email.nil? }, message: 'is required if email is not set.'
|
|
824
822
|
property :pants, required: :weekday?, message: 'are only required on weekdays.'
|
|
825
823
|
property :occupation, default: 'Rubyist'
|
|
824
|
+
property :genome
|
|
826
825
|
|
|
827
826
|
def weekday?
|
|
828
827
|
[ Time.now.saturday?, Time.now.sunday? ].none?
|
|
@@ -847,6 +846,8 @@ p.occupation # => 'Evil'
|
|
|
847
846
|
p.name # => 'Trudy'
|
|
848
847
|
p.update_attributes!(occupation: nil)
|
|
849
848
|
p.occupation # => 'Rubyist'
|
|
849
|
+
p.genome = -> { Genome.sequence } # Some expensive operation
|
|
850
|
+
p.genome # => 'GATTACA'
|
|
850
851
|
```
|
|
851
852
|
|
|
852
853
|
Properties defined as symbols are not the same thing as properties defined as strings.
|
|
@@ -1104,7 +1105,7 @@ mapper["Get off my lawn!"] # => "Forget your lawn, old man!"
|
|
|
1104
1105
|
If this value is too low or too high for your needs, you can tune it by setting: `rash.optimize_every = n`.
|
|
1105
1106
|
|
|
1106
1107
|
## Mascot
|
|
1107
|
-
[](https://en.wiktionary.org/wiki/eierlegende_Wollmilchsau) Meet Hashie's "
|
|
1108
|
+
[](https://en.wiktionary.org/wiki/eierlegende_Wollmilchsau) Meet Hashie's "official" mascot, the [eierlegende Wollmilchsau](https://en.wiktionary.org/wiki/eierlegende_Wollmilchsau)!
|
|
1108
1109
|
|
|
1109
1110
|
## Contributing
|
|
1110
1111
|
|
data/Rakefile
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'rubygems'
|
|
2
4
|
require 'bundler'
|
|
3
5
|
Bundler.setup
|
|
@@ -16,6 +18,7 @@ RuboCop::RakeTask.new(:rubocop)
|
|
|
16
18
|
require_relative 'spec/support/integration_specs'
|
|
17
19
|
task :integration_specs do
|
|
18
20
|
next if ENV['CI']
|
|
21
|
+
|
|
19
22
|
status_codes = []
|
|
20
23
|
handler = lambda do |status_code|
|
|
21
24
|
status_codes << status_code unless status_code.zero?
|
data/hashie.gemspec
CHANGED
data/lib/hashie/dash.rb
CHANGED
|
@@ -10,7 +10,7 @@ module Hashie
|
|
|
10
10
|
# lightweight data object that needs even fewer options and
|
|
11
11
|
# resources than something like a DataMapper resource.
|
|
12
12
|
#
|
|
13
|
-
# It is
|
|
13
|
+
# It is preferable to a Struct because of the in-class
|
|
14
14
|
# API for defining properties as well as per-property defaults.
|
|
15
15
|
class Dash < Hash
|
|
16
16
|
include Hashie::Extensions::PrettyInspect
|
|
@@ -17,14 +17,7 @@ module Hashie
|
|
|
17
17
|
}.freeze
|
|
18
18
|
|
|
19
19
|
ABSTRACT_CORE_TYPES =
|
|
20
|
-
|
|
21
|
-
{ Numeric => [Integer, Float, Complex, Rational] }
|
|
22
|
-
else
|
|
23
|
-
{
|
|
24
|
-
Integer => [Fixnum, Bignum],
|
|
25
|
-
Numeric => [Fixnum, Bignum, Float, Complex, Rational]
|
|
26
|
-
}
|
|
27
|
-
end
|
|
20
|
+
{ Numeric => [Integer, Float, Complex, Rational] }
|
|
28
21
|
|
|
29
22
|
def self.included(base)
|
|
30
23
|
base.send :include, InstanceMethods
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Hashie
|
|
2
2
|
module Extensions
|
|
3
3
|
module DeepLocate
|
|
4
|
-
# The module level implementation of #deep_locate,
|
|
4
|
+
# The module level implementation of #deep_locate, in case you do not want
|
|
5
5
|
# to include/extend the base datastructure. For further examples please
|
|
6
6
|
# see #deep_locate.
|
|
7
7
|
#
|
|
@@ -241,7 +241,7 @@ module Hashie
|
|
|
241
241
|
end
|
|
242
242
|
|
|
243
243
|
# MethodOverridingInitializer allows you to override default hash
|
|
244
|
-
# methods when passing in values from an existing hash. The
|
|
244
|
+
# methods when passing in values from an existing hash. The overridden
|
|
245
245
|
# methods are aliased with two leading underscores.
|
|
246
246
|
#
|
|
247
247
|
# @example
|
data/lib/hashie/mash.rb
CHANGED
|
@@ -21,7 +21,7 @@ module Hashie
|
|
|
21
21
|
# * Bang (<tt>!</tt>): Forces the existence of this key, used for deep Mashes. Think of it
|
|
22
22
|
# as "touch" for mashes.
|
|
23
23
|
# * Under Bang (<tt>_</tt>): Like Bang, but returns a new Mash rather than creating a key.
|
|
24
|
-
# Used to test
|
|
24
|
+
# Used to test existence in deep Mashes.
|
|
25
25
|
#
|
|
26
26
|
# == Basic Example
|
|
27
27
|
#
|
|
@@ -322,22 +322,18 @@ module Hashie
|
|
|
322
322
|
self.class.new(other_hash).merge(self)
|
|
323
323
|
end
|
|
324
324
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
super(*keys.map { |key| convert_key(key) })
|
|
328
|
-
end
|
|
325
|
+
def dig(*keys)
|
|
326
|
+
super(*keys.map { |key| convert_key(key) })
|
|
329
327
|
end
|
|
330
328
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
end
|
|
329
|
+
def transform_values(&blk)
|
|
330
|
+
self.class.new(super(&blk))
|
|
331
|
+
end
|
|
335
332
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
end
|
|
333
|
+
# Returns a new instance of the class it was called on, with nil values
|
|
334
|
+
# removed.
|
|
335
|
+
def compact
|
|
336
|
+
self.class.new(super)
|
|
341
337
|
end
|
|
342
338
|
|
|
343
339
|
with_minimum_ruby('2.5.0') do
|
data/lib/hashie/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hashie
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Bleigh
|
|
@@ -9,8 +9,22 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2025-12-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: logger
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - ">="
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '0'
|
|
21
|
+
type: :runtime
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '0'
|
|
14
28
|
- !ruby/object:Gem::Dependency
|
|
15
29
|
name: bundler
|
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -98,14 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
98
112
|
requirements:
|
|
99
113
|
- - ">="
|
|
100
114
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: '
|
|
115
|
+
version: '2.7'
|
|
102
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
117
|
requirements:
|
|
104
118
|
- - ">="
|
|
105
119
|
- !ruby/object:Gem::Version
|
|
106
120
|
version: '0'
|
|
107
121
|
requirements: []
|
|
108
|
-
rubygems_version: 3.
|
|
122
|
+
rubygems_version: 3.5.16
|
|
109
123
|
signing_key:
|
|
110
124
|
specification_version: 4
|
|
111
125
|
summary: Your friendly neighborhood hash library.
|