embulk-output-google_sheets_ruby 0.1.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 +7 -0
- data/.gitignore +6 -0
- data/.ruby-version +1 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/Rakefile +3 -0
- data/embulk-output-google_sheets_ruby.gemspec +21 -0
- data/lib/embulk/output/google_sheets_ruby.rb +77 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d69ca03f0c92a37fa74bd5ca901d64d00279fc76b600f65d9126bffc339993a7
|
4
|
+
data.tar.gz: 19a5c30537e2e4b0d5d43dab1455e4c88404d97d8ebabfbfb9b1621168be0436
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01bb9447433ec9d61dd7e5722bf8879f3e503f16c46d95a57bfddc18e1110c22ae285c03cb540afe30cc877d4e8c5d2df4567565ce64716e4aad6fae249d7572
|
7
|
+
data.tar.gz: d5f2bb8960981e2f5724ea593161bd642cd51e72582191b93637c1fb18f12656b20e0ad009bd13faa8999d78ade17d6dc05a21a823f2aad19a8baa902d1a6bcd
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jruby-9.1.15.0
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Google Sheets Ruby output plugin for Embulk
|
2
|
+
|
3
|
+
Dumps records to Google Sheets.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
* **Plugin type**: output
|
8
|
+
* **Load all or nothing**: yes
|
9
|
+
* **Resume supported**: no
|
10
|
+
* **Cleanup supported**: no
|
11
|
+
|
12
|
+
## Configuration
|
13
|
+
|
14
|
+
- **spreadsheet_id**: Spreadsheet ID (string, required)
|
15
|
+
- **credentials_path**: Credentials JSON path (string, default: `"credentials.json"`)
|
16
|
+
|
17
|
+
## Example
|
18
|
+
|
19
|
+
```yaml
|
20
|
+
out:
|
21
|
+
type: google_sheets_ruby
|
22
|
+
spreadsheet_id: YOUR_SPREAD_SHEET_ID
|
23
|
+
credentials_path: /path/to/credentials.json
|
24
|
+
range: A1
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
## Build
|
29
|
+
|
30
|
+
```
|
31
|
+
$ rake
|
32
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = 'embulk-output-google_sheets_ruby'
|
4
|
+
spec.version = '0.1.0'
|
5
|
+
spec.authors = ['ariarijp']
|
6
|
+
spec.summary = 'Google Sheets Ruby output plugin for Embulk'
|
7
|
+
spec.description = 'Dumps records to Google Sheets.'
|
8
|
+
spec.email = ['takuya.arita@gmail.com']
|
9
|
+
spec.licenses = ['MIT']
|
10
|
+
spec.homepage = 'https://github.com/ariarijp/embulk-output-google_sheets_ruby'
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split("\n") + Dir['classpath/*.jar']
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec)/})
|
14
|
+
spec.require_paths = ['lib']
|
15
|
+
|
16
|
+
spec.add_dependency 'google-api-client', '~> 0.8'
|
17
|
+
|
18
|
+
spec.add_development_dependency 'bundler', ['>= 1.10.6']
|
19
|
+
spec.add_development_dependency 'embulk', ['>= 0.8.39']
|
20
|
+
spec.add_development_dependency 'rake', ['>= 10.0']
|
21
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'google/apis/sheets_v4'
|
3
|
+
require 'googleauth'
|
4
|
+
|
5
|
+
APPLICATION_NAME = 'embulk-output-google_sheets_ruby'.freeze
|
6
|
+
SCOPE = Google::Apis::SheetsV4::AUTH_SPREADSHEETS
|
7
|
+
|
8
|
+
module Embulk
|
9
|
+
module Output
|
10
|
+
# Google Sheets Ruby output plugin for Embulk
|
11
|
+
class GoogleSheetsRuby < OutputPlugin
|
12
|
+
Plugin.register_output('google_sheets_ruby', self)
|
13
|
+
|
14
|
+
def self.transaction(config, _schema, _count)
|
15
|
+
task = {
|
16
|
+
'spreadsheet_id' => config.param('spreadsheet_id', :string),
|
17
|
+
'range' => config.param('range', :string, default: 'A1'),
|
18
|
+
'credentials_path' => config.param('credentials_path',
|
19
|
+
:string,
|
20
|
+
default: 'credentials.json')
|
21
|
+
}
|
22
|
+
|
23
|
+
yield(task)
|
24
|
+
|
25
|
+
{}
|
26
|
+
end
|
27
|
+
|
28
|
+
def init
|
29
|
+
@spreadsheet_id = task['spreadsheet_id']
|
30
|
+
@credentials_path = task['credentials_path']
|
31
|
+
@range = task['range']
|
32
|
+
@rows = []
|
33
|
+
@rows << schema.map(&:name)
|
34
|
+
|
35
|
+
@service = Google::Apis::SheetsV4::SheetsService.new
|
36
|
+
@service.client_options.application_name = APPLICATION_NAME
|
37
|
+
@service.authorization = authorize
|
38
|
+
end
|
39
|
+
|
40
|
+
def add(page)
|
41
|
+
page.each do |record|
|
42
|
+
@rows << record
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def commit
|
47
|
+
value_range = Google::Apis::SheetsV4::ValueRange.new
|
48
|
+
value_range.range = @range
|
49
|
+
value_range.major_dimension = 'ROWS'
|
50
|
+
value_range.values = @rows
|
51
|
+
|
52
|
+
update_sheet(value_range)
|
53
|
+
|
54
|
+
{}
|
55
|
+
end
|
56
|
+
|
57
|
+
def authorize
|
58
|
+
authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
|
59
|
+
json_key_io: File.open(@credentials_path),
|
60
|
+
scope: SCOPE
|
61
|
+
)
|
62
|
+
authorizer.fetch_access_token!
|
63
|
+
|
64
|
+
authorizer
|
65
|
+
end
|
66
|
+
|
67
|
+
def update_sheet(value_range)
|
68
|
+
@service.update_spreadsheet_value(
|
69
|
+
@spreadsheet_id,
|
70
|
+
value_range.range,
|
71
|
+
value_range,
|
72
|
+
value_input_option: 'USER_ENTERED'
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-output-google_sheets_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ariarijp
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: google-api-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.10.6
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.10.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: embulk
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.39
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.39
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: Dumps records to Google Sheets.
|
70
|
+
email:
|
71
|
+
- takuya.arita@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".ruby-version"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- embulk-output-google_sheets_ruby.gemspec
|
83
|
+
- lib/embulk/output/google_sheets_ruby.rb
|
84
|
+
homepage: https://github.com/ariarijp/embulk-output-google_sheets_ruby
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.7.6
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Google Sheets Ruby output plugin for Embulk
|
108
|
+
test_files: []
|