ruby-rails-extensions 2.1.0.pre.rc.2 → 2.1.0.pre.rc.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e50d84a162aacc2d390f3c614cbb90eb1ca0dcd300af71f113a90ef32957fa9
|
4
|
+
data.tar.gz: 1fab75f93d14b9fe573bab13b501a5c02392b8cda2dc9d71ebd249b0d0127236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af0f9b3787dbc7e4cada77d4b4c00cbb2e4796a6c0886a0b60a6837bd37c215dbb5e084b6897a230bf1577c2795b9a4ccabab24f02080aa3d16f4485eafe26bd
|
7
|
+
data.tar.gz: 807ed07672397a877bfbede2eebd367dcc816a313e637f25f7e64146910385cbe18104c1ef2763fab20c218323c89ec0565772f3acf2f053a815a93645432129
|
data/CHANGELOG.md
CHANGED
@@ -5,8 +5,9 @@ Unreleased Changes
|
|
5
5
|
------------------
|
6
6
|
|
7
7
|
* Modules added:
|
8
|
-
* `Hash
|
9
|
-
* `Hash
|
8
|
+
* `Hash#nmerge` and `Hash#nmerge!`
|
9
|
+
* `Hash#left_deep_merge` and `Hash#left_deep_merge!`
|
10
|
+
* `Hash#invert_with_dups`
|
10
11
|
|
11
12
|
2.0.1 (2024-07-29)
|
12
13
|
------------------
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Hash.class_eval do
|
4
|
+
# Invert a hash keeping possible duplicate values.
|
5
|
+
# @see Hash#invert for more details or to use without keeping duplicates.
|
6
|
+
# @see https://stackoverflow.com/a/10989394/8806642 for source.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# h = {:a => 1, :b => 2, :c => 3, :d => 4, :z => 1}
|
10
|
+
# h.invert
|
11
|
+
# # => {1=>:z, 2=>:b, 3=>:c, 4=>:d}
|
12
|
+
# h.invert_with_dups
|
13
|
+
# # => {1=>[:a, :z], 2=>[:b], 3=>[:c], 4=>[:d]}
|
14
|
+
#
|
15
|
+
# @return [Hash]
|
16
|
+
#
|
17
|
+
def invert_with_dups
|
18
|
+
each_with_object({}) do |(key, value), out|
|
19
|
+
out[value] ||= []
|
20
|
+
out[value] << key
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-rails-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0.pre.rc.
|
4
|
+
version: 2.1.0.pre.rc.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brands Insurance
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/ruby-rails-extensions/extensions/humanize_symbol.rb
|
65
65
|
- lib/ruby-rails-extensions/extensions/in_utc.rb
|
66
66
|
- lib/ruby-rails-extensions/extensions/input.rb
|
67
|
+
- lib/ruby-rails-extensions/extensions/invert_with_dups.rb
|
67
68
|
- lib/ruby-rails-extensions/extensions/left_deep_merge.rb
|
68
69
|
- lib/ruby-rails-extensions/extensions/month_and_year.rb
|
69
70
|
- lib/ruby-rails-extensions/extensions/month_year.rb
|