embulk 0.8.8 → 0.8.9

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: 169a08fe7c64079ed0d67fcb6407bb2e70e4fcb2
4
- data.tar.gz: 455cbbb90fca39312a155631ee1601ca775e7d99
3
+ metadata.gz: c2f4ce6246c951b41b33a123f74e33d54324a865
4
+ data.tar.gz: 7c7bb33676ac7bcad4bc03dec3b843242b5ebf15
5
5
  SHA512:
6
- metadata.gz: a364df59f481375932ec165dc2e9e1e7164f9cebdb0c3aac12d85e8099e44ad243378fdf8a5041610d8b2665fa5b9429c5843b025308dff25d1c162ea83e1a7a
7
- data.tar.gz: 57606c02eb5e567a74e81aafc3289f05d2ad24babdb507b846e5fa408547833f6c9618eeda7e7377c3b49c43ca4c60181aa76b34e62bb19179aa95b7a61888a3
6
+ metadata.gz: e4921463f2ec39d4f47981692059f2221eb98003d94a063a09b0fda6cae4fb697053a5199ce2abfc31d29e43d172d24b01eacacbb1b287e80f0a93abe4d698af
7
+ data.tar.gz: bb264a3a0528502f42222d6c86ec8d5d06214bdfd7bb29c06e9c1fd9252900a7a93b70c1316423a7338672ec05bff6382c1412fed8585a4461ebc1d9340b2997
@@ -16,7 +16,7 @@ def release_projects = [project(":embulk-core"), project(":embulk-standards")]
16
16
 
17
17
  allprojects {
18
18
  group = 'org.embulk'
19
- version = '0.8.8'
19
+ version = '0.8.9'
20
20
 
21
21
  ext {
22
22
  jrubyVersion = '9.0.5.0'
@@ -38,7 +38,7 @@ dependencies {
38
38
  compile 'joda-time:joda-time:2.9.2'
39
39
  compile 'io.netty:netty-buffer:5.0.0.Alpha1'
40
40
  compile 'org.fusesource.jansi:jansi:1.11'
41
- compile 'org.msgpack:msgpack-core:0.8.3'
41
+ compile 'org.msgpack:msgpack-core:0.8.7'
42
42
 
43
43
  // For embulk/guess/charset.rb. See also embulk.gemspec
44
44
  compile 'com.ibm.icu:icu4j:54.1.1'
@@ -1,11 +1,18 @@
1
1
  package org.embulk.spi.time;
2
2
 
3
+ import java.util.Date;
4
+ import java.util.Locale;
5
+ import java.util.TimeZone;
6
+ import java.util.Calendar;
7
+ import java.text.SimpleDateFormat;
8
+ import java.text.ParseException;
3
9
  import org.joda.time.DateTimeZone;
4
10
  import com.google.common.base.Optional;
5
11
  import org.jruby.embed.ScriptingContainer;
6
12
  import org.embulk.config.Config;
7
13
  import org.embulk.config.ConfigInject;
8
14
  import org.embulk.config.ConfigDefault;
15
+ import org.embulk.config.ConfigException;
9
16
  import static org.embulk.spi.time.TimestampFormat.parseDateTimeZone;
10
17
 
11
18
  public class TimestampParser
@@ -32,6 +39,10 @@ public class TimestampParser
32
39
  @ConfigDefault("\"%Y-%m-%d %H:%M:%S.%N %z\"")
33
40
  public String getDefaultTimestampFormat();
34
41
 
42
+ @Config("default_date")
43
+ @ConfigDefault("\"1970-01-01\"")
44
+ public String getDefaultDate();
45
+
35
46
  @ConfigInject
36
47
  public ScriptingContainer getJRuby();
37
48
  }
@@ -45,6 +56,10 @@ public class TimestampParser
45
56
  @Config("format")
46
57
  @ConfigDefault("null")
47
58
  public Optional<String> getFormat();
59
+
60
+ @Config("date")
61
+ @ConfigDefault("null")
62
+ public Optional<String> getDate();
48
63
  }
49
64
 
50
65
  private final JRubyTimeParserHelper helper;
@@ -58,21 +73,44 @@ public class TimestampParser
58
73
 
59
74
  TimestampParser(Task task)
60
75
  {
61
- this(task.getJRuby(), task.getDefaultTimestampFormat(), task.getDefaultTimeZone());
76
+ this(task.getJRuby(), task.getDefaultTimestampFormat(), task.getDefaultTimeZone(), task.getDefaultDate());
62
77
  }
63
78
 
64
79
  public TimestampParser(Task task, TimestampColumnOption columnOption)
65
80
  {
66
81
  this(task.getJRuby(),
67
82
  columnOption.getFormat().or(task.getDefaultTimestampFormat()),
68
- columnOption.getTimeZone().or(task.getDefaultTimeZone()));
83
+ columnOption.getTimeZone().or(task.getDefaultTimeZone()),
84
+ columnOption.getDate().or(task.getDefaultDate()));
69
85
  }
70
86
 
71
87
  public TimestampParser(ScriptingContainer jruby, String format, DateTimeZone defaultTimeZone)
88
+ {
89
+ this(jruby, format, defaultTimeZone, "1970-01-01");
90
+ }
91
+
92
+ public TimestampParser(ScriptingContainer jruby, String format, DateTimeZone defaultTimeZone, String defaultDate)
72
93
  {
73
94
  JRubyTimeParserHelperFactory helperFactory = (JRubyTimeParserHelperFactory) jruby.runScriptlet("Embulk::Java::TimeParserHelper::Factory.new");
95
+
96
+ // calculate default date
97
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
98
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
99
+ Date utc;
100
+ try {
101
+ utc = df.parse(defaultDate);
102
+ }
103
+ catch (ParseException ex) {
104
+ throw new ConfigException("Invalid date format. Expected yyyy-MM-dd: " + defaultDate);
105
+ }
106
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ENGLISH);
107
+ cal.setTime(utc);
108
+ int year = cal.get(Calendar.YEAR);
109
+ int month = cal.get(Calendar.MONTH) + 1;
110
+ int day = cal.get(Calendar.DAY_OF_MONTH);
111
+
74
112
  // TODO get default current time from ExecTask.getExecTimestamp
75
- this.helper = (JRubyTimeParserHelper) helperFactory.newInstance(format, 1970, 1, 1, 0, 0, 0, 0); // TODO default time zone
113
+ this.helper = (JRubyTimeParserHelper) helperFactory.newInstance(format, year, month, day, 0, 0, 0, 0); // TODO default time zone
76
114
  this.defaultTimeZone = defaultTimeZone;
77
115
  }
78
116
 
@@ -60,4 +60,16 @@ public class TestTimestampFormatterParser
60
60
  TimestampParser parser = new TimestampParser(ptask);
61
61
  assertEquals(Timestamp.ofEpochSecond(1416365189), parser.parse("1416365189"));
62
62
  }
63
+
64
+ @Test
65
+ public void testDefaultDate() throws Exception
66
+ {
67
+ ConfigSource config = Exec.newConfigSource()
68
+ .set("default_timestamp_format", "%H:%M:%S %Z")
69
+ .set("default_date", "2016-02-03");
70
+
71
+ ParserTestTask ptask = config.loadConfig(ParserTestTask.class);
72
+ TimestampParser parser = new TimestampParser(ptask);
73
+ assertEquals(Timestamp.ofEpochSecond(1454467589, 0), parser.parse("02:46:29 +0000"));
74
+ }
63
75
  }
@@ -4,6 +4,7 @@ Release Notes
4
4
  .. toctree::
5
5
  :maxdepth: 1
6
6
 
7
+ release/release-0.8.9
7
8
  release/release-0.8.8
8
9
  release/release-0.8.7
9
10
  release/release-0.8.6
@@ -0,0 +1,14 @@
1
+ Release 0.8.9
2
+ ==================================
3
+
4
+ General Changes
5
+ ------------------
6
+
7
+ * Added ``date:`` option to timestamp parser. If format doesn't include date part, date option is used as the default date. For example, parsing text "02:46:29" with ``format: %H:%M:%S`` and ``date: 2016-02-03`` options returns "2016-02-03 02:46:29".
8
+
9
+ * Upgraded msgpack-core version from 0.8.6 to 0.8.7. Release notes of msgpack-java: https://github.com/msgpack/msgpack-java/blob/develop/RELEASE_NOTES.md
10
+
11
+
12
+ Release Date
13
+ ------------------
14
+ 2016-05-12
@@ -15,6 +15,7 @@ id,account,time,purchase,comment
15
15
  2,14824,2015-01-27 19:01:23,20150127,embulk jruby
16
16
  3,27559,2015-01-28 02:20:02,20150128,"Embulk ""csv"" parser plugin"
17
17
  4,11270,2015-01-29 11:54:36,20150129,NULL
18
+
18
19
  EOF
19
20
  end
20
21
 
@@ -1 +1 @@
1
- jruby-9.0.4.0
1
+ jruby-9.0.5.0
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org/'
2
- gem 'embulk', '~> 0.7.0'
2
+ gem 'embulk', '~> 0.8.0'
3
3
 
4
4
  #
5
5
  # 1. Use following syntax to specify versions of plugins
@@ -1,3 +1,3 @@
1
1
  module Embulk
2
- VERSION = '0.8.8'
2
+ VERSION = '0.8.9'
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.8.8
4
+ version: 0.8.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-15 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jruby-jars
@@ -108,9 +108,9 @@ files:
108
108
  - classpath/commons-beanutils-core-1.8.3.jar
109
109
  - classpath/commons-compress-1.10.jar
110
110
  - classpath/commons-lang3-3.1.jar
111
- - classpath/embulk-cli-0.8.8.jar
112
- - classpath/embulk-core-0.8.8.jar
113
- - classpath/embulk-standards-0.8.8.jar
111
+ - classpath/embulk-cli-0.8.9.jar
112
+ - classpath/embulk-core-0.8.9.jar
113
+ - classpath/embulk-standards-0.8.9.jar
114
114
  - classpath/guava-18.0.jar
115
115
  - classpath/guice-4.0.jar
116
116
  - classpath/guice-bootstrap-0.1.1.jar
@@ -126,7 +126,7 @@ files:
126
126
  - classpath/joda-time-2.9.2.jar
127
127
  - classpath/logback-classic-1.1.3.jar
128
128
  - classpath/logback-core-1.1.3.jar
129
- - classpath/msgpack-core-0.8.3.jar
129
+ - classpath/msgpack-core-0.8.7.jar
130
130
  - classpath/netty-buffer-5.0.0.Alpha1.jar
131
131
  - classpath/netty-common-5.0.0.Alpha1.jar
132
132
  - classpath/slf4j-api-1.7.12.jar
@@ -429,6 +429,7 @@ files:
429
429
  - embulk-docs/src/release/release-0.8.6.rst
430
430
  - embulk-docs/src/release/release-0.8.7.rst
431
431
  - embulk-docs/src/release/release-0.8.8.rst
432
+ - embulk-docs/src/release/release-0.8.9.rst
432
433
  - embulk-standards/build.gradle
433
434
  - embulk-standards/src/main/java/org/embulk/standards/Bzip2FileDecoderPlugin.java
434
435
  - embulk-standards/src/main/java/org/embulk/standards/Bzip2FileEncoderPlugin.java