airtable_sync 1.0.1 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d1acb193baf36f2a13ce8a407f969b6e75069dd21fddf3ed25c40fc65e2eb82
4
- data.tar.gz: de8d079498ae0dd3557818acbb86aa7428e0812f967169c34382e92b6fa940ca
3
+ metadata.gz: 63372f70b76e6a3e677c47ff16b931362c5acd14b535f9ae6d9df25298d267ea
4
+ data.tar.gz: 4e457f78302ea735b01b0709f3d54b121e9e0dfee9bf2a73061fe93412ba477c
5
5
  SHA512:
6
- metadata.gz: 6a07bb6c9ae37b887b3f636c6987e07a865a4cd71e4a29c63069671ae5e94d4553c20dc5fe5c0c7f13ba0bc66412cdeb0502f930192d07928dcbeb2207501bc0
7
- data.tar.gz: 8880ccee15569c4215213143f2320dfc4d3f1886b3ffb8bf38cc44db96e9d1041b00ffaf5d49a6c8315a094fb278a357a58e8a7c44207156bc1e0a4ea581ac22
6
+ metadata.gz: a683ed10cc9c860b81b719c901b984691836a9c973fbc14f0454bc17381974afb6bfc20c44e09923a9d0c12bfe5d3696fd52e00eb86193ec121b04c501a2854e
7
+ data.tar.gz: 25668b3801f6c405c6eca0cfe515acc621a9446d55728ae434d50e64b092e6c25ae836f0fefe97e55e7946c4552ee0934a0d5c91b48833303a39b3575c862548
data/README.md CHANGED
@@ -30,17 +30,13 @@ bundle exec rails generate airtable_sync:install
30
30
 
31
31
  ## Usage
32
32
 
33
- 1. Generate AirTable API key
34
- https://airtable.com/create/apikey
35
- 2.
36
-
37
33
  ### Configuration options
38
34
 
39
35
  In `config/initializers/airtable_sync.rb` you can specify configuration options:
40
36
 
41
- 1. `api_key`
42
- 2. `webflow_site_id`
43
- 3. `skip_airtable_sync` - skip synchronization for different environments.
37
+ 1. `api_key` - In order to use this gem, you need to generate AirTable API key: https://airtable.com/create/apikey
38
+ 2. `airtable_base_id` - you can set `airtable_base_id` here or override `def airtable_base_id` in your model. More on this below.
39
+ 3. `skip_airtable_sync` - if set to `true`, AirtableSync will not sync records to AirTable. This is useful for development and test environments where you don't want to sync records to AirTable.
44
40
 
45
41
  Example:
46
42
 
@@ -51,6 +47,10 @@ AirtableSync.configure do |config|
51
47
  end
52
48
  ```
53
49
 
50
+ ### Create AirTable tables
51
+
52
+ You need to create the AirTable base(s) and table(s) yourself.
53
+
54
54
  ### Add AirtableSync to models
55
55
 
56
56
  For each model that you want to sync to AirTable, you need to run the connection generator:
@@ -61,10 +61,6 @@ bundle exec rails generate airtable_sync:connection Article
61
61
 
62
62
  Please note that this _does not_ create the AirTable table. You need to already have it or create it manually.
63
63
 
64
- ### Create AirTable tables
65
-
66
- As mentioned above, you need to create the AirTable tables yourself.
67
-
68
64
  ### Set `airtable_base_id`
69
65
 
70
66
  There are couple of ways how you can set the `airtable_base_id` to be used.
@@ -79,6 +75,20 @@ AirtableSync.configure do |config|
79
75
  end
80
76
  ```
81
77
 
78
+ #### Set `airtable_base_id` in model
79
+
80
+ ```rb
81
+ # app/models/article.rb
82
+
83
+ class Article < ApplicationRecord
84
+ include AirtableSync::RecordSync
85
+
86
+ def airtable_base_id
87
+ site.airtable_base_id
88
+ end
89
+ end
90
+ ```
91
+
82
92
  ### Customize fields to synchronize
83
93
 
84
94
  By default, AirtableSync calls `#as_airtable_json` on a record to get the fields that it needs to push to AirTable. `#as_airtable_json` simply calls `#as_json` in its default implementation. To change this behavior, you can override `#as_airtable_json` in your model:
@@ -122,10 +132,10 @@ For example:
122
132
  AirtableSync::CreateRecordJob.perform_now('articles', 1, 'Stories')
123
133
  ```
124
134
 
125
- Or, if you want to use the default 'articles' table name:
135
+ Or, if you want to use the default 'Articles' table name:
126
136
 
127
137
  ```ruby
128
- AirtableSync::CreateRecordJob.perform_now('articles', 1)
138
+ AirtableSync::CreateRecordJob.perform_now('articles', 1) # table_name defaults to 'Articles'
129
139
  ```
130
140
 
131
141
  ### Run the initial sync
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AirtableSync
4
- VERSION = '1.0.1'
4
+ VERSION = '1.2.0'
5
5
  end
data/lib/airtable_sync.rb CHANGED
@@ -7,9 +7,3 @@ require 'airrecord'
7
7
 
8
8
  module AirtableSync
9
9
  end
10
-
11
- module Airrecord
12
- class Client
13
- def escape(*args) = ERB::Util.url_encode(*args)
14
- end
15
- end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airtable_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-28 00:00:00.000000000 Z
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: airrecord