embulk 0.6.17 → 0.6.18

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: c667cedd2e533e4a3404c81baa92618dfd826644
4
- data.tar.gz: fc3c840b3c855395c02b3d2ba3e84cf3428a8a55
3
+ metadata.gz: ff085042dbecce04ca4a8095c59802bc4336a67e
4
+ data.tar.gz: aab28c9c0d9ae11a758ba6148baa12a8973e7903
5
5
  SHA512:
6
- metadata.gz: e30b36e74c05cc9a3f63565691fd4366803be573f9909c1cfcce1292a65a1c7b70a1a6d324990555f89b774c786a8dc1316012f9f9a4330f52c3963573cedaa9
7
- data.tar.gz: 8299b1e6c264a0031e2de1c557fd1a91eae1d24bf7badfc671e81fdc007421c4cc77dbc40cb8e6c15f66d54bd259be44b925772104055105988a704401f52418
6
+ metadata.gz: bace1db62e73980869cbf11118be290cdcacda974473bb6e334fbb0075bbbdcf8dec7096cff6f35c8de185baa67b6f5efee498e13d974183a5ec15a7ab9bf0db
7
+ data.tar.gz: 2d1e67648bc4eec548433c69f147e70647fe958d53c15234af3df6289e562a2aaa2e1d49bc9342204f83f6718f2965fa9b7713e5a415bb3e733d3a32e9fcdeac
data/build.gradle CHANGED
@@ -11,7 +11,7 @@ def release_projects = [project(":embulk-core"), project(":embulk-standards")]
11
11
 
12
12
  allprojects {
13
13
  group = 'org.embulk'
14
- version = '0.6.17'
14
+ version = '0.6.18'
15
15
 
16
16
  ext {
17
17
  jrubyVersion = '1.7.19'
@@ -22,14 +22,14 @@ dependencies {
22
22
  compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.5.3'
23
23
  compile 'com.fasterxml.jackson.module:jackson-module-guice:2.5.3'
24
24
  compile 'ch.qos.logback:logback-classic:1.1.3'
25
- compile 'org.slf4j:slf4j-api:1.7.10'
25
+ compile 'org.slf4j:slf4j-api:1.7.12'
26
26
  compile 'org.jruby:jruby-complete:' + project.jrubyVersion
27
27
  compile 'com.google.code.findbugs:annotations:3.0.0'
28
28
  compile 'org.yaml:snakeyaml:1.14'
29
29
  compile 'javax.validation:validation-api:1.1.0.Final'
30
30
  compile 'org.apache.bval:bval-jsr303:0.5'
31
31
  compile 'io.airlift:slice:0.9'
32
- compile 'joda-time:joda-time:2.7'
32
+ compile 'joda-time:joda-time:2.8.1'
33
33
  compile 'io.netty:netty-buffer:5.0.0.Alpha1'
34
34
  compile 'org.fusesource.jansi:jansi:1.11'
35
35
 
@@ -2,12 +2,14 @@ package org.embulk.config;
2
2
 
3
3
  import java.io.File;
4
4
  import java.io.FileInputStream;
5
+ import java.io.InputStream;
5
6
  import java.io.IOException;
6
7
  import java.util.Properties;
7
8
  import com.google.inject.Inject;
8
9
  import com.fasterxml.jackson.databind.ObjectMapper;
9
10
  import com.fasterxml.jackson.core.JsonParser;
10
11
  import com.fasterxml.jackson.databind.JsonNode;
12
+ import com.fasterxml.jackson.databind.RuntimeJsonMappingException;
11
13
  import com.fasterxml.jackson.databind.node.ObjectNode;
12
14
  import com.fasterxml.jackson.databind.node.JsonNodeFactory;
13
15
  import org.yaml.snakeyaml.Yaml;
@@ -22,47 +24,77 @@ public class ConfigLoader
22
24
  this.model = model;
23
25
  }
24
26
 
25
- public ConfigSource fromJson(JsonParser parser) throws IOException
27
+ public ConfigSource fromJsonFile(File file) throws IOException
26
28
  {
27
- // TODO check parsed.isObject()
28
- ObjectNode source = (ObjectNode) new ObjectMapper().readTree(parser);
29
- return new DataSourceImpl(model, source);
29
+ try (FileInputStream is = new FileInputStream(file)) {
30
+ return fromJson(is);
31
+ }
32
+ }
33
+
34
+ public ConfigSource fromJson(InputStream stream) throws IOException
35
+ {
36
+ JsonNode node = new ObjectMapper().readTree(stream);
37
+ if (!node.isObject()) {
38
+ throw new RuntimeJsonMappingException("Expected object to load ConfigSource but got: "+node.getNodeType());
39
+ }
40
+ return new DataSourceImpl(model, (ObjectNode) node);
41
+ }
42
+
43
+ public ConfigSource fromYamlFile(File file) throws IOException
44
+ {
45
+ try (FileInputStream stream = new FileInputStream(file)) {
46
+ return fromYaml(stream);
47
+ }
30
48
  }
31
49
 
32
- public ConfigSource fromYamlFile(File path) throws IOException
50
+ public ConfigSource fromYaml(InputStream stream) throws IOException
33
51
  {
34
52
  Yaml yaml = new Yaml();
35
- Object parsedYaml;
36
- try (FileInputStream is = new FileInputStream(path)) {
37
- parsedYaml = yaml.load(is);
53
+ Object object = yaml.load(stream);
54
+ JsonNode node = objectToJson(object);
55
+ if (!node.isObject()) {
56
+ throw new RuntimeJsonMappingException("Expected object to load ConfigSource but got "+node);
38
57
  }
39
- ObjectNode source = objectToJsonObject(parsedYaml);
58
+ return new DataSourceImpl(model, (ObjectNode) node);
59
+ }
60
+
61
+ @Deprecated
62
+ public ConfigSource fromJson(JsonParser parser) throws IOException
63
+ {
64
+ // TODO check parsed.isObject()
65
+ ObjectNode source = (ObjectNode) new ObjectMapper().readTree(parser);
40
66
  return new DataSourceImpl(model, source);
41
67
  }
42
68
 
43
69
  public ConfigSource fromPropertiesYamlLiteral(Properties props, String keyPrefix)
44
70
  {
45
- // TODO exception handling
46
71
  ObjectNode source = new ObjectNode(JsonNodeFactory.instance);
72
+ DataSource ds = new DataSourceImpl(model, source);
47
73
  Yaml yaml = new Yaml();
48
- for (String key : props.stringPropertyNames()) {
49
- // TODO handle "." and "[...]" as map and array acccessor for example:
50
- // in.parser.type=csv => {"in": {"parser": {"type": "csv"}}}
51
- if (!key.startsWith(keyPrefix)) {
74
+ for (String propName : props.stringPropertyNames()) {
75
+ if (!propName.startsWith(keyPrefix)) {
52
76
  continue;
53
77
  }
54
- String yamlValue = props.getProperty(key);
55
- String keyName = key.substring(keyPrefix.length());
56
- Object parsedValue = yaml.load(yamlValue);
57
- JsonNode typedValue = objectToJson(parsedValue);
58
- source.set(keyName, typedValue);
78
+ String keyName = propName.substring(keyPrefix.length());
79
+ String yamlValue = props.getProperty(propName);
80
+ Object parsedValue = yaml.load(yamlValue); // TODO exception handling
81
+ JsonNode node = objectToJson(parsedValue);
82
+
83
+ // handle "." as a map acccessor. for example:
84
+ // in.parser.type=csv => {"in": {"parser": {"type": "csv"}}}
85
+ // TODO handle "[]" as array index
86
+ String[] fragments = keyName.split("\\.");
87
+ DataSource key = ds;
88
+ for (int i=0; i < fragments.length - 1; i++) {
89
+ key = key.getNestedOrSetEmpty(fragments[i]); // TODO exception handling
90
+ }
91
+ key.set(fragments[fragments.length - 1], node);
59
92
  }
60
93
  return new DataSourceImpl(model, source);
61
94
  }
62
95
 
63
96
  private JsonNode objectToJson(Object object)
64
97
  {
65
- // TODO exception
66
98
  ObjectMapper objectMapper = new ObjectMapper();
67
99
  try {
68
100
  return objectMapper.readTree(objectMapper.writeValueAsString(object));
@@ -70,14 +102,4 @@ public class ConfigLoader
70
102
  throw new RuntimeException(ex);
71
103
  }
72
104
  }
73
-
74
- private ObjectNode objectToJsonObject(Object object)
75
- {
76
- // TODO exception
77
- JsonNode json = objectToJson(object);
78
- if (!json.isObject()) {
79
- throw new RuntimeException("Expected object to deserialize ConfigSource but got "+json);
80
- }
81
- return (ObjectNode) json;
82
- }
83
105
  }
@@ -54,10 +54,10 @@ public abstract class Filters
54
54
  List<Schema> filterSchemas, PageOutput output)
55
55
  {
56
56
  PageOutput out = output;
57
- int pos = 0;
58
- while (pos < plugins.size()) {
57
+ int pos = plugins.size() - 1;
58
+ while (pos >= 0) {
59
59
  out = plugins.get(pos).open(taskSources.get(pos), filterSchemas.get(pos), filterSchemas.get(pos + 1), out);
60
- pos++;
60
+ pos--;
61
61
  }
62
62
  return out;
63
63
  }
@@ -0,0 +1,66 @@
1
+ package org.embulk.config;
2
+
3
+ import java.util.Properties;
4
+ import java.io.InputStream;
5
+ import java.io.ByteArrayInputStream;
6
+ import java.io.IOException;
7
+ import java.nio.charset.StandardCharsets;
8
+ import com.fasterxml.jackson.databind.ObjectMapper;
9
+ import org.junit.Before;
10
+ import org.junit.Test;
11
+ import static org.junit.Assert.assertEquals;
12
+ import com.google.inject.Inject;
13
+ import org.embulk.spi.Exec;
14
+ import org.embulk.EmbulkTestRuntime;
15
+
16
+ public class TestConfigLoader
17
+ {
18
+ private ConfigLoader loader;
19
+
20
+ @Before
21
+ public void setup() throws Exception
22
+ {
23
+ this.loader = new ConfigLoader(new ModelManager(null, new ObjectMapper()));
24
+ }
25
+
26
+ @Test
27
+ public void testFromEmptyJson() throws IOException
28
+ {
29
+ ConfigSource config = loader.fromJson(newInputStream("{\"type\":\"test\",\"data\":1}"));
30
+ assertEquals("test", config.get(String.class, "type"));
31
+ assertEquals(1, (int) config.get(Integer.class, "data"));
32
+ }
33
+
34
+ @Test
35
+ public void testFromYamlProperties() throws IOException
36
+ {
37
+ Properties props = new Properties();
38
+ props.setProperty("type", "test");
39
+ props.setProperty("data", "1");
40
+
41
+ ConfigSource config = loader.fromPropertiesYamlLiteral(props, "");
42
+ assertEquals("test", config.get(String.class, "type"));
43
+ assertEquals(1, (int) config.get(Integer.class, "data"));
44
+ }
45
+
46
+ @Test
47
+ public void testFromYamlPropertiesNested() throws IOException
48
+ {
49
+ Properties props = new Properties();
50
+ props.setProperty("type", "test");
51
+ props.setProperty("columns.k1", "1");
52
+ props.setProperty("values.myval.data", "2");
53
+
54
+ ConfigSource config = loader.fromPropertiesYamlLiteral(props, "");
55
+ System.out.println("config: "+config);
56
+ assertEquals("test", config.get(String.class, "type"));
57
+ assertEquals(1, (int) config.getNested("columns").get(Integer.class, "k1"));
58
+ assertEquals(2, (int) config.getNested("values").getNested("myval").get(Integer.class, "data"));
59
+ }
60
+
61
+ private static InputStream newInputStream(String string)
62
+ {
63
+ byte[] bytes = string.getBytes(StandardCharsets.UTF_8);
64
+ return new ByteArrayInputStream(bytes);
65
+ }
66
+ }
@@ -4,6 +4,7 @@ Release Notes
4
4
  .. toctree::
5
5
  :maxdepth: 1
6
6
 
7
+ release/release-0.6.18
7
8
  release/release-0.6.17
8
9
  release/release-0.6.16
9
10
  release/release-0.6.15
@@ -0,0 +1,14 @@
1
+ Release 0.6.18
2
+ ==================================
3
+
4
+ General Changes
5
+ ------------------
6
+
7
+ * Upgraded slf4j-api from 1.7.10 to 1.7.12
8
+ * Upgraded joda-time from 2.7 to 2.8.1
9
+ * Fixed broken plugin template generation of java-filter and ruby (@sakama++)
10
+ * Fixed stacking order of filter plugins. This fixes broken behavior when we use multiple filter plugins.
11
+
12
+ Release Date
13
+ ------------------
14
+ 2015-07-22
@@ -2,7 +2,7 @@
2
2
 
3
3
  %case language
4
4
  %when :ruby
5
- TODO: Write short description here and <%= project_name %>.gemspec file.
5
+ TODO: Write short description here and <%= full_project_name %>.gemspec file.
6
6
  %when :java
7
7
  TODO: Write short description here and build.gradle file.
8
8
  %else
@@ -1,4 +1,4 @@
1
- package org.embulk.<%= embulk_category %>;
1
+ package <%= java_package_name %>;
2
2
 
3
3
  import com.google.common.base.Optional;
4
4
  import org.embulk.config.Config;
@@ -1,3 +1,3 @@
1
1
  module Embulk
2
- VERSION = '0.6.17'
2
+ VERSION = '0.6.18'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.17
4
+ version: 0.6.18
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-07-17 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -265,6 +265,7 @@ files:
265
265
  - embulk-core/src/test/java/org/embulk/RandomManager.java
266
266
  - embulk-core/src/test/java/org/embulk/TestPluginSourceModule.java
267
267
  - embulk-core/src/test/java/org/embulk/TestUtilityModule.java
268
+ - embulk-core/src/test/java/org/embulk/config/TestConfigLoader.java
268
269
  - embulk-core/src/test/java/org/embulk/config/TestConfigSource.java
269
270
  - embulk-core/src/test/java/org/embulk/config/TestTaskSource.java
270
271
  - embulk-core/src/test/java/org/embulk/plugin/MockPluginSource.java
@@ -333,6 +334,7 @@ files:
333
334
  - embulk-docs/src/release/release-0.6.15.rst
334
335
  - embulk-docs/src/release/release-0.6.16.rst
335
336
  - embulk-docs/src/release/release-0.6.17.rst
337
+ - embulk-docs/src/release/release-0.6.18.rst
336
338
  - embulk-docs/src/release/release-0.6.2.rst
337
339
  - embulk-docs/src/release/release-0.6.3.rst
338
340
  - embulk-docs/src/release/release-0.6.4.rst
@@ -449,8 +451,8 @@ files:
449
451
  - classpath/bval-jsr303-0.5.jar
450
452
  - classpath/commons-beanutils-core-1.8.3.jar
451
453
  - classpath/commons-lang3-3.1.jar
452
- - classpath/embulk-core-0.6.17.jar
453
- - classpath/embulk-standards-0.6.17.jar
454
+ - classpath/embulk-core-0.6.18.jar
455
+ - classpath/embulk-standards-0.6.18.jar
454
456
  - classpath/guava-18.0.jar
455
457
  - classpath/guice-4.0.jar
456
458
  - classpath/guice-multibindings-4.0.jar
@@ -463,13 +465,13 @@ files:
463
465
  - classpath/jackson-module-guice-2.5.3.jar
464
466
  - classpath/jansi-1.11.jar
465
467
  - classpath/javax.inject-1.jar
466
- - classpath/joda-time-2.7.jar
468
+ - classpath/joda-time-2.8.1.jar
467
469
  - classpath/jruby-complete-1.7.19.jar
468
470
  - classpath/logback-classic-1.1.3.jar
469
471
  - classpath/logback-core-1.1.3.jar
470
472
  - classpath/netty-buffer-5.0.0.Alpha1.jar
471
473
  - classpath/netty-common-5.0.0.Alpha1.jar
472
- - classpath/slf4j-api-1.7.10.jar
474
+ - classpath/slf4j-api-1.7.12.jar
473
475
  - classpath/slice-0.9.jar
474
476
  - classpath/snakeyaml-1.14.jar
475
477
  - classpath/validation-api-1.1.0.Final.jar