embulk-output-command 0.1.3 → 0.1.4

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: 1880f5cf82dd5ea86ca253cf39afc926fd6cefa6
4
- data.tar.gz: 862b6032bb80311f630a9675836de5b1dcbd3650
3
+ metadata.gz: ff67dc43fd3f3b015cfe5c896b854d804965c0bd
4
+ data.tar.gz: e16b8fd85d43205af34543029f50ea7811c1d649
5
5
  SHA512:
6
- metadata.gz: ca89155cb3c5d46d9f79bb3d1f5fd1ad736ba95d34b63128119c5ce25da0b69ddffee73d592604ec9c716b4697a0d586ea0eb72dcf3cd89a603363dd790d824e
7
- data.tar.gz: 6ef7f878c444b90c0f1d90e91defeb5027c5fe7acb2e679d1fa8cfacc0049753009d47a25e00bb9cfd4c9d851e46091edf9b04d23f910323d098ab171cd102a0
6
+ metadata.gz: 92183c8fcda594460b9dd458f571ca1277fd3b90aae80de0a8917a0f053271d41cc65b73ffeadad4156ef53414888c029d235ffa811b5434797dc3d6066d9433
7
+ data.tar.gz: 89f535dabe00f6fee3bccf027fb308a23d1d9b3a2bd32f5895855c6615894d9d6efbfae4458f2377c962278b13cbeae22169aa6f957cbc831b9800fb63b854ac
@@ -0,0 +1,24 @@
1
+
2
+ Release 0.1.4 - 2016-01-13
3
+
4
+ * added support for Windows
5
+
6
+
7
+ Release 0.1.3 - 2015-08-18
8
+
9
+ * embulk version to v0.7.0
10
+
11
+
12
+ Release 0.1.2 - 2015-02-25
13
+
14
+ * fixed gem description
15
+
16
+
17
+ Release 0.1.1 - 2015-02-25
18
+
19
+ * upgraded to embulk-core v0.4.8
20
+
21
+
22
+ Release 0.1.0 - 2015-02-18
23
+
24
+ * The initial release
data/README.md CHANGED
@@ -12,7 +12,7 @@ This plugin runs a command and writes formatted data to its stdin.
12
12
 
13
13
  - **command**: command line (string, required)
14
14
 
15
- The **command** is exected using a shell. So it can include pipe (`|`), environment variables (`$VAR`), redirects, and so on.
15
+ The **command** is exected using a shell (`sh -c` on UNIX/Linux, `PowerShell.exe -Command` on Windows). Therefore, it can include pipe (`|`), environment variables (`$VAR`), redirects, and so on.
16
16
 
17
17
  The command runs `total-task-count * total-seqid-count` times. For example, if there is 3 local files and formatter produces 2 files for each input file, the command is executed for 6 times.
18
18
 
@@ -12,13 +12,14 @@ configurations {
12
12
  provided
13
13
  }
14
14
 
15
- version = "0.1.3"
15
+ version = "0.1.4"
16
16
 
17
17
  dependencies {
18
18
  compile "org.embulk:embulk-core:0.7.0"
19
19
  provided "org.embulk:embulk-core:0.7.0"
20
20
  // compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
21
21
  testCompile "junit:junit:4.+"
22
+ testCompile 'org.embulk:embulk-core:0.7.+:tests'
22
23
  }
23
24
 
24
25
  task classpath(type: Copy, dependsOn: ["jar"]) {
@@ -5,6 +5,8 @@ import java.util.ArrayList;
5
5
  import java.io.OutputStream;
6
6
  import java.io.FilterOutputStream;
7
7
  import java.io.IOException;
8
+
9
+ import com.google.common.annotations.VisibleForTesting;
8
10
  import org.slf4j.Logger;
9
11
  import com.google.common.base.Throwables;
10
12
  import com.google.common.collect.ImmutableList;
@@ -32,11 +34,6 @@ public class CommandFileOutputPlugin
32
34
  public String getCommand();
33
35
  }
34
36
 
35
- public static final List<String> SHELL = ImmutableList.of(
36
- // TODO use ["PowerShell.exe", "-Command"] on windows?
37
- "sh", "-c"
38
- );
39
-
40
37
  @Override
41
38
  public ConfigDiff transaction(ConfigSource config, int taskCount,
42
39
  FileOutputPlugin.Control control)
@@ -68,8 +65,9 @@ public class CommandFileOutputPlugin
68
65
  {
69
66
  PluginTask task = taskSource.loadTask(PluginTask.class);
70
67
 
68
+ List<String> shell = new ShellFactory().build().get();
71
69
  List<String> cmdline = new ArrayList<String>();
72
- cmdline.addAll(SHELL);
70
+ cmdline.addAll(shell);
73
71
  cmdline.add(task.getCommand());
74
72
 
75
73
  logger.info("Using command {}", cmdline);
@@ -77,6 +75,26 @@ public class CommandFileOutputPlugin
77
75
  return new PluginFileOutput(cmdline, taskIndex);
78
76
  }
79
77
 
78
+ @VisibleForTesting
79
+ static class ShellFactory
80
+ {
81
+ private List<String> shell;
82
+
83
+ public List<String> get() {
84
+ return this.shell;
85
+ }
86
+
87
+ public ShellFactory build() {
88
+ String osName = System.getProperty("os.name");
89
+ if(osName.indexOf("Windows") >= 0) {
90
+ this.shell = ImmutableList.of("PowerShell.exe", "-Command");
91
+ } else {
92
+ this.shell = ImmutableList.of("sh", "-c");
93
+ }
94
+ return this;
95
+ }
96
+ }
97
+
80
98
  private static class ProcessWaitOutputStream
81
99
  extends FilterOutputStream
82
100
  {
@@ -1,5 +1,39 @@
1
1
  package org.embulk.output;
2
2
 
3
+ import com.google.common.collect.ImmutableList;
4
+ import org.junit.Before;
5
+ import org.junit.Rule;
6
+ import org.junit.Test;
7
+ import org.embulk.EmbulkTestRuntime;
8
+ import org.embulk.output.CommandFileOutputPlugin.ShellFactory;
9
+
10
+ import java.util.List;
11
+
12
+ import static org.junit.Assert.assertEquals;
13
+
3
14
  public class TestCommandFileOutputPlugin
4
15
  {
16
+ @Rule
17
+ public EmbulkTestRuntime runtime = new EmbulkTestRuntime();
18
+
19
+ private ShellFactory shellFactory;
20
+
21
+ @Before
22
+ public void createResources()
23
+ {
24
+ shellFactory = new ShellFactory().build();
25
+ }
26
+
27
+ @Test
28
+ public void testShell() {
29
+ List<String> shell = shellFactory.get();
30
+ String osName = System.getProperty("os.name");
31
+ List<String> actualShellCmd;
32
+ if (osName.indexOf("Windows") >= 0) {
33
+ actualShellCmd = ImmutableList.of("PowerShell.exe", "-Command");
34
+ } else {
35
+ actualShellCmd = ImmutableList.of("sh", "-c");
36
+ }
37
+ assertEquals(actualShellCmd, shell);
38
+ }
5
39
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-19 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -47,6 +47,7 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - .gitignore
49
49
  - COPYING
50
+ - ChangeLog
50
51
  - README.md
51
52
  - build.gradle
52
53
  - gradle/wrapper/gradle-wrapper.jar
@@ -56,7 +57,7 @@ files:
56
57
  - lib/embulk/output/command.rb
57
58
  - src/main/java/org/embulk/output/CommandFileOutputPlugin.java
58
59
  - src/test/java/org/embulk/output/TestCommandFileOutputPlugin.java
59
- - classpath/embulk-output-command-0.1.3.jar
60
+ - classpath/embulk-output-command-0.1.4.jar
60
61
  homepage: https://github.com/embulk/embulk-output-command
61
62
  licenses:
62
63
  - Apache 2.0