eternity 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/eternity/patch.rb +32 -20
- data/lib/eternity/version.rb +1 -1
- 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: b0981a07c6d2750de190de34fd06fa69bc36294a
|
4
|
+
data.tar.gz: 48446c1ea896d5d99089ca1b1409d883c666490d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51c887426e9faae2f4c2dbaf51003b24f0afbe5e1e3627fd9a70348163c29484f6ab3ea5f6c0ad6bdb2845549afd6e07c92222ae3f741abd45caf83aeb081fb6
|
7
|
+
data.tar.gz: 98df7c4d6301a44c4a100f1a8517a220bede1ce1af42cd3b3fb7e228266c5a65ff0736335d666711a10bdfb3643ba500ce07e5b6c78dfa719afee85c9a0f5864
|
data/lib/eternity/patch.rb
CHANGED
@@ -45,28 +45,40 @@ module Eternity
|
|
45
45
|
private
|
46
46
|
|
47
47
|
def calculate_delta
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
merged_delta.each_with_object({}) do |(collection, elements), hash|
|
58
|
-
hash[collection] = {}
|
59
|
-
|
60
|
-
elements.each do |id, change|
|
61
|
-
if change['action'] == UPDATE && current_index[collection][id].sha1 == Blob.digest(Blob.serialize(change['data']))
|
62
|
-
change = nil
|
63
|
-
elsif change['action'] == DELETE && !current_index[collection].include?(id)
|
64
|
-
change = nil
|
65
|
-
end
|
66
|
-
hash[collection][id] = change if change
|
48
|
+
if current_commit.nil?
|
49
|
+
target_commit.with_index do |target_index|
|
50
|
+
target_index.each_with_object({}) do |(collection, collection_index), hash|
|
51
|
+
hash[collection] = collection_index.ids.each_with_object({}) do |id, h|
|
52
|
+
h[id] = {
|
53
|
+
'action' => INSERT,
|
54
|
+
'data' => collection_index[id].data
|
55
|
+
}
|
67
56
|
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
else
|
60
|
+
base_commit.with_index do |base_index|
|
61
|
+
current_commit.with_index do |current_index|
|
62
|
+
current_delta = Delta.merge current_history.reverse.map(&:delta)
|
63
|
+
target_delta = Delta.merge target_history.reverse.map(&:delta)
|
64
|
+
revert_delta = Delta.revert current_delta, base_index
|
65
|
+
|
66
|
+
merged_delta = merge_deltas target_delta, revert_delta, base_index
|
67
|
+
|
68
|
+
merged_delta.each_with_object({}) do |(collection, elements), hash|
|
69
|
+
hash[collection] = {}
|
70
|
+
|
71
|
+
elements.each do |id, change|
|
72
|
+
if change['action'] == UPDATE && current_index[collection][id].sha1 == Blob.digest(Blob.serialize(change['data']))
|
73
|
+
change = nil
|
74
|
+
elsif change['action'] == DELETE && !current_index[collection].include?(id)
|
75
|
+
change = nil
|
76
|
+
end
|
77
|
+
hash[collection][id] = change if change
|
78
|
+
end
|
68
79
|
|
69
|
-
|
80
|
+
hash.delete collection if hash[collection].empty?
|
81
|
+
end
|
70
82
|
end
|
71
83
|
end
|
72
84
|
end
|
data/lib/eternity/version.rb
CHANGED
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: 3.0.
|
4
|
+
version: 3.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: 2018-06-
|
11
|
+
date: 2018-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: restruct
|