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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 280de802ac46bd98ca727a3cec0e50c8b3b37e30
4
- data.tar.gz: 2f0a2a057a5e74620a7ae526cdec1d57db7dd127
3
+ metadata.gz: f9e978f431bd3b4d4ae0fa14c7ca7ed317d36c36
4
+ data.tar.gz: c7d6711d2a6ccbbbca166f46ad8d9d76dba0a590
5
5
  SHA512:
6
- metadata.gz: dd1ecf427b65d0476191f70521b4016361da409f3edf8ceab106b6ee04a3837f35cd704f70ce2b71a18fea4b43d70913ae3580e0f0ba21b24fd6f97f0573f9a8
7
- data.tar.gz: ce04fba46ee3ed7bbcafab7327030576499a69afd31214c64ea83944c1ec6024fa886ba9a700c386e5791bb660eb9efa159f067cb8902ef2616aeabb364757bc
6
+ metadata.gz: e5e5c155ffad8a236a9b90e54e650cd863acf71d43f88f747a818c2611ee37b1ce4871987658f7b2d8337c19cec7912db8ffd6af8880fbd584d7371f8015e765
7
+ data.tar.gz: 0d984b22b55280b0b7cf124458c9d6a9e8a7f8f95d0c9b5e39801c74af37f7926151fdabe08afb9286250044b81b490dd3968b127fb3e24c35656444d77a724d
@@ -41,14 +41,21 @@ module Eternity
41
41
  end
42
42
 
43
43
  def normalize(data)
44
- case data
45
- when Hash
46
- sorted_data = Hash[data.sort_by { |k,v| k.to_s }]
47
- sorted_data.each { |k,v| sorted_data[k] = v.utc.strftime TIME_FORMAT if v.respond_to? :utc }
48
- when Array
49
- data.map { |d| normalize d }
50
- else
51
- data
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
 
@@ -1,3 +1,3 @@
1
1
  module Eternity
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
@@ -92,12 +92,24 @@ describe Blob do
92
92
  Blob.cache_size.must_equal 0
93
93
  end
94
94
 
95
- it 'Normalize serialization' do
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
- Blob.serialize(data_1).must_equal Blob.serialize(data_2)
101
- end
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.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: 2017-09-18 00:00:00.000000000 Z
11
+ date: 2018-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: restruct