embulk-parser-csv_guessable 0.1.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 +7 -0
- data/.gitignore +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/build.gradle +97 -0
- data/config/checkstyle/checkstyle.xml +128 -0
- data/config/checkstyle/default.xml +108 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/gradlew +169 -0
- data/gradlew.bat +84 -0
- data/lib/embulk/guess/csv_guessable.rb +61 -0
- data/lib/embulk/parser/csv_guessable.rb +3 -0
- data/libs/embulk-standards-0.8.22.jar +0 -0
- data/src/main/java/org/embulk/parser/csv_guessable/CsvGuessableParserPlugin.java +371 -0
- data/src/main/java/org/embulk/parser/csv_guessable/CsvTokenizer.java +512 -0
- data/src/test/java/org/embulk/parser/csv_guessable/TestCsvGuessableParserPlugin.java +81 -0
- data/src/test/resources/data/test.csv +3 -0
- data/src/test/resources/data/test_alias.yml +3 -0
- data/src/test/resources/yml/guess_from_header.yml +9 -0
- data/src/test/resources/yml/original-csv.yml +12 -0
- data/src/test/resources/yml/replace_column_name.yml +13 -0
- metadata +100 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
package org.embulk.parser.csv_guessable;
|
2
|
+
|
3
|
+
import org.embulk.config.ConfigException;
|
4
|
+
import org.embulk.config.ConfigLoader;
|
5
|
+
import org.embulk.config.ConfigSource;
|
6
|
+
import org.embulk.EmbulkTestRuntime;
|
7
|
+
import org.embulk.spi.Exec;
|
8
|
+
import org.junit.Rule;
|
9
|
+
import org.junit.rules.ExpectedException;
|
10
|
+
import org.junit.Test;
|
11
|
+
|
12
|
+
import static org.junit.Assert.assertFalse;
|
13
|
+
|
14
|
+
import static org.embulk.parser.csv_guessable.CsvGuessableParserPlugin.PluginTask;
|
15
|
+
|
16
|
+
public class TestCsvGuessableParserPlugin
|
17
|
+
{
|
18
|
+
@Rule
|
19
|
+
public EmbulkTestRuntime runtime = new EmbulkTestRuntime();
|
20
|
+
|
21
|
+
@Rule
|
22
|
+
public ExpectedException exception = ExpectedException.none();
|
23
|
+
|
24
|
+
private ConfigSource getConfigFromYaml(String yaml)
|
25
|
+
{
|
26
|
+
ConfigLoader loader = new ConfigLoader(Exec.getModelManager());
|
27
|
+
return loader.fromYamlString(yaml);
|
28
|
+
}
|
29
|
+
|
30
|
+
/*
|
31
|
+
@Test
|
32
|
+
public void throwExceptionWithoutRequisite()
|
33
|
+
{
|
34
|
+
String configYaml = "" +
|
35
|
+
"type: csv_with_header";
|
36
|
+
|
37
|
+
ConfigSource config = getConfigFromYaml(configYaml);
|
38
|
+
|
39
|
+
exception.expect(ConfigException.class);
|
40
|
+
exception.expectMessage("Field either 'columns' or 'schema_file' is required but not set");
|
41
|
+
}
|
42
|
+
*/
|
43
|
+
|
44
|
+
@Test
|
45
|
+
public void defaultValue()
|
46
|
+
{
|
47
|
+
String configYaml = "" +
|
48
|
+
"type: csv_with_header\n" +
|
49
|
+
"schema_line: 2";
|
50
|
+
ConfigSource config = getConfigFromYaml(configYaml);
|
51
|
+
PluginTask task = config.loadConfig(PluginTask.class);
|
52
|
+
|
53
|
+
assertFalse(task.getSchemaConfig().isPresent());
|
54
|
+
assertFalse(task.getSchemaFile().isPresent());
|
55
|
+
}
|
56
|
+
|
57
|
+
/*
|
58
|
+
@Test
|
59
|
+
public void originalCsvParserPlugin()
|
60
|
+
{
|
61
|
+
String configYaml = "" +
|
62
|
+
"type: csv_with_header\n" +
|
63
|
+
"columns:\n" +
|
64
|
+
" - {name: id, type: long}\n" +
|
65
|
+
" - {name: title, type: string}\n" +
|
66
|
+
" - {name: status, type: string}";
|
67
|
+
ConfigSource config = getConfigFromYaml(configYaml);
|
68
|
+
PluginTask task = config.loadConfig(PluginTask.class);
|
69
|
+
}
|
70
|
+
|
71
|
+
@Test
|
72
|
+
public void csvGuessable()
|
73
|
+
{
|
74
|
+
}
|
75
|
+
|
76
|
+
@Test
|
77
|
+
public void replaceColumnsName()
|
78
|
+
{
|
79
|
+
}
|
80
|
+
*/
|
81
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
in:
|
2
|
+
type: file
|
3
|
+
path_prefix: data/test
|
4
|
+
parser:
|
5
|
+
type: csv_guessable
|
6
|
+
schema_file: data/test.csv
|
7
|
+
schema_line: 1
|
8
|
+
columns:
|
9
|
+
- {value_name: '#', name: number, type: long}
|
10
|
+
- {value_name: 'title', name: description, type: string}
|
11
|
+
- {value_name: 'status', name: ok?, type: string}
|
12
|
+
out:
|
13
|
+
type: stdout
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-parser-csv_guessable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- koooge
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ~>
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.0'
|
19
|
+
name: bundler
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '10.0'
|
33
|
+
name: rake
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Parses Csv Guessable files read by other file input plugins.
|
42
|
+
email:
|
43
|
+
- koooooge@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- build.gradle
|
52
|
+
- config/checkstyle/checkstyle.xml
|
53
|
+
- config/checkstyle/default.xml
|
54
|
+
- gradle/wrapper/gradle-wrapper.jar
|
55
|
+
- gradle/wrapper/gradle-wrapper.properties
|
56
|
+
- gradlew
|
57
|
+
- gradlew.bat
|
58
|
+
- lib/embulk/guess/csv_guessable.rb
|
59
|
+
- lib/embulk/parser/csv_guessable.rb
|
60
|
+
- libs/embulk-standards-0.8.22.jar
|
61
|
+
- src/main/java/org/embulk/parser/csv_guessable/CsvGuessableParserPlugin.java
|
62
|
+
- src/main/java/org/embulk/parser/csv_guessable/CsvTokenizer.java
|
63
|
+
- src/test/java/org/embulk/parser/csv_guessable/TestCsvGuessableParserPlugin.java
|
64
|
+
- src/test/resources/data/test.csv
|
65
|
+
- src/test/resources/data/test_alias.yml
|
66
|
+
- src/test/resources/yml/guess_from_header.yml
|
67
|
+
- src/test/resources/yml/original-csv.yml
|
68
|
+
- src/test/resources/yml/replace_column_name.yml
|
69
|
+
- classpath/commons-lang3-3.5.jar
|
70
|
+
- classpath/embulk-parser-csv_guessable-0.1.1.jar
|
71
|
+
- classpath/opencsv-3.9.jar
|
72
|
+
- classpath/commons-beanutils-1.9.3.jar
|
73
|
+
- classpath/embulk-standards-0.8.22.jar
|
74
|
+
- classpath/commons-collections-3.2.2.jar
|
75
|
+
- classpath/commons-logging-1.2.jar
|
76
|
+
homepage: https://github.com/koooge/embulk-parser-csv_guessable
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.1.9
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Csv Guessable parser plugin for Embulk
|
100
|
+
test_files: []
|