embulk-parser-regex 0.2.0 → 0.2.1

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: 180e9d8ef6ff872d1aa840f937972ba228b2762c
4
- data.tar.gz: 5ae14fb13a5ac890f8f4c7224cf14fbe660ddb22
3
+ metadata.gz: e8d133ba73ccd1e36f1080041375467f531f756c
4
+ data.tar.gz: 1e35069e1548167e77161aaa4af85d9069e29856
5
5
  SHA512:
6
- metadata.gz: bf0f5d97601bd217bc28b955d1046456d9231c9cbf7614c82fe90dfe70fb43716ce09ab3762e0bf2737ffc9a1e6774e23086e7a61c2b5526afc284619df89a0d
7
- data.tar.gz: 7e1a23835f82c112616998ce5c121ddac25299ac0d91afb934b6a5f8218b295a561a7842446b261a79a83dea9d267dca1d60f827e3a72e99675c824b4ee40a7d
6
+ metadata.gz: d603860a6064bab07f8951f66c632d35af221f7665c4f7b6faf435aba86ebed2666f54cf65b3d63e9d798395cf17cabc37fefe7394a928f4f2e8de81e6009c55
7
+ data.tar.gz: f6d21ac5993d9727b6c02ad7d315bfe282d4f44a32016bd389315ce3acaecaa7c9eb094a1fef5509eee3b67ec79f9b823808d23ac54b647f319cbf5a8c8a21a1
data/README.md CHANGED
@@ -53,3 +53,9 @@ $ embulk guess -g regex config.yml -o guessed.yml
53
53
  ```
54
54
  $ ./gradlew gem # -t to watch change of files and rebuild continuously
55
55
  ```
56
+
57
+ ## Run checkstyle:
58
+
59
+ ```
60
+ $ ./gradlew check
61
+ ```
@@ -2,6 +2,7 @@ plugins {
2
2
  id "com.jfrog.bintray" version "1.1"
3
3
  id "com.github.jruby-gradle.base" version "0.1.5"
4
4
  id "java"
5
+ id "checkstyle"
5
6
  }
6
7
 
7
8
  import com.github.jrubygradle.JRubyExec
@@ -13,15 +14,22 @@ configurations {
13
14
  provided
14
15
  }
15
16
 
16
- version = "0.2.0"
17
+ version = "0.2.1"
18
+
19
+ sourceCompatibility = 1.7
20
+ targetCompatibility = 1.7
17
21
 
18
22
  dependencies {
19
- compile "org.embulk:embulk-core:0.7.4"
20
- provided "org.embulk:embulk-core:0.7.4"
23
+ compile "org.embulk:embulk-core:0.8.+"
24
+ provided "org.embulk:embulk-core:0.8.+"
21
25
  // compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
22
26
  testCompile "junit:junit:4.+"
23
27
  }
24
28
 
29
+ checkstyle {
30
+ toolVersion = '6.7'
31
+ }
32
+
25
33
  task classpath(type: Copy, dependsOn: ["jar"]) {
26
34
  doFirst { file("classpath").deleteDir() }
27
35
  from (configurations.runtime - configurations.provided + files(jar.archivePath))
@@ -14,6 +14,7 @@ import org.embulk.spi.util.DynamicColumnSetter;
14
14
  import org.embulk.spi.util.LineDecoder;
15
15
  import org.embulk.spi.util.Timestamps;
16
16
  import org.embulk.spi.util.dynamic.*;
17
+ import org.slf4j.Logger;
17
18
 
18
19
  import java.util.HashMap;
19
20
  import java.util.Map;
@@ -42,6 +43,12 @@ public class RegexParserPlugin implements ParserPlugin {
42
43
  extends Task, TimestampFormatter.TimestampColumnOption {
43
44
  }
44
45
 
46
+ private final Logger log;
47
+
48
+ public RegexParserPlugin() {
49
+ log = Exec.getLogger(RegexParserPlugin.class);
50
+ }
51
+
45
52
  public void transaction(ConfigSource config, ParserPlugin.Control control) {
46
53
  PluginTask task = config.loadConfig(PluginTask.class);
47
54
  control.run(task.dump(), task.getSchemaConfig().toSchema());
@@ -59,18 +66,23 @@ public class RegexParserPlugin implements ParserPlugin {
59
66
  timestampParsers, taskSource.loadTask(PluginTaskFormatter.class));
60
67
 
61
68
  while (input.nextFile()) {
69
+
70
+ int lineNumber = 0;
71
+
62
72
  while (true) {
63
73
  String line = lineDecoder.poll();
74
+ lineNumber++;
75
+
64
76
  if (line == null) {
65
77
  break;
66
78
  }
67
79
  Matcher matcher = pattern.matcher(line);
68
80
  if (!matcher.matches()) {
69
81
  if (task.getSkipIfUnmatch()) {
70
- // TODO: How to Log?
82
+ log.warn(String.format("Skipped unmatched line %d: %s", lineNumber, line));
71
83
  continue;
72
84
  } else {
73
- throw new DataException("Unmatched Line: " + line);
85
+ throw new DataException(String.format("Unmatched Line at line %d: %s", lineNumber, line));
74
86
  }
75
87
  }
76
88
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-parser-regex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Morishita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-31 00:00:00.000000000 Z
11
+ date: 2016-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -65,7 +65,7 @@ files:
65
65
  - sample/simple/data_simple_1.txt
66
66
  - src/main/java/org/embulk/parser/regex/RegexParserPlugin.java
67
67
  - src/test/java/org/embulk/parser/regex/TestRegexParserPlugin.java
68
- - classpath/embulk-parser-regex-0.2.0.jar
68
+ - classpath/embulk-parser-regex-0.2.1.jar
69
69
  homepage: https://github.com/mokemokechicken/embulk-parser-regex
70
70
  licenses:
71
71
  - MIT