embulk-parser-jsonpath 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +107 -0
- data/build.gradle +111 -0
- data/config/checkstyle/checkstyle.xml +128 -0
- data/config/checkstyle/default.xml +108 -0
- data/example/conf.yml +18 -0
- data/example/dummy.rb +27 -0
- data/example/input.json +1006 -0
- data/example/input2.json +1006 -0
- data/example/seed.yml +8 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/gradlew +160 -0
- data/gradlew.bat +90 -0
- data/lib/embulk/guess/jsonpath.rb +61 -0
- data/lib/embulk/parser/jsonpath.rb +3 -0
- data/src/main/java/org/embulk/parser/jsonpath/ColumnCaster.java +97 -0
- data/src/main/java/org/embulk/parser/jsonpath/ColumnVisitorImpl.java +167 -0
- data/src/main/java/org/embulk/parser/jsonpath/JsonRecordValidateException.java +22 -0
- data/src/main/java/org/embulk/parser/jsonpath/JsonpathParserPlugin.java +148 -0
- data/src/main/java/org/embulk/parser/jsonpath/cast/BooleanCast.java +39 -0
- data/src/main/java/org/embulk/parser/jsonpath/cast/DoubleCast.java +41 -0
- data/src/main/java/org/embulk/parser/jsonpath/cast/JsonCast.java +40 -0
- data/src/main/java/org/embulk/parser/jsonpath/cast/LongCast.java +47 -0
- data/src/main/java/org/embulk/parser/jsonpath/cast/StringCast.java +82 -0
- data/src/test/java/org/embulk/parser/jsonpath/TestColumnCaster.java +256 -0
- data/src/test/java/org/embulk/parser/jsonpath/TestJsonpathParserPlugin.java +292 -0
- data/src/test/java/org/embulk/parser/jsonpath/cast/TestBooleanCast.java +56 -0
- data/src/test/java/org/embulk/parser/jsonpath/cast/TestDoubleCast.java +49 -0
- data/src/test/java/org/embulk/parser/jsonpath/cast/TestJsonCast.java +79 -0
- data/src/test/java/org/embulk/parser/jsonpath/cast/TestLongCast.java +41 -0
- data/src/test/java/org/embulk/parser/jsonpath/cast/TestStringCast.java +103 -0
- metadata +113 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
package org.embulk.parser.jsonpath.cast;
|
2
|
+
|
3
|
+
import org.embulk.spi.time.Timestamp;
|
4
|
+
import org.junit.Test;
|
5
|
+
|
6
|
+
import static org.junit.Assert.assertEquals;
|
7
|
+
|
8
|
+
public class TestLongCast
|
9
|
+
{
|
10
|
+
@Test
|
11
|
+
public void asBoolean()
|
12
|
+
{
|
13
|
+
assertEquals(true, LongCast.asBoolean(1));
|
14
|
+
assertEquals(false, LongCast.asBoolean(0));
|
15
|
+
}
|
16
|
+
|
17
|
+
@Test
|
18
|
+
public void asLong()
|
19
|
+
{
|
20
|
+
assertEquals(1, LongCast.asLong(1));
|
21
|
+
}
|
22
|
+
|
23
|
+
@Test
|
24
|
+
public void asDouble()
|
25
|
+
{
|
26
|
+
assertEquals(1.0, LongCast.asDouble(1), 0.0);
|
27
|
+
}
|
28
|
+
|
29
|
+
@Test
|
30
|
+
public void asString()
|
31
|
+
{
|
32
|
+
assertEquals("1", LongCast.asString(1));
|
33
|
+
}
|
34
|
+
|
35
|
+
@Test
|
36
|
+
public void asTimestamp()
|
37
|
+
{
|
38
|
+
Timestamp expected = Timestamp.ofEpochSecond(1);
|
39
|
+
assertEquals(expected, LongCast.asTimestamp(1));
|
40
|
+
}
|
41
|
+
}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
package org.embulk.parser.jsonpath.cast;
|
2
|
+
|
3
|
+
import org.embulk.EmbulkTestRuntime;
|
4
|
+
import org.embulk.spi.DataException;
|
5
|
+
import org.embulk.spi.time.Timestamp;
|
6
|
+
import org.embulk.spi.time.TimestampParser;
|
7
|
+
import org.joda.time.DateTimeZone;
|
8
|
+
import org.jruby.embed.ScriptingContainer;
|
9
|
+
import org.junit.Before;
|
10
|
+
import org.junit.Rule;
|
11
|
+
import org.junit.Test;
|
12
|
+
|
13
|
+
import static org.junit.Assert.assertEquals;
|
14
|
+
import static org.junit.Assert.assertTrue;
|
15
|
+
import static org.junit.Assert.fail;
|
16
|
+
|
17
|
+
public class TestStringCast
|
18
|
+
{
|
19
|
+
@Rule
|
20
|
+
public EmbulkTestRuntime runtime = new EmbulkTestRuntime();
|
21
|
+
public ScriptingContainer jruby;
|
22
|
+
|
23
|
+
@Before
|
24
|
+
public void createResource()
|
25
|
+
{
|
26
|
+
jruby = new ScriptingContainer();
|
27
|
+
}
|
28
|
+
|
29
|
+
@Test
|
30
|
+
public void asBoolean()
|
31
|
+
{
|
32
|
+
for (String str : StringCast.TRUE_STRINGS) {
|
33
|
+
assertEquals(true, StringCast.asBoolean(str));
|
34
|
+
}
|
35
|
+
for (String str : StringCast.FALSE_STRINGS) {
|
36
|
+
assertEquals(false, StringCast.asBoolean(str));
|
37
|
+
}
|
38
|
+
try {
|
39
|
+
StringCast.asBoolean("foo");
|
40
|
+
}
|
41
|
+
catch (Throwable t) {
|
42
|
+
assertTrue(t instanceof DataException);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
@Test
|
47
|
+
public void asLong()
|
48
|
+
{
|
49
|
+
assertEquals(1, StringCast.asLong("1"));
|
50
|
+
try {
|
51
|
+
StringCast.asLong("1.5");
|
52
|
+
fail();
|
53
|
+
}
|
54
|
+
catch (Throwable t) {
|
55
|
+
assertTrue(t instanceof DataException);
|
56
|
+
}
|
57
|
+
try {
|
58
|
+
StringCast.asLong("foo");
|
59
|
+
fail();
|
60
|
+
}
|
61
|
+
catch (Throwable t) {
|
62
|
+
assertTrue(t instanceof DataException);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
@Test
|
67
|
+
public void asDouble()
|
68
|
+
{
|
69
|
+
assertEquals(1.0, StringCast.asDouble("1"), 0.0);
|
70
|
+
assertEquals(1.5, StringCast.asDouble("1.5"), 0.0);
|
71
|
+
try {
|
72
|
+
StringCast.asDouble("foo");
|
73
|
+
fail();
|
74
|
+
}
|
75
|
+
catch (Throwable t) {
|
76
|
+
assertTrue(t instanceof DataException);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
@Test
|
81
|
+
public void asString()
|
82
|
+
{
|
83
|
+
assertEquals("1", StringCast.asString("1"));
|
84
|
+
assertEquals("1.5", StringCast.asString("1.5"));
|
85
|
+
assertEquals("foo", StringCast.asString("foo"));
|
86
|
+
}
|
87
|
+
|
88
|
+
@Test
|
89
|
+
public void asTimestamp()
|
90
|
+
{
|
91
|
+
Timestamp expected = Timestamp.ofEpochSecond(1463084053, 123456000);
|
92
|
+
TimestampParser parser = new TimestampParser(jruby, "%Y-%m-%d %H:%M:%S.%N", DateTimeZone.UTC);
|
93
|
+
assertEquals(expected, StringCast.asTimestamp("2016-05-12 20:14:13.123456", parser));
|
94
|
+
|
95
|
+
try {
|
96
|
+
StringCast.asTimestamp("foo", parser);
|
97
|
+
fail();
|
98
|
+
}
|
99
|
+
catch (Throwable t) {
|
100
|
+
assertTrue(t instanceof DataException);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-parser-jsonpath
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hiroyuki Sato
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-29 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 Jsonpath files read by other file input plugins.
|
42
|
+
email:
|
43
|
+
- hiroysato@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .travis.yml
|
50
|
+
- CHANGELOG.md
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- build.gradle
|
54
|
+
- config/checkstyle/checkstyle.xml
|
55
|
+
- config/checkstyle/default.xml
|
56
|
+
- example/conf.yml
|
57
|
+
- example/dummy.rb
|
58
|
+
- example/input.json
|
59
|
+
- example/input2.json
|
60
|
+
- example/seed.yml
|
61
|
+
- gradle/wrapper/gradle-wrapper.jar
|
62
|
+
- gradle/wrapper/gradle-wrapper.properties
|
63
|
+
- gradlew
|
64
|
+
- gradlew.bat
|
65
|
+
- lib/embulk/guess/jsonpath.rb
|
66
|
+
- lib/embulk/parser/jsonpath.rb
|
67
|
+
- src/main/java/org/embulk/parser/jsonpath/ColumnCaster.java
|
68
|
+
- src/main/java/org/embulk/parser/jsonpath/ColumnVisitorImpl.java
|
69
|
+
- src/main/java/org/embulk/parser/jsonpath/JsonRecordValidateException.java
|
70
|
+
- src/main/java/org/embulk/parser/jsonpath/JsonpathParserPlugin.java
|
71
|
+
- src/main/java/org/embulk/parser/jsonpath/cast/BooleanCast.java
|
72
|
+
- src/main/java/org/embulk/parser/jsonpath/cast/DoubleCast.java
|
73
|
+
- src/main/java/org/embulk/parser/jsonpath/cast/JsonCast.java
|
74
|
+
- src/main/java/org/embulk/parser/jsonpath/cast/LongCast.java
|
75
|
+
- src/main/java/org/embulk/parser/jsonpath/cast/StringCast.java
|
76
|
+
- src/test/java/org/embulk/parser/jsonpath/TestColumnCaster.java
|
77
|
+
- src/test/java/org/embulk/parser/jsonpath/TestJsonpathParserPlugin.java
|
78
|
+
- src/test/java/org/embulk/parser/jsonpath/cast/TestBooleanCast.java
|
79
|
+
- src/test/java/org/embulk/parser/jsonpath/cast/TestDoubleCast.java
|
80
|
+
- src/test/java/org/embulk/parser/jsonpath/cast/TestJsonCast.java
|
81
|
+
- src/test/java/org/embulk/parser/jsonpath/cast/TestLongCast.java
|
82
|
+
- src/test/java/org/embulk/parser/jsonpath/cast/TestStringCast.java
|
83
|
+
- classpath/accessors-smart-1.1.jar
|
84
|
+
- classpath/asm-5.0.3.jar
|
85
|
+
- classpath/embulk-parser-jsonpath-0.1.0.jar
|
86
|
+
- classpath/json-path-2.2.0.jar
|
87
|
+
- classpath/json-smart-2.2.1.jar
|
88
|
+
- classpath/slf4j-api-1.7.16.jar
|
89
|
+
homepage: https://github.com/hiroyuki-sato/embulk-parser-jsonpath
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.1.9
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Jsonpath parser plugin for Embulk
|
113
|
+
test_files: []
|