embulk-output-google_spreadsheets 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +14 -3
- data/build.gradle +1 -1
- data/src/main/java/org/embulk/output/google_spreadsheets/GoogleSpreadsheetsOutputPlugin.java +49 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e147a98084a075ff73b0c616d7795508b46627c4
|
4
|
+
data.tar.gz: ff7b12e9cd4613ce1a59f675f79c69e11741e6a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6262b0076d02dbe010f2c5c0ff0d217a0df0658d893f82fdec9f4a64aeefd8fe2e1f4c8f4b5e731c1aaf65fac5d4de70a8856a27e0ef6038f51371d9c1ef5b7
|
7
|
+
data.tar.gz: f2674419e96d00c2b28da5c493274a18578725322422d0f4a0e4c3f172bf3e04c34dd978bdbbb24fd624830893eeaa17cf138a1565e62b701046c3c0c689d6ba
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -9,11 +9,22 @@ Embulk output plugin to load into Google Spreadsheets.
|
|
9
9
|
* **Resume supported**: no
|
10
10
|
* **Cleanup supported**: yes
|
11
11
|
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
### Install plugin
|
15
|
+
|
16
|
+
```
|
17
|
+
embulk gem install embulk-output-google_spreadsheets
|
18
|
+
```
|
19
|
+
|
20
|
+
|
12
21
|
## Configuration
|
13
22
|
|
14
|
-
- **service_account_email**:
|
15
|
-
- **p12_keyfile**:
|
16
|
-
- **spreadsheet_id**:
|
23
|
+
- **service_account_email**: Your Google service account email (string, required)
|
24
|
+
- **p12_keyfile**: Fullpath of private key in P12(PKCS12) format (string, required)
|
25
|
+
- **spreadsheet_id**: Your spreadsheet id (string, required)
|
26
|
+
- **sheet_index**: sheet index (int, optional default: 0)
|
27
|
+
- **application_name**: Anything you like (string, optional defaulf: "Embulk-GoogleSpreadsheets-OutputPlugin")
|
17
28
|
|
18
29
|
## Example
|
19
30
|
|
data/build.gradle
CHANGED
data/src/main/java/org/embulk/output/google_spreadsheets/GoogleSpreadsheetsOutputPlugin.java
CHANGED
@@ -30,6 +30,10 @@ import java.io.File;
|
|
30
30
|
import java.net.URL;
|
31
31
|
import java.util.List;
|
32
32
|
import java.util.Arrays;
|
33
|
+
import org.embulk.spi.time.Timestamp;
|
34
|
+
import org.joda.time.DateTimeZone;
|
35
|
+
import org.joda.time.format.DateTimeFormat;
|
36
|
+
import org.joda.time.format.DateTimeFormatter;
|
33
37
|
import org.slf4j.Logger;
|
34
38
|
import java.security.GeneralSecurityException;
|
35
39
|
|
@@ -55,6 +59,10 @@ public class GoogleSpreadsheetsOutputPlugin
|
|
55
59
|
@Config("application_name")
|
56
60
|
@ConfigDefault("\"Embulk-GoogleSpreadsheets-OutputPlugin\"")
|
57
61
|
public String getApplicationName();
|
62
|
+
|
63
|
+
@Config("default_timezone")
|
64
|
+
@ConfigDefault("\"UTC\"")
|
65
|
+
public String getDefaultTimezone();
|
58
66
|
}
|
59
67
|
|
60
68
|
private final Logger log;
|
@@ -124,6 +132,7 @@ public class GoogleSpreadsheetsOutputPlugin
|
|
124
132
|
private SpreadsheetService service;
|
125
133
|
private WorksheetEntry worksheet;
|
126
134
|
private ListEntry row;
|
135
|
+
private DateTimeFormatter formatter;
|
127
136
|
|
128
137
|
public GoogleSpreadsheetsPageOutput(PluginTask task) {
|
129
138
|
try {
|
@@ -138,6 +147,9 @@ public class GoogleSpreadsheetsOutputPlugin
|
|
138
147
|
WorksheetFeed worksheetFeed = service.getFeed(spreadsheet.getWorksheetFeedUrl(), WorksheetFeed.class);
|
139
148
|
List<WorksheetEntry> worksheets = worksheetFeed.getEntries();
|
140
149
|
worksheet = worksheets.get(task.getSheetIndex());
|
150
|
+
|
151
|
+
DateTimeZone zone = DateTimeZone.forID(task.getDefaultTimezone());
|
152
|
+
formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZone(zone);
|
141
153
|
}
|
142
154
|
catch (ServiceException e) {
|
143
155
|
throw new RuntimeException(e);
|
@@ -167,32 +179,59 @@ public class GoogleSpreadsheetsOutputPlugin
|
|
167
179
|
pageReader.getSchema().visitColumns(new ColumnVisitor() {
|
168
180
|
@Override
|
169
181
|
public void booleanColumn(Column column) {
|
170
|
-
|
171
|
-
|
182
|
+
if (pageReader.isNull(column)) {
|
183
|
+
log.debug("booleanColumn: null");
|
184
|
+
row.getCustomElements().setValueLocal(column.getName(), "");
|
185
|
+
} else {
|
186
|
+
log.debug("booleanColumn: " + pageReader.getBoolean(column));
|
187
|
+
row.getCustomElements().setValueLocal(column.getName(), (pageReader.getBoolean(column) ? "true" : "false"));
|
188
|
+
}
|
172
189
|
}
|
173
190
|
|
174
191
|
@Override
|
175
192
|
public void longColumn(Column column) {
|
176
|
-
|
177
|
-
|
193
|
+
if (pageReader.isNull(column)) {
|
194
|
+
log.debug("longColumn: null");
|
195
|
+
row.getCustomElements().setValueLocal(column.getName(), "");
|
196
|
+
} else {
|
197
|
+
log.debug("longColumn: " + pageReader.getLong(column));
|
198
|
+
row.getCustomElements().setValueLocal(column.getName(), Long.toString(pageReader.getLong(column)));
|
199
|
+
}
|
178
200
|
}
|
179
201
|
|
180
202
|
@Override
|
181
203
|
public void doubleColumn(Column column) {
|
182
|
-
|
183
|
-
|
204
|
+
if (pageReader.isNull(column)) {
|
205
|
+
log.debug("doubleColumn: null");
|
206
|
+
row.getCustomElements().setValueLocal(column.getName(), "");
|
207
|
+
} else {
|
208
|
+
log.debug("doubleColumn: " + pageReader.getDouble(column));
|
209
|
+
row.getCustomElements().setValueLocal(column.getName(), Double.toString(pageReader.getDouble(column)));
|
210
|
+
}
|
184
211
|
}
|
185
212
|
|
186
213
|
@Override
|
187
214
|
public void stringColumn(Column column) {
|
188
|
-
|
189
|
-
|
215
|
+
if (pageReader.isNull(column)) {
|
216
|
+
log.debug("stringColumn: null");
|
217
|
+
row.getCustomElements().setValueLocal(column.getName(), "");
|
218
|
+
} else {
|
219
|
+
log.debug("stringColumn: " + pageReader.getString(column));
|
220
|
+
row.getCustomElements().setValueLocal(column.getName(), pageReader.getString(column));
|
221
|
+
}
|
190
222
|
}
|
191
223
|
|
192
224
|
@Override
|
193
225
|
public void timestampColumn(Column column) {
|
194
|
-
|
195
|
-
|
226
|
+
if (pageReader.isNull(column)) {
|
227
|
+
log.debug("timestampColumn: null");
|
228
|
+
row.getCustomElements().setValueLocal(column.getName(), "");
|
229
|
+
} else {
|
230
|
+
Timestamp timestamp = pageReader.getTimestamp(column);
|
231
|
+
String strTimestamp = formatter.print(timestamp.toEpochMilli());
|
232
|
+
log.debug("timestampColumn: " + strTimestamp);
|
233
|
+
row.getCustomElements().setValueLocal(column.getName(), strTimestamp);
|
234
|
+
}
|
196
235
|
}
|
197
236
|
});
|
198
237
|
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noriaki Katayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -61,7 +61,7 @@ files:
|
|
61
61
|
- classpath/commons-codec-1.3.jar
|
62
62
|
- classpath/commons-logging-1.1.1.jar
|
63
63
|
- classpath/core-1.47.1.jar
|
64
|
-
- classpath/embulk-output-google_spreadsheets-0.
|
64
|
+
- classpath/embulk-output-google_spreadsheets-0.2.0.jar
|
65
65
|
- classpath/google-api-client-1.20.0.jar
|
66
66
|
- classpath/google-api-services-drive-v2-rev184-1.20.0.jar
|
67
67
|
- classpath/google-http-client-1.20.0.jar
|