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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc9d14ac105120b4957aea38c2d55b04c92a6e1c
4
- data.tar.gz: 47d8da8bc92ab354da600cf44f7f6a2f08ad5e1d
3
+ metadata.gz: e147a98084a075ff73b0c616d7795508b46627c4
4
+ data.tar.gz: ff7b12e9cd4613ce1a59f675f79c69e11741e6a5
5
5
  SHA512:
6
- metadata.gz: 2ba749b2bcea3a1577b82c26b40ed1099c3d22a6bddb72de531935aaac857a3cbfe28b2fe9fb3e404dc23be15e67b87a6af86067e312a9e411ea842ad0fa44fa
7
- data.tar.gz: 67b8204840acc560cdd38e3ec2c2fa821c676716cae8213c8bd192a94363ba44f2b1ee0c447988b0f812b40c2eb0480da98026e749e88325b07292710b60e7f9
6
+ metadata.gz: c6262b0076d02dbe010f2c5c0ff0d217a0df0658d893f82fdec9f4a64aeefd8fe2e1f4c8f4b5e731c1aaf65fac5d4de70a8856a27e0ef6038f51371d9c1ef5b7
7
+ data.tar.gz: f2674419e96d00c2b28da5c493274a18578725322422d0f4a0e4c3f172bf3e04c34dd978bdbbb24fd624830893eeaa17cf138a1565e62b701046c3c0c689d6ba
@@ -1,5 +1,7 @@
1
1
  language: java
2
2
  jdk:
3
+ - openjdk7
4
+ - oraclejdk7
3
5
  - oraclejdk8
4
6
  sudo: false
5
7
  script:
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**: description (string, required)
15
- - **p12_keyfile**: description (string, required)
16
- - **spreadsheet_id**: description (string, required)
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
 
@@ -12,7 +12,7 @@ configurations {
12
12
  provided
13
13
  }
14
14
 
15
- version = "0.1.1"
15
+ version = "0.2.0"
16
16
 
17
17
  dependencies {
18
18
  compile "org.embulk:embulk-core:0.7.4"
@@ -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
- log.debug("booleanColumn: " + pageReader.getString(column));
171
- row.getCustomElements().setValueLocal(column.getName(), pageReader.getString(column));
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
- log.debug("longColumn: " + pageReader.getString(column));
177
- row.getCustomElements().setValueLocal(column.getName(), pageReader.getString(column));
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
- log.debug("doubleColumn: " + pageReader.getString(column));
183
- row.getCustomElements().setValueLocal(column.getName(), pageReader.getString(column));
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
- log.debug("stringColumn: " + pageReader.getString(column));
189
- row.getCustomElements().setValueLocal(column.getName(), pageReader.getString(column));
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
- log.debug("timestampColumn: " + pageReader.getString(column));
195
- row.getCustomElements().setValueLocal(column.getName(), pageReader.getString(column));
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.1.1
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: 2015-09-28 00:00:00.000000000 Z
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.1.1.jar
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