synced 1.7.0 → 2.0.0

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
- SHA1:
3
- metadata.gz: 9d07dc9160fbcc981a1b08e986c8b732768b3912
4
- data.tar.gz: 6ad287a51fd7465e84120d34c230d0359ef7afe1
2
+ SHA256:
3
+ metadata.gz: c2c2e645519782a9d9dd2d17e75c568d9da22740fd72ae1df00378c274db862c
4
+ data.tar.gz: bddae30333bfe7676cf0efccce14d22296988f5a5bcaff40ee5e99bd2fa15054
5
5
  SHA512:
6
- metadata.gz: 0381da8af658da381a11eb0fcc3b2f764a0e90e20c6fb5df03e6fc33d3755c1f39bdd4451c94461779ecb66140e6e60940e71781714ed1cf3431a038344a6c3b
7
- data.tar.gz: 8c30d25d30aebb37edd4f1eb3b331795bce23efbcdda85331468f9c01b220b08ae3c97bac7e25fd9e157329e9816d8c4a1327cf8df2eb66533b7139d39245980
6
+ metadata.gz: 9b7640f5888e65432bb20672b372dae02c2b92a81d48ada3799145526ccc5838f36652843822c872e308f99ec347723b8cbf462adc99db489e0c0bb567219c41
7
+ data.tar.gz: ed40aead1f87fa5f0eb4fa78fe1eead2c936deae3676caa516a31c60c822992d7d0bb3529e58abdd5c160a470af69128846380cb5c4e477443f3ec0f2f98389e
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- [![Code Climate](https://codeclimate.com/github/BookingSync/synced.png)](https://codeclimate.com/github/BookingSync/synced)
2
- [![Build Status](https://travis-ci.org/BookingSync/synced.png?branch=master)](https://travis-ci.org/BookingSync/synced)
1
+ ©[![Code Climate](https://codeclimate.com/github/BookingSync/synced.png)](https://codeclimate.com/github/BookingSync/synced)
2
+ [![Build Status](https://github.com/BookingSync/synced/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/BookingSync/synced/actions/workflows/ci.yml)
3
3
 
4
4
  # Synced
5
5
 
@@ -13,7 +13,7 @@ added/changed/deleted objects since last synchronization.
13
13
 
14
14
  ## Requirements
15
15
 
16
- This engine requires Rails `>= 4.0.0` and Ruby `>= 2.0.0`.
16
+ This engine requires Rails `>= 6.0.0` and Ruby `>= 2.7.0`.
17
17
 
18
18
  ## Installation
19
19
 
@@ -500,6 +500,9 @@ Or as a param in `synchronize` method:
500
500
  Photo.synchronize(transaction_per_page: true)
501
501
  ```
502
502
 
503
+ ## Model Aliasing
504
+ By default `synced` gem will look for an endpoint in BookingSync with the same name as it was defined in. If you want to name your class differently or place it in a namespace, provide endpoint of resource that you want to access with the `endpoint` option. Like so: `synced endpoint: :bookings`.
505
+
503
506
  ## Synced configuration options
504
507
 
505
508
  Option name | Default value | Description | synced | synchronize |
@@ -518,6 +521,7 @@ Option name | Default value | Description
518
521
  `:transaction_per_page` | `false` | [Whether transaction should be per page of fetched objects or for all the pages - note that setting this value to `true` will mean always fetching data in batches, even when specifying `auto_paginate` as true](#persisting-fetched-objects) | YES | YES |
519
522
  `:handle_processed_objects_proc` | `nil` | [Custom proc taking persisted remote objects, called after persisting batch of data](#persisted-objects) | YES | NO |
520
523
  `:tolerance` | 0 | [How many seconds updated_since param should be reduced during request](#syncing-with-offset) | YES | NO |
524
+ `:endpoint` | `table name of the class it was defined in` | endpoint for synchronizeable resource on BookingSync | YES | NO |
521
525
 
522
526
  ## Documentation
523
527
 
data/lib/synced/model.rb CHANGED
@@ -50,13 +50,13 @@ module Synced
50
50
  options.assert_valid_keys(:associations, :data_key, :fields, :globalized_attributes,
51
51
  :id_key, :include, :initial_sync_since, :local_attributes, :mapper, :only_updated,
52
52
  :remove, :auto_paginate, :transaction_per_page, :delegate_attributes, :query_params,
53
- :timestamp_strategy, :handle_processed_objects_proc, :tolerance)
53
+ :timestamp_strategy, :handle_processed_objects_proc, :tolerance, :endpoint)
54
54
  class_attribute :synced_id_key, :synced_data_key,
55
55
  :synced_local_attributes, :synced_associations, :synced_only_updated,
56
56
  :synced_mapper, :synced_remove, :synced_include, :synced_fields, :synced_auto_paginate, :synced_transaction_per_page,
57
57
  :synced_globalized_attributes, :synced_initial_sync_since, :synced_delegate_attributes,
58
58
  :synced_query_params, :synced_timestamp_strategy, :synced_strategy, :synced_handle_processed_objects_proc,
59
- :synced_tolerance
59
+ :synced_tolerance, :synced_endpoint
60
60
  self.synced_strategy = strategy
61
61
  self.synced_id_key = options.fetch(:id_key, :synced_id)
62
62
  self.synced_data_key = options.fetch(:data_key) { synced_column_presence(:synced_data) }
@@ -78,6 +78,7 @@ module Synced
78
78
  self.synced_transaction_per_page = options.fetch(:transaction_per_page, false)
79
79
  self.synced_handle_processed_objects_proc = options.fetch(:handle_processed_objects_proc, nil)
80
80
  self.synced_tolerance = options.fetch(:tolerance, 0).to_i.abs
81
+ self.synced_endpoint = options.fetch(:endpoint) { self.to_s.tableize }
81
82
  include Synced::DelegateAttributes
82
83
  include Synced::HasSyncedData
83
84
  end
@@ -126,7 +127,6 @@ module Synced
126
127
  options[:transaction_per_page] = synced_transaction_per_page unless options.has_key?(:transaction_per_page)
127
128
  options.merge!({
128
129
  scope: scope,
129
- strategy: strategy,
130
130
  id_key: synced_id_key,
131
131
  synced_data_key: synced_data_key,
132
132
  data_key: synced_data_key,
@@ -138,9 +138,10 @@ module Synced
138
138
  initial_sync_since: synced_initial_sync_since,
139
139
  timestamp_strategy: synced_timestamp_strategy,
140
140
  handle_processed_objects_proc: synced_handle_processed_objects_proc,
141
- tolerance: synced_tolerance
141
+ tolerance: synced_tolerance,
142
+ synced_endpoint: synced_endpoint
142
143
  })
143
- Synced::Synchronizer.new(self, options).perform
144
+ Synced::Synchronizer.new(self, strategy: strategy, **options).perform
144
145
  end
145
146
 
146
147
  # Reset last sync timestamp for given scope, this forces synced to sync
@@ -150,12 +151,12 @@ module Synced
150
151
  def reset_synced(scope: scope_from_relation)
151
152
  options = {
152
153
  scope: scope,
153
- strategy: synced_strategy,
154
154
  only_updated: synced_only_updated,
155
155
  initial_sync_since: synced_initial_sync_since,
156
- timestamp_strategy: synced_timestamp_strategy
156
+ timestamp_strategy: synced_timestamp_strategy,
157
+ synced_endpoint: synced_endpoint
157
158
  }
158
- Synced::Synchronizer.new(self, options).reset_synced
159
+ Synced::Synchronizer.new(self, strategy: synced_strategy, **options).reset_synced
159
160
  end
160
161
 
161
162
  private
@@ -172,4 +173,3 @@ module Synced
172
173
  end
173
174
  end
174
175
  end
175
-
@@ -49,6 +49,7 @@ module Synced
49
49
  # of fetched records
50
50
  def initialize(model_class, options = {})
51
51
  @model_class = model_class
52
+ @synced_endpoint = options[:synced_endpoint]
52
53
  @scope = options[:scope]
53
54
  @id_key = options[:id_key]
54
55
  @data_key = options[:data_key]
@@ -198,18 +199,18 @@ module Synced
198
199
  def fetch_and_save_remote_objects(processor)
199
200
  instrument("fetch_remote_objects.synced", model: @model_class) do
200
201
  if @transaction_per_page
201
- api.paginate(resource_name, api_request_options) do |batch|
202
+ api.paginate(@synced_endpoint, api_request_options) do |batch|
202
203
  relation_scope.transaction do
203
204
  processor.call(batch)
204
205
  end
205
206
  end
206
207
  elsif @auto_paginate
207
208
  relation_scope.transaction do
208
- processor.call(api.paginate(resource_name, api_request_options))
209
+ processor.call(api.paginate(@synced_endpoint, api_request_options))
209
210
  end
210
211
  else
211
212
  relation_scope.transaction do
212
- api.paginate(resource_name, api_request_options) do |batch|
213
+ api.paginate(@synced_endpoint, api_request_options) do |batch|
213
214
  processor.call(batch)
214
215
  end
215
216
  end
@@ -1,3 +1,3 @@
1
1
  module Synced
2
- VERSION = "1.7.0"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synced
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Grosjean
8
8
  - Mariusz Pietrzyk
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-27 00:00:00.000000000 Z
12
+ date: 2022-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 4.0.0
20
+ version: '6'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 4.0.0
27
+ version: '6'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bookingsync-api
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 0.1.4
34
+ version: 1.0.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 0.1.4
41
+ version: 1.0.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: hashie
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -222,7 +222,7 @@ homepage: https://github.com/BookingSync/synced
222
222
  licenses:
223
223
  - MIT
224
224
  metadata: {}
225
- post_install_message:
225
+ post_install_message:
226
226
  rdoc_options: []
227
227
  require_paths:
228
228
  - lib
@@ -237,9 +237,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0'
239
239
  requirements: []
240
- rubyforge_project:
241
- rubygems_version: 2.6.14
242
- signing_key:
240
+ rubygems_version: 3.3.26
241
+ signing_key:
243
242
  specification_version: 4
244
243
  summary: Keep your BookingSync Application synced with BookingSync.
245
244
  test_files: []