immosquare-extensions 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e6c1b345c314a734220646b1b777b87eb9dc03c5e83b7523d1315f49ef51334
|
4
|
+
data.tar.gz: e90b46d14c40a00fa121e336fc839b9f9d11c6a866f31337400ca14f5ef37b08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6690804267f30d222a482bbffd3c47dac59d8d5b21e32f5f375f2e1b4d41938ff8acb80900675e0cf963efca0e931cf2d8851424e2e9378ddfe4b84d159ac628
|
7
|
+
data.tar.gz: bcd8843d0423781c3161035bf3c9f8ebcfa5b7946e69e728e3a5099f4049eb41655e785452d0c7877d9dda73c51c089e063de7c5ef00070d5d8170429ffc029a
|
@@ -20,21 +20,6 @@ class Hash
|
|
20
20
|
cpy
|
21
21
|
end
|
22
22
|
|
23
|
-
##============================================================##
|
24
|
-
## Convert all keys of the hash to lowercase.
|
25
|
-
## If a value is an array, it recursively processes the
|
26
|
-
## nested hash elements.
|
27
|
-
##
|
28
|
-
## Example:
|
29
|
-
## { "A" => { "B" => "value" } }.downcase_key => {"a"=>{"b"=>"value"}}
|
30
|
-
##============================================================##
|
31
|
-
def downcase_key
|
32
|
-
keys.each do |k|
|
33
|
-
store(k.downcase, (v = delete(k)).is_a?(Array) ? v.map(&:downcase_key) : v)
|
34
|
-
end
|
35
|
-
self
|
36
|
-
end
|
37
|
-
|
38
23
|
##============================================================##
|
39
24
|
## Calculate the depth (or level) of nesting within a hash.
|
40
25
|
##
|
@@ -42,11 +27,13 @@ class Hash
|
|
42
27
|
## {a: {b: {c: 1}}}.depth => 3
|
43
28
|
##============================================================##
|
44
29
|
def depth
|
45
|
-
|
30
|
+
return 0 unless any?
|
31
|
+
|
32
|
+
1 + values.map {|v| v.is_a?(Hash) ? v.depth : 0 }.max
|
46
33
|
end
|
47
34
|
|
48
35
|
##============================================================##
|
49
|
-
## Sort a hash by its keys. If the recursive flag is true,
|
36
|
+
## Sort a hash by its keys. If the recursive flag is true,
|
50
37
|
## it will sort nested hashes as well.
|
51
38
|
##
|
52
39
|
## Reference:
|
@@ -63,7 +50,7 @@ class Hash
|
|
63
50
|
end
|
64
51
|
|
65
52
|
##============================================================##
|
66
|
-
## Flatten a nested hash into a single-level hash. Nested keys
|
53
|
+
## Flatten a nested hash into a single-level hash. Nested keys
|
67
54
|
## are represented with dot notation.
|
68
55
|
##
|
69
56
|
## Reference:
|
@@ -78,10 +65,14 @@ class Hash
|
|
78
65
|
v.flatten_hash.map do |h_k, h_v|
|
79
66
|
h["#{k}.#{h_k}".to_sym] = h_v
|
80
67
|
end
|
81
|
-
else
|
68
|
+
else
|
82
69
|
h[k] = v
|
83
70
|
end
|
84
|
-
end
|
71
|
+
end
|
85
72
|
end
|
86
73
|
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
87
78
|
end
|
@@ -24,7 +24,7 @@ class String
|
|
24
24
|
end
|
25
25
|
|
26
26
|
##============================================================##
|
27
|
-
## Provide a custom titleize method to handle strings
|
27
|
+
## Provide a custom titleize method to handle strings
|
28
28
|
## especially ones with hyphens more appropriately.
|
29
29
|
## Standard titleize does not preserve hyphens in the desired manner.
|
30
30
|
##
|
@@ -40,9 +40,9 @@ class String
|
|
40
40
|
end
|
41
41
|
|
42
42
|
##============================================================##
|
43
|
-
## Overriding the standard upcase method to provide a more
|
43
|
+
## Overriding the standard upcase method to provide a more
|
44
44
|
## comprehensive version that correctly handles Unicode characters.
|
45
|
-
##
|
45
|
+
##
|
46
46
|
## Example:
|
47
47
|
## "José".upcase => "JOSÉ"
|
48
48
|
##============================================================##
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immosquare-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IMMO SQUARE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unicode_utils
|