serialized-hashie 1.0.3 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/package.yml +3 -0
- data/.gitignore +2 -0
- data/lib/serialized_hashie/hash.rb +39 -12
- data/lib/serialized_hashie/version.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 453189d5dcb6f074f9b595cb427c339b44683a047d8226390106f0662ddb92f4
|
4
|
+
data.tar.gz: 9e26fa8420bd8817094d51adc6949bf65204bb9dc9fbc73c1934c7c11a772a00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5173fefd9c87a94ec53d182975fe2ae26371aed4efdcfe5168c5e7b5bd826cc3dd2e87985c309b8c0c8bb2093878557212ef0ff3e4fd9582606af0beaf390b3c
|
7
|
+
data.tar.gz: c66ac14e0de4f89586891a783424d2ca876a72b3145625eb2ed8065a3bd579d8eb5e2d40a86ef78a1c1b48e3a17ed67ecbb3b1cba448689ff2852d5481ba8d0b
|
data/.gitignore
CHANGED
@@ -10,22 +10,13 @@ module SerializedHashie
|
|
10
10
|
class << self
|
11
11
|
|
12
12
|
def dump(obj)
|
13
|
-
|
14
|
-
|
15
|
-
if value.is_a?(Array)
|
16
|
-
obj[key] = value.reject { |v| blank?(v) }
|
17
|
-
end
|
18
|
-
|
19
|
-
obj[key] = SerializedHashie.dump_extensions.run(obj[key])
|
20
|
-
end
|
21
|
-
obj.to_h.to_json
|
13
|
+
hash = dump_hash(obj)
|
14
|
+
hash.to_json
|
22
15
|
end
|
23
16
|
|
24
17
|
def load(raw_hash)
|
25
18
|
hash = JSON.parse(presence(raw_hash) || '{}')
|
26
|
-
hash
|
27
|
-
hash[key] = SerializedHashie.load_extensions.run(value)
|
28
|
-
end
|
19
|
+
hash = load_hash(hash)
|
29
20
|
new(hash)
|
30
21
|
end
|
31
22
|
|
@@ -42,6 +33,42 @@ module SerializedHashie
|
|
42
33
|
blank?(value) ? nil : value
|
43
34
|
end
|
44
35
|
|
36
|
+
def dump_hash(hash)
|
37
|
+
hash = hash.transform_values do |value|
|
38
|
+
dump_value(value)
|
39
|
+
end
|
40
|
+
hash.reject { |_, v| blank?(v) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def dump_value(value)
|
44
|
+
if blank?(value)
|
45
|
+
return nil
|
46
|
+
end
|
47
|
+
|
48
|
+
if value.is_a?(::Hash)
|
49
|
+
return dump_hash(value)
|
50
|
+
end
|
51
|
+
|
52
|
+
if value.is_a?(::Array)
|
53
|
+
return value.map { |v| dump_value(v) }.compact
|
54
|
+
end
|
55
|
+
|
56
|
+
SerializedHashie.dump_extensions.run(value)
|
57
|
+
end
|
58
|
+
|
59
|
+
def load_hash(hash)
|
60
|
+
hash.transform_values do |value|
|
61
|
+
load_value(value)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def load_value(value)
|
66
|
+
return load_hash(value) if value.is_a?(::Hash)
|
67
|
+
return value.map { |v| load_value(v) } if value.is_a?(Array)
|
68
|
+
|
69
|
+
SerializedHashie.load_extensions.run(value)
|
70
|
+
end
|
71
|
+
|
45
72
|
end
|
46
73
|
|
47
74
|
end
|
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
module SerializedHashie
|
4
4
|
|
5
|
-
|
5
|
+
VERSION_FILE_ROOT = File.expand_path('../../VERSION', __dir__)
|
6
|
+
if File.file?(VERSION_FILE_ROOT)
|
7
|
+
VERSION = File.read(VERSION_FILE_ROOT).strip.delete_prefix('v')
|
8
|
+
else
|
9
|
+
VERSION = '0.0.0.dev'
|
10
|
+
end
|
6
11
|
|
7
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serialized-hashie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|