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: a1d5cf291f00c33bf864785c2bf1b72db5ce0c682292da329aa3bef2cd909df2
4
- data.tar.gz: 0d443a7bdb4304e42c7d065085a2a57c84ca57f6ef16078d6ae318953cd80a42
3
+ metadata.gz: 0e6c1b345c314a734220646b1b777b87eb9dc03c5e83b7523d1315f49ef51334
4
+ data.tar.gz: e90b46d14c40a00fa121e336fc839b9f9d11c6a866f31337400ca14f5ef37b08
5
5
  SHA512:
6
- metadata.gz: 8866d06150921a47bd3b23d3b02f65acb3bc51793f55ff1f0097fe29c969a064ed0f61908b792cd1069366a02c6d3312ca5aecee18ace47321a2f357b964ba92
7
- data.tar.gz: 5ee4d9ef0ecbb4374cd2dab28baa8e22bb9909e45c19499194d34698056f3133de6382c2e095273bc6b6c6c63b7960b185a260ec14de913b0ac6dc94cc4fa2cb
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
- 1 + values.map {|v| v.is_a?(Hash) ? v.depth : 1 }.max
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
  ##============================================================##
@@ -1,3 +1,3 @@
1
1
  module ImmosquareExtensions
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
@@ -3,5 +3,4 @@ require "immosquare-extensions/hash"
3
3
  require "immosquare-extensions/string"
4
4
 
5
5
  module ImmosquareExentions
6
-
7
- end
6
+ end
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.0
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-25 00:00:00.000000000 Z
11
+ date: 2023-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unicode_utils