embulk-output-ftp 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0494ae651d3e5c17bb41c2cb08712ed7d6388d2
4
- data.tar.gz: 9463836af3ca53940c83237a3e84126dadb8d153
3
+ metadata.gz: 1235e5dc7f3eea1852b1bb9a78f0e0f4dd99cf9d
4
+ data.tar.gz: 8b73b609b94b5d2f00a95b13aaf7d416d2716248
5
5
  SHA512:
6
- metadata.gz: 66c737b48bc821ca444806d7d555ed17c1f7b4385f75743428a2fa3d94e72488791c0aa9883720155ac86e4d65de7e08f2c6af91afbf6ed7756cdb558116e67f
7
- data.tar.gz: ccd8a59f0f4b58d9e02158ad757fd490c6e678768bf2e8f75aaa0a74dd0bfcfc465522b8126fe47710bf583c585218b860d410ccdd027c2e23ca4b92f8e41112
6
+ metadata.gz: cd0b1ffc89da7fd8e8a0a204503b3fc6bfb6d71760054a3708e6691e87d5c8ab75e5ce5075d64ab54e0925fadb18c0d05c4d2132ad6967757934b09ea7fe2f7c
7
+ data.tar.gz: bd01eb4835cbced4fb699b9a78bf2dbef3eba47461870ed8974ebbbd46a470b0ff4c48260e5079b8ce794a89f44b13b6d55d5619612cf792446425507e4db04d
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
+ ## 0.1.6 - 2016-09-09
2
+
3
+ * [maintenance] Fix NullPointerException at FtpFileOutput.getRemoteDirectory() method [#12](https://github.com/embulk/embulk-output-ftp/pull/12)
4
+
5
+
1
6
  ## 0.1.5 - 2016-08-08
2
7
 
3
- * [maintenance] Improve connection stability [#8](https://github.com/embulk/embulk-output-ftp/pull/9)
8
+ * [maintenance] Improve connection stability [#9](https://github.com/embulk/embulk-output-ftp/pull/9)
4
9
 
5
10
  ## 0.1.4 - 2016-07-29
6
11
 
data/README.md CHANGED
@@ -19,7 +19,7 @@ If you want to use SFTP, please use [embulk-output-sftp](https://github.com/civi
19
19
  - **password**: password to login (string, default: `""`)
20
20
  - **path_prefix** prefix of target files (string, required)
21
21
  - **sequence_format** Format for sequence part of output files (string, default: `".%03d.%02d"`)
22
- - **ext** e.g. "csv.gz, json.gz" (string, required)
22
+ - **file_ext** e.g. "csv.gz, json.gz" (string, required)
23
23
  - **passive_mode**: use passive mode (boolean, default: true)
24
24
  - **ascii_mode**: use ASCII mode instead of binary mode (boolean, default: false)
25
25
  - **ssl**: use FTPS (SSL encryption). (boolean, default: false)
@@ -54,7 +54,7 @@ out:
54
54
  port: 21
55
55
  user: anonymous
56
56
  path_prefix: /ftp/file/path/prefix
57
- ext: csv
57
+ file_ext: csv
58
58
  formatter:
59
59
  type: csv.gz
60
60
  header_line: false
@@ -76,7 +76,7 @@ out:
76
76
  ssl_verify: false
77
77
 
78
78
  path_prefix: /ftp/file/path/prefix
79
- ext: csv
79
+ file_ext: csv
80
80
  ```
81
81
 
82
82
  FTPS encryption with server certificate verification:
@@ -106,7 +106,7 @@ out:
106
106
  -----END CERTIFICATE-----
107
107
 
108
108
  path_prefix: /ftp/file/path/prefix
109
- ext: csv
109
+ file_ext: csv
110
110
  ```
111
111
 
112
112
  ## Build
data/build.gradle CHANGED
@@ -14,7 +14,7 @@ configurations {
14
14
  provided
15
15
  }
16
16
 
17
- version = "0.1.5"
17
+ version = "0.1.6"
18
18
 
19
19
  sourceCompatibility = 1.7
20
20
  targetCompatibility = 1.7
@@ -92,6 +92,10 @@ public class FtpFileOutputPlugin implements FileOutputPlugin
92
92
  @Config("max_connection_retry")
93
93
  @ConfigDefault("10") // 10 times retry to connect FTP server if failed.
94
94
  int getMaxConnectionRetry();
95
+
96
+ @Config("directory_separator")
97
+ @ConfigDefault("\"/\"")
98
+ String getDirectorySeparator();
95
99
  }
96
100
 
97
101
  private static final Logger log = Exec.getLogger(FtpFileOutputPlugin.class);
@@ -150,6 +154,7 @@ public class FtpFileOutputPlugin implements FileOutputPlugin
150
154
  private final String sequenceFormat;
151
155
  private final String pathSuffix;
152
156
  private final int maxConnectionRetry;
157
+ private final String separator;
153
158
  private BufferedOutputStream output = null;
154
159
  private int fileIndex;
155
160
  private File file;
@@ -165,6 +170,7 @@ public class FtpFileOutputPlugin implements FileOutputPlugin
165
170
  this.sequenceFormat = task.getSequenceFormat();
166
171
  this.pathSuffix = task.getFileNameExtension();
167
172
  this.maxConnectionRetry = task.getMaxConnectionRetry();
173
+ this.separator = task.getDirectorySeparator();
168
174
  }
169
175
 
170
176
  @Override
@@ -178,7 +184,10 @@ public class FtpFileOutputPlugin implements FileOutputPlugin
178
184
  suffix = "." + suffix;
179
185
  }
180
186
  filePath = pathPrefix + String.format(sequenceFormat, taskIndex, fileIndex) + suffix;
181
- remoteDirectory = getRemoteDirectory(filePath);
187
+ if (!filePath.startsWith(separator)) {
188
+ filePath = separator + filePath;
189
+ }
190
+ remoteDirectory = getRemoteDirectory(filePath, separator);
182
191
  file = Exec.getTempFileSpace().createTempFile(filePath, "tmp");
183
192
  log.info("Writing local temporary file \"{}\"", file.getAbsolutePath());
184
193
  output = new BufferedOutputStream(new FileOutputStream(file));
@@ -308,10 +317,17 @@ public class FtpFileOutputPlugin implements FileOutputPlugin
308
317
  return Exec.newTaskReport();
309
318
  }
310
319
 
311
- private String getRemoteDirectory(String filePath)
320
+ private String getRemoteDirectory(String filePath, String separator)
312
321
  {
313
322
  Path path = Paths.get(filePath);
314
- return path.getParent().toString();
323
+ if (path.getParent() == null) {
324
+ return separator;
325
+ }
326
+ String parent = path.getParent().toString();
327
+ if (!parent.startsWith(separator)) {
328
+ parent = separator + parent;
329
+ }
330
+ return parent;
315
331
  }
316
332
  }
317
333
 
@@ -117,6 +117,7 @@ public class TestFtpFileOutputPlugin
117
117
  assertEquals(false, task.getSsl());
118
118
  assertEquals(true, task.getSslExplicit());
119
119
  assertEquals(10, task.getMaxConnectionRetry());
120
+ assertEquals("/", task.getDirectorySeparator());
120
121
  }
121
122
 
122
123
  @Test
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Akama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-08 00:00:00.000000000 Z
11
+ date: 2016-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +67,7 @@ files:
67
67
  - src/test/resources/sample_02.csv
68
68
  - classpath/bcpkix-jdk15on-1.52.jar
69
69
  - classpath/bcprov-jdk15on-1.52.jar
70
- - classpath/embulk-output-ftp-0.1.5.jar
70
+ - classpath/embulk-output-ftp-0.1.6.jar
71
71
  - classpath/ftp4j-1.7.2.jar
72
72
  homepage: https://github.com/embulk/embulk-output-ftp
73
73
  licenses: