embulk-output-google_sheets_ruby 0.1.1 → 0.1.2
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/README.md +9 -0
- data/embulk-output-google_sheets_ruby.gemspec +1 -1
- data/lib/embulk/output/google_sheets_ruby.rb +21 -2
- 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: b82829274f264b8fced2593de323c77cce0af988
|
4
|
+
data.tar.gz: 490ad389c0167776b07cc3f4dedb28b1ea31effe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df2787529b3a7be6f40bedf024737c5d9f8d8a6a57ecbc55952ec9d16836ff8df1ad8f92714524f47a02249afc8ed3402fa81e224b98743e5718c94366cc41b
|
7
|
+
data.tar.gz: 8147c662357ed61a0238a1acf87acfd2ee66ac448361e1819dcd48caf90fe83b1020e24e54d83af4d0cf59f254706fcc2be09f58ee2ea88fefe9bb49a1a134c5
|
data/README.md
CHANGED
@@ -17,6 +17,7 @@ Dumps records to Google Sheets.
|
|
17
17
|
| credentials_path | string | optional | `"credentials.json"` | keyfile path |
|
18
18
|
| range | string | optional | `"A1"` | |
|
19
19
|
| auth_method | string | optional | `service_account` | `service_account` or `authorized_user` |
|
20
|
+
| mode | string | optional | `update` | `update` or `append` |
|
20
21
|
|
21
22
|
##### about credentials_path
|
22
23
|
|
@@ -68,6 +69,14 @@ bundle --path vendor/bundle
|
|
68
69
|
bundle exec ruby example/setup_authorized_user_credentials.rb
|
69
70
|
```
|
70
71
|
|
72
|
+
## mode
|
73
|
+
|
74
|
+
mode can be overwritten or added.
|
75
|
+
Please check the official API reference.
|
76
|
+
|
77
|
+
- `update` : https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update
|
78
|
+
- `append` : https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
|
79
|
+
|
71
80
|
## Build
|
72
81
|
|
73
82
|
```
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = 'embulk-output-google_sheets_ruby'
|
4
|
-
spec.version = '0.1.
|
4
|
+
spec.version = '0.1.2'
|
5
5
|
spec.authors = ['ariarijp']
|
6
6
|
spec.summary = 'Google Sheets Ruby output plugin for Embulk'
|
7
7
|
spec.description = 'Dumps records to Google Sheets.'
|
@@ -18,7 +18,8 @@ module Embulk
|
|
18
18
|
'credentials_path' => config.param('credentials_path',
|
19
19
|
:string,
|
20
20
|
default: 'credentials.json'),
|
21
|
-
'auth_method' => config.param('auth_method', :string, default: 'service_account')
|
21
|
+
'auth_method' => config.param('auth_method', :string, default: 'service_account'),
|
22
|
+
'mode' => config.param('mode', :string, default: 'update')
|
22
23
|
}
|
23
24
|
|
24
25
|
yield(task)
|
@@ -31,6 +32,7 @@ module Embulk
|
|
31
32
|
@credentials_path = task['credentials_path']
|
32
33
|
@range = task['range']
|
33
34
|
@auth_method = task['auth_method']
|
35
|
+
@mode = task['mode']
|
34
36
|
@rows = []
|
35
37
|
@rows << schema.map(&:name)
|
36
38
|
|
@@ -51,7 +53,14 @@ module Embulk
|
|
51
53
|
value_range.major_dimension = 'ROWS'
|
52
54
|
value_range.values = @rows
|
53
55
|
|
54
|
-
|
56
|
+
case @mode
|
57
|
+
when 'update'
|
58
|
+
update_sheet(value_range)
|
59
|
+
when 'append'
|
60
|
+
append_sheet(value_range)
|
61
|
+
else
|
62
|
+
raise ConfigError.new("Unknown mode: #{@mode}")
|
63
|
+
end
|
55
64
|
|
56
65
|
{}
|
57
66
|
end
|
@@ -81,6 +90,16 @@ module Embulk
|
|
81
90
|
value_input_option: 'USER_ENTERED'
|
82
91
|
)
|
83
92
|
end
|
93
|
+
|
94
|
+
def append_sheet(value_range)
|
95
|
+
@service.append_spreadsheet_value(
|
96
|
+
@spreadsheet_id,
|
97
|
+
value_range.range,
|
98
|
+
value_range,
|
99
|
+
value_input_option: 'USER_ENTERED',
|
100
|
+
insert_data_option: 'INSERT_ROWS'
|
101
|
+
)
|
102
|
+
end
|
84
103
|
end
|
85
104
|
end
|
86
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-google_sheets_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ariarijp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|