synchronisable 1.1.0 → 1.1.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/synchronisable/context.rb +8 -1
- data/lib/synchronisable/locale/en.yml +3 -1
- data/lib/synchronisable/locale/ru.yml +2 -0
- data/lib/synchronisable/source.rb +3 -1
- data/lib/synchronisable/synchronizer.rb +5 -1
- data/lib/synchronisable/version.rb +1 -1
- data/spec/dummy/app/synchronizers/tournament_synchronizer.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: 46e5d5f7aa22b3aba79572bb609e1944e14e5d6d
|
4
|
+
data.tar.gz: 5858c6ad336fa0e59ef3c682d29beb8c0be80aed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e925cf5b4ecf118c8f74dfa0837fde9c9942581826d9d907d88c23b135a6633dce8f6a6ce4a745d7eaa4a18e80ed7adab9f3cb188496e537bac8fbc7fb32f634
|
7
|
+
data.tar.gz: 0d40c8a690b4e03fb8770f63e5d425be912aca8c7bacec78f0f3ec13b40ac6bcb38008a37e3cb7c93ceb4ef6b31b6f19f3dbebe858a7cc568f805e155c384ebe
|
@@ -12,7 +12,7 @@ module Synchronisable
|
|
12
12
|
|
13
13
|
# @return [String] summary synchronization info.
|
14
14
|
def summary_message
|
15
|
-
I18n.t('messages.result',
|
15
|
+
msg = I18n.t('messages.result',
|
16
16
|
:model => model,
|
17
17
|
:parent => @parent.try(:model) || 'nil',
|
18
18
|
:before => before,
|
@@ -20,6 +20,13 @@ module Synchronisable
|
|
20
20
|
:deleted => deleted,
|
21
21
|
:errors => errors.count
|
22
22
|
)
|
23
|
+
|
24
|
+
msg << I18n.t(
|
25
|
+
'messages.errors',
|
26
|
+
:errors => errors.join('. ')
|
27
|
+
) if errors.present?
|
28
|
+
|
29
|
+
msg
|
23
30
|
end
|
24
31
|
end
|
25
32
|
end
|
@@ -12,7 +12,9 @@ en:
|
|
12
12
|
local record: %{local_record}
|
13
13
|
gateway_method_missing: Method %{method} is not implemented for gateway
|
14
14
|
messages:
|
15
|
-
result:
|
15
|
+
result: >
|
16
16
|
parent: %{parent},
|
17
17
|
records before: %{before}, records after: %{after},
|
18
18
|
deleted records: %{deleted}, errors: %{errors}
|
19
|
+
errors: >
|
20
|
+
Errors: %{errors}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'pry-byebug'
|
2
|
+
|
1
3
|
module Synchronisable
|
2
4
|
# TODO: Massive refactoring needed
|
3
5
|
|
@@ -33,12 +35,12 @@ module Synchronisable
|
|
33
35
|
|
34
36
|
@remote_id = @synchronizer.extract_remote_id(@remote_attrs)
|
35
37
|
@local_attrs = @synchronizer.map_attributes(@remote_attrs)
|
38
|
+
@unique_id = @synchronizer.uid(@local_attrs)
|
36
39
|
@associations = @synchronizer.associations_for(@local_attrs)
|
37
40
|
|
38
41
|
@parent_associations = filter_associations(PARENT_ASSOCIATION_KEYS)
|
39
42
|
@child_associations = filter_associations(CHILD_ASSOCIATION_KEYS)
|
40
43
|
|
41
|
-
@unique_id = @local_attrs[@synchronizer.unique_id]
|
42
44
|
@import_record = find_import
|
43
45
|
|
44
46
|
remove_association_keys_from_local_attrs
|
@@ -19,7 +19,7 @@ module Synchronisable
|
|
19
19
|
attribute :remote_id, default: :id
|
20
20
|
|
21
21
|
# The unique id to prevent sync of duplicate records.
|
22
|
-
|
22
|
+
method :unique_id, default: -> (attrs) { nil }
|
23
23
|
|
24
24
|
# Mapping configuration between local model attributes and
|
25
25
|
# its remote counterpart (including id attribute).
|
@@ -123,6 +123,10 @@ module Synchronisable
|
|
123
123
|
data.present? ? data : gateway_instance.try(:find, params)
|
124
124
|
end
|
125
125
|
|
126
|
+
def uid(attrs)
|
127
|
+
unique_id.is_a?(Proc) ? unique_id.(attrs) : attrs[unique_id]
|
128
|
+
end
|
129
|
+
|
126
130
|
# Extracts remote id from given attribute hash.
|
127
131
|
#
|
128
132
|
# @param attrs [Hash] remote attributes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synchronisable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasiliy Yorkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|