eternity 3.0.0 → 3.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: 3f537658382ba4f3dd470886816e95c83318241b
4
- data.tar.gz: a1adaa2d8cd91bc760752f08d17029ae992bf278
3
+ metadata.gz: b0981a07c6d2750de190de34fd06fa69bc36294a
4
+ data.tar.gz: 48446c1ea896d5d99089ca1b1409d883c666490d
5
5
  SHA512:
6
- metadata.gz: c8da66be778bc5fc98cb9afb69315d239b438ab9cce05e49a75268293ed6c7357f2f1dfa0c6202518757f4ac3316925ccaddc755c42d7c351783df184e4252df
7
- data.tar.gz: 0cd4241e82f74c5d9f87e977847d5a4864d20a003705fb6cde8aa60422182f1eaae88a9fb1ecd13ed121f8cd0509d7f673fb737dde362507ed0702f69ea7f5e0
6
+ metadata.gz: 51c887426e9faae2f4c2dbaf51003b24f0afbe5e1e3627fd9a70348163c29484f6ab3ea5f6c0ad6bdb2845549afd6e07c92222ae3f741abd45caf83aeb081fb6
7
+ data.tar.gz: 98df7c4d6301a44c4a100f1a8517a220bede1ce1af42cd3b3fb7e228266c5a65ff0736335d666711a10bdfb3643ba500ce07e5b6c78dfa719afee85c9a0f5864
@@ -45,28 +45,40 @@ module Eternity
45
45
  private
46
46
 
47
47
  def calculate_delta
48
- base_commit.with_index do |base_index|
49
- current_commit.with_index do |current_index|
50
-
51
- current_delta = Delta.merge current_history.reverse.map(&:delta)
52
- target_delta = Delta.merge target_history.reverse.map(&:delta)
53
- revert_delta = Delta.revert current_delta, base_index
54
-
55
- merged_delta = merge_deltas target_delta, revert_delta, base_index
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
- hash.delete collection if hash[collection].empty?
80
+ hash.delete collection if hash[collection].empty?
81
+ end
70
82
  end
71
83
  end
72
84
  end
@@ -1,3 +1,3 @@
1
1
  module Eternity
2
- VERSION = '3.0.0'
2
+ VERSION = '3.0.1'
3
3
  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: 3.0.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-06 00:00:00.000000000 Z
11
+ date: 2018-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: restruct