eternity 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eternity/blob.rb +15 -8
- data/lib/eternity/version.rb +1 -1
- data/spec/blob_spec.rb +18 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9e978f431bd3b4d4ae0fa14c7ca7ed317d36c36
|
4
|
+
data.tar.gz: c7d6711d2a6ccbbbca166f46ad8d9d76dba0a590
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5e5c155ffad8a236a9b90e54e650cd863acf71d43f88f747a818c2611ee37b1ce4871987658f7b2d8337c19cec7912db8ffd6af8880fbd584d7371f8015e765
|
7
|
+
data.tar.gz: 0d984b22b55280b0b7cf124458c9d6a9e8a7f8f95d0c9b5e39801c74af37f7926151fdabe08afb9286250044b81b490dd3968b127fb3e24c35656444d77a724d
|
data/lib/eternity/blob.rb
CHANGED
@@ -41,14 +41,21 @@ module Eternity
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def normalize(data)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
if data.kind_of? Hash
|
45
|
+
sorted_data = Hash[data.sort_by { |k,v| k.to_s }]
|
46
|
+
sorted_data.each { |k,v| sorted_data[k] = normalize v }
|
47
|
+
|
48
|
+
elsif data.kind_of? Array
|
49
|
+
data.map { |v| normalize v }
|
50
|
+
|
51
|
+
elsif data.kind_of? String
|
52
|
+
data.encode 'UTF-8'
|
53
|
+
|
54
|
+
elsif data.respond_to? :utc
|
55
|
+
data.utc.strftime TIME_FORMAT
|
56
|
+
|
57
|
+
else
|
58
|
+
data
|
52
59
|
end
|
53
60
|
end
|
54
61
|
|
data/lib/eternity/version.rb
CHANGED
data/spec/blob_spec.rb
CHANGED
@@ -92,12 +92,24 @@ describe Blob do
|
|
92
92
|
Blob.cache_size.must_equal 0
|
93
93
|
end
|
94
94
|
|
95
|
-
|
96
|
-
time = Time.now
|
97
|
-
data_1 = {key_1: 1, key_2: time}
|
98
|
-
data_2 = {key_2: time.utc.strftime(TIME_FORMAT), key_1: 1}
|
95
|
+
describe 'Normalize serialization' do
|
99
96
|
|
100
|
-
|
101
|
-
|
97
|
+
it 'Sort keys and normalize time' do
|
98
|
+
time = Time.now
|
99
|
+
data_1 = {key_1: 1, key_2: time}
|
100
|
+
data_2 = {key_2: time.utc.strftime(TIME_FORMAT), key_1: 1}
|
101
|
+
|
102
|
+
Blob.serialize(data_1).must_equal Blob.serialize(data_2)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'Normalize string encoding' do
|
106
|
+
string = 'test'
|
107
|
+
data_1 = {key_1: [string], key_2: string.encode('UTF-8')}
|
108
|
+
data_2 = {key_1: [string.encode('ASCII-8BIT')], key_2: string.encode('ASCII-8BIT')}
|
109
|
+
|
110
|
+
Blob.serialize(data_1).must_equal Blob.serialize(data_2)
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
102
114
|
|
103
115
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eternity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: restruct
|