embulk-output-google_spreadsheets 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -0
- data/README.md +8 -8
- data/build.gradle +1 -1
- data/src/main/java/org/embulk/output/google_spreadsheets/GoogleSpreadsheetsOutputPlugin.java +17 -15
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc9d14ac105120b4957aea38c2d55b04c92a6e1c
|
4
|
+
data.tar.gz: 47d8da8bc92ab354da600cf44f7f6a2f08ad5e1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ba749b2bcea3a1577b82c26b40ed1099c3d22a6bddb72de531935aaac857a3cbfe28b2fe9fb3e404dc23be15e67b87a6af86067e312a9e411ea842ad0fa44fa
|
7
|
+
data.tar.gz: 67b8204840acc560cdd38e3ec2c2fa821c676716cae8213c8bd192a94363ba44f2b1ee0c447988b0f812b40c2eb0480da98026e749e88325b07292710b60e7f9
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Google Spreadsheets output plugin for Embulk
|
1
|
+
# Google Spreadsheets output plugin for Embulk [![Build Status](https://travis-ci.org/kataring/embulk-output-google_spreadsheets.svg?branch=master)](https://travis-ci.org/kataring/embulk-output-google_spreadsheets) [![Gem Version](https://badge.fury.io/rb/embulk-output-google_spreadsheets.svg)](http://badge.fury.io/rb/embulk-output-google_spreadsheets)
|
2
2
|
|
3
3
|
Embulk output plugin to load into Google Spreadsheets.
|
4
4
|
|
@@ -11,23 +11,23 @@ Embulk output plugin to load into Google Spreadsheets.
|
|
11
11
|
|
12
12
|
## Configuration
|
13
13
|
|
14
|
-
- **
|
15
|
-
- **
|
16
|
-
- **
|
14
|
+
- **service_account_email**: description (string, required)
|
15
|
+
- **p12_keyfile**: description (string, required)
|
16
|
+
- **spreadsheet_id**: description (string, required)
|
17
17
|
|
18
18
|
## Example
|
19
19
|
|
20
20
|
```yaml
|
21
21
|
out:
|
22
22
|
type: google_spreadsheets
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
service_account_email: 'XXXXXXXXXXXXXXXXXXXXXXXX@developer.gserviceaccount.com'
|
24
|
+
p12_keyfile: '/tmp/embulk.p12'
|
25
|
+
spreadsheet_id: '1RPXaB85DXM7sGlpFYIcpoD2GWFpktgh0jBHlF4m1a0A'
|
26
26
|
```
|
27
27
|
|
28
28
|
|
29
29
|
## Build
|
30
30
|
|
31
31
|
```
|
32
|
-
$ ./gradlew gem
|
32
|
+
$ ./gradlew gem
|
33
33
|
```
|
data/build.gradle
CHANGED
data/src/main/java/org/embulk/output/google_spreadsheets/GoogleSpreadsheetsOutputPlugin.java
CHANGED
@@ -39,18 +39,22 @@ public class GoogleSpreadsheetsOutputPlugin
|
|
39
39
|
public interface PluginTask
|
40
40
|
extends Task
|
41
41
|
{
|
42
|
-
@Config("
|
43
|
-
public String
|
42
|
+
@Config("service_account_email")
|
43
|
+
public String getServiceAccountEmail();
|
44
44
|
|
45
|
-
@Config("
|
46
|
-
public String
|
45
|
+
@Config("spreadsheet_id")
|
46
|
+
public String getSpreadsheetId();
|
47
47
|
|
48
|
-
@Config("
|
49
|
-
public String
|
48
|
+
@Config("p12_keyfile")
|
49
|
+
public String getP12Keyfile();
|
50
50
|
|
51
|
-
@Config("
|
51
|
+
@Config("sheet_index")
|
52
52
|
@ConfigDefault("0")
|
53
|
-
public int
|
53
|
+
public int getSheetIndex();
|
54
|
+
|
55
|
+
@Config("application_name")
|
56
|
+
@ConfigDefault("\"Embulk-GoogleSpreadsheets-OutputPlugin\"")
|
57
|
+
public String getApplicationName();
|
54
58
|
}
|
55
59
|
|
56
60
|
private final Logger log;
|
@@ -95,13 +99,12 @@ public class GoogleSpreadsheetsOutputPlugin
|
|
95
99
|
{
|
96
100
|
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
|
97
101
|
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
|
98
|
-
//GoogleClientSecrets secret = GoogleClientSecrets.load(jsonFactory, new FileReader("/tmp/embulk.json"));
|
99
102
|
List<String> scopes = Arrays.asList(DriveScopes.DRIVE, "https://spreadsheets.google.com/feeds");
|
100
103
|
|
101
104
|
return new GoogleCredential.Builder().setTransport(httpTransport)
|
102
105
|
.setJsonFactory(jsonFactory)
|
103
|
-
.setServiceAccountId(task.
|
104
|
-
.setServiceAccountPrivateKeyFromP12File(new File(task.
|
106
|
+
.setServiceAccountId(task.getServiceAccountEmail())
|
107
|
+
.setServiceAccountPrivateKeyFromP12File(new File(task.getP12Keyfile()))
|
105
108
|
.setServiceAccountScopes(scopes)
|
106
109
|
.build();
|
107
110
|
}
|
@@ -125,17 +128,16 @@ public class GoogleSpreadsheetsOutputPlugin
|
|
125
128
|
public GoogleSpreadsheetsPageOutput(PluginTask task) {
|
126
129
|
try {
|
127
130
|
GoogleCredential credentials = getServiceAccountCredential(task);
|
128
|
-
|
129
|
-
service = new SpreadsheetService("embulk-test");
|
131
|
+
service = new SpreadsheetService(task.getApplicationName());
|
130
132
|
service.setProtocolVersion(SpreadsheetService.Versions.V3);
|
131
133
|
service.setOAuth2Credentials(credentials);
|
132
134
|
|
133
|
-
URL entryUrl = new URL("https://spreadsheets.google.com/feeds/spreadsheets/" + task.
|
135
|
+
URL entryUrl = new URL("https://spreadsheets.google.com/feeds/spreadsheets/" + task.getSpreadsheetId());
|
134
136
|
SpreadsheetEntry spreadsheet = service.getEntry(entryUrl, SpreadsheetEntry.class);
|
135
137
|
|
136
138
|
WorksheetFeed worksheetFeed = service.getFeed(spreadsheet.getWorksheetFeedUrl(), WorksheetFeed.class);
|
137
139
|
List<WorksheetEntry> worksheets = worksheetFeed.getEntries();
|
138
|
-
worksheet = worksheets.get(task.
|
140
|
+
worksheet = worksheets.get(task.getSheetIndex());
|
139
141
|
}
|
140
142
|
catch (ServiceException e) {
|
141
143
|
throw new RuntimeException(e);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-google_spreadsheets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noriaki Katayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- .gitignore
|
49
|
+
- .travis.yml
|
49
50
|
- LICENSE.txt
|
50
51
|
- README.md
|
51
52
|
- build.gradle
|
@@ -60,7 +61,7 @@ files:
|
|
60
61
|
- classpath/commons-codec-1.3.jar
|
61
62
|
- classpath/commons-logging-1.1.1.jar
|
62
63
|
- classpath/core-1.47.1.jar
|
63
|
-
- classpath/embulk-output-google_spreadsheets-0.1.
|
64
|
+
- classpath/embulk-output-google_spreadsheets-0.1.1.jar
|
64
65
|
- classpath/google-api-client-1.20.0.jar
|
65
66
|
- classpath/google-api-services-drive-v2-rev184-1.20.0.jar
|
66
67
|
- classpath/google-http-client-1.20.0.jar
|