embulk-filter-hash 0.1.2 → 0.2.0

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: 55e32c59aa1c3fc35b3ea853b56be1ade5eb7544
4
- data.tar.gz: 543dbf94ee96d0b2d8c5df445c02e1c38c5df69c
3
+ metadata.gz: 5ded1ac8ae36443e9654c2192980f2032b692e11
4
+ data.tar.gz: 379c360184e10e28c39eeaf1e7eccd25f582200f
5
5
  SHA512:
6
- metadata.gz: 00fed17b6821661a3d3770020e4f70c5d5340542d040bd2f18f46befe1d045a86af0f2942f1abec5477e5e48ca5e39215b8df5a8aabcebeffaaa6be1dbd5de41
7
- data.tar.gz: 6863c2ac3fbf8111efc9945f4b6963cdefe1eec6e8dc2a759620e17913e2561af5366fb6ecd56e564346f63f59c0bf3a913aaf4f58f62a9ef62add4052a1b2d3
6
+ metadata.gz: 72cfce290a43b1ff0df9f036482647fea65c589fc4ef2db8abfdb4f625c95902efb6216140b83f01546251ad2191406962ad04ea12ad1a3c22bfb20457ebe6f0
7
+ data.tar.gz: c333b812cc4807dd514682f8930a07400fc4d23851ee4010eaf6274021a83ce408c6db7d8b15cf819c7d9d1654508a668aaac3e54dbf551eaba799aad7bf2030
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ sudo: required
2
+
3
+ language: java
4
+
5
+ jdk:
6
+ - oraclejdk8
7
+
8
+ script:
9
+ - ./gradlew --info check
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/kamatama41/embulk-filter-hash.svg?branch=master)](https://travis-ci.org/kamatama41/embulk-filter-hash)
2
+
1
3
  # Hash filter plugin for Embulk
2
4
 
3
5
  Embulk filter plugin to convert a input to hash.
data/build.gradle CHANGED
@@ -7,18 +7,20 @@ import com.github.jrubygradle.JRubyExec
7
7
  repositories {
8
8
  mavenCentral()
9
9
  jcenter()
10
+ maven { url "http://kamatama41.github.com/embulk-test-helpers/repository" }
10
11
  }
11
12
  configurations {
12
13
  provided
13
14
  }
14
15
 
15
- version = "0.1.2"
16
+ version = "0.2.0"
16
17
 
17
18
  dependencies {
18
- compile "org.embulk:embulk-core:0.8.8"
19
- provided "org.embulk:embulk-core:0.8.8"
20
- // compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
21
- testCompile "junit:junit:4.+"
19
+ compile "org.embulk:embulk-core:0.8.16"
20
+ provided "org.embulk:embulk-core:0.8.16"
21
+ testCompile "com.kamatama41:embulk-test-helpers:0.1.1"
22
+ // Uncomment when using local embulk-test-helpers (and settings.gradle as well)
23
+ //testCompile project(':embulk-test-helpers')
22
24
  }
23
25
 
24
26
  task classpath(type: Copy, dependsOn: ["jar"]) {
Binary file
@@ -1,6 +1,6 @@
1
- #Tue Aug 11 00:26:20 PDT 2015
1
+ #Sun Jan 29 22:41:06 JST 2017
2
2
  distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
data/gradlew CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bash
1
+ #!/usr/bin/env sh
2
2
 
3
3
  ##############################################################################
4
4
  ##
@@ -6,12 +6,30 @@
6
6
  ##
7
7
  ##############################################################################
8
8
 
9
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10
- DEFAULT_JVM_OPTS=""
9
+ # Attempt to set APP_HOME
10
+ # Resolve links: $0 may be a link
11
+ PRG="$0"
12
+ # Need this for relative symlinks.
13
+ while [ -h "$PRG" ] ; do
14
+ ls=`ls -ld "$PRG"`
15
+ link=`expr "$ls" : '.*-> \(.*\)$'`
16
+ if expr "$link" : '/.*' > /dev/null; then
17
+ PRG="$link"
18
+ else
19
+ PRG=`dirname "$PRG"`"/$link"
20
+ fi
21
+ done
22
+ SAVED="`pwd`"
23
+ cd "`dirname \"$PRG\"`/" >/dev/null
24
+ APP_HOME="`pwd -P`"
25
+ cd "$SAVED" >/dev/null
11
26
 
12
27
  APP_NAME="Gradle"
13
28
  APP_BASE_NAME=`basename "$0"`
14
29
 
30
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31
+ DEFAULT_JVM_OPTS=""
32
+
15
33
  # Use the maximum available, or set MAX_FD != -1 to use that value.
16
34
  MAX_FD="maximum"
17
35
 
@@ -30,6 +48,7 @@ die ( ) {
30
48
  cygwin=false
31
49
  msys=false
32
50
  darwin=false
51
+ nonstop=false
33
52
  case "`uname`" in
34
53
  CYGWIN* )
35
54
  cygwin=true
@@ -40,31 +59,11 @@ case "`uname`" in
40
59
  MINGW* )
41
60
  msys=true
42
61
  ;;
62
+ NONSTOP* )
63
+ nonstop=true
64
+ ;;
43
65
  esac
44
66
 
45
- # For Cygwin, ensure paths are in UNIX format before anything is touched.
46
- if $cygwin ; then
47
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48
- fi
49
-
50
- # Attempt to set APP_HOME
51
- # Resolve links: $0 may be a link
52
- PRG="$0"
53
- # Need this for relative symlinks.
54
- while [ -h "$PRG" ] ; do
55
- ls=`ls -ld "$PRG"`
56
- link=`expr "$ls" : '.*-> \(.*\)$'`
57
- if expr "$link" : '/.*' > /dev/null; then
58
- PRG="$link"
59
- else
60
- PRG=`dirname "$PRG"`"/$link"
61
- fi
62
- done
63
- SAVED="`pwd`"
64
- cd "`dirname \"$PRG\"`/" >&-
65
- APP_HOME="`pwd -P`"
66
- cd "$SAVED" >&-
67
-
68
67
  CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69
68
 
70
69
  # Determine the Java command to use to start the JVM.
@@ -90,7 +89,7 @@ location of your Java installation."
90
89
  fi
91
90
 
92
91
  # Increase the maximum file descriptors if we can.
93
- if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
92
+ if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
94
93
  MAX_FD_LIMIT=`ulimit -H -n`
95
94
  if [ $? -eq 0 ] ; then
96
95
  if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -114,6 +113,7 @@ fi
114
113
  if $cygwin ; then
115
114
  APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116
115
  CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116
+ JAVACMD=`cygpath --unix "$JAVACMD"`
117
117
 
118
118
  # We build the pattern for arguments to be converted via cygpath
119
119
  ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -154,11 +154,19 @@ if $cygwin ; then
154
154
  esac
155
155
  fi
156
156
 
157
- # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158
- function splitJvmOpts() {
159
- JVM_OPTS=("$@")
157
+ # Escape application args
158
+ save ( ) {
159
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160
+ echo " "
160
161
  }
161
- eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162
- JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
162
+ APP_ARGS=$(save "$@")
163
+
164
+ # Collect all arguments for the java command, following the shell quoting and substitution rules
165
+ eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166
+
167
+ # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168
+ if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169
+ cd "$(dirname "$0")"
170
+ fi
163
171
 
164
- exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
172
+ exec "$JAVACMD" "$@"
data/gradlew.bat CHANGED
@@ -8,14 +8,14 @@
8
8
  @rem Set local scope for the variables with windows NT shell
9
9
  if "%OS%"=="Windows_NT" setlocal
10
10
 
11
- @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12
- set DEFAULT_JVM_OPTS=
13
-
14
11
  set DIRNAME=%~dp0
15
12
  if "%DIRNAME%" == "" set DIRNAME=.
16
13
  set APP_BASE_NAME=%~n0
17
14
  set APP_HOME=%DIRNAME%
18
15
 
16
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17
+ set DEFAULT_JVM_OPTS=
18
+
19
19
  @rem Find java.exe
20
20
  if defined JAVA_HOME goto findJavaFromJavaHome
21
21
 
@@ -46,10 +46,9 @@ echo location of your Java installation.
46
46
  goto fail
47
47
 
48
48
  :init
49
- @rem Get command-line arguments, handling Windowz variants
49
+ @rem Get command-line arguments, handling Windows variants
50
50
 
51
51
  if not "%OS%" == "Windows_NT" goto win9xME_args
52
- if "%@eval[2+2]" == "4" goto 4NT_args
53
52
 
54
53
  :win9xME_args
55
54
  @rem Slurp the command line arguments.
@@ -60,11 +59,6 @@ set _SKIP=2
60
59
  if "x%~1" == "x" goto execute
61
60
 
62
61
  set CMD_LINE_ARGS=%*
63
- goto execute
64
-
65
- :4NT_args
66
- @rem Get arguments from the 4NT Shell from JP Software
67
- set CMD_LINE_ARGS=%$
68
62
 
69
63
  :execute
70
64
  @rem Setup the command line
data/settings.gradle ADDED
@@ -0,0 +1,3 @@
1
+ // Uncomment when using local embulk-test-helpers (and build.gradle as well)
2
+ //include ':embulk-test-helpers'
3
+ //project(':embulk-test-helpers').projectDir = new File(settingsDir, '../embulk-test-helpers')
@@ -1,27 +1,90 @@
1
1
  package org.embulk.filter.hash;
2
2
 
3
- //import com.fasterxml.jackson.databind.ObjectMapper;
4
- //import com.google.inject.AbstractModule;
5
- //import com.google.inject.Guice;
6
- //import org.embulk.EmbulkEmbed;
7
- //import org.embulk.config.ConfigLoader;
8
- //import org.embulk.config.ModelManager;
9
- //import org.junit.Test;
10
- //
11
- //import java.io.File;
12
- //import java.io.IOException;
13
-
14
- public class TestHashFilterPlugin
15
- {
16
- // @Test
17
- // public void test() throws IOException {
18
- // EmbulkEmbed embed = new EmbulkEmbed.Bootstrap().initialize();
19
- // ConfigLoader loader = new ConfigLoader(new ModelManager(Guice.createInjector(new AbstractModule() {
20
- // @Override
21
- // protected void configure() {}
22
- // }),
23
- // new ObjectMapper()
24
- // ));
25
- // embed.run(loader.fromYamlFile(new File("./test.yml")));
26
- // }
3
+ import org.embulk.config.ConfigSource;
4
+ import org.embulk.spi.FilterPlugin;
5
+ import org.embulk.test.ExtendedTestingEmbulk;
6
+ import org.junit.Rule;
7
+ import org.junit.Test;
8
+
9
+ import java.util.Arrays;
10
+ import java.util.Collections;
11
+
12
+ import static org.embulk.spi.type.Types.STRING;
13
+ import static org.embulk.test.TestOutputPlugin.assertRecords;
14
+ import static org.embulk.test.TestOutputPlugin.assertSchema;
15
+ import static org.embulk.test.Utils.column;
16
+ import static org.embulk.test.Utils.record;
17
+
18
+ public class TestHashFilterPlugin {
19
+ @Rule
20
+ public ExtendedTestingEmbulk embulk = (ExtendedTestingEmbulk) ExtendedTestingEmbulk
21
+ .builder()
22
+ .registerPlugin(FilterPlugin.class, "hash", HashFilterPlugin.class)
23
+ .build();
24
+
25
+ @Test
26
+ public void specifiedColumnIsHashedAndRenamed() {
27
+ final String inConfigPath = "yaml/input_basic.yml";
28
+
29
+ ConfigSource config = embulk.newConfig()
30
+ .set("type", "hash")
31
+ .set("columns", Collections.singletonList(
32
+ config().set("name", "age").set("algorithm", "MD5").set("new_name", "hashed_age")
33
+ )
34
+ );
35
+
36
+ embulk.runFilter(config, inConfigPath);
37
+
38
+ assertSchema(
39
+ column("username", STRING),
40
+ column("hashed_age", STRING)
41
+ );
42
+
43
+ assertRecords(
44
+ record("user1", "98f13708210194c475687be6106a3b84")
45
+ );
46
+ }
47
+
48
+ @Test
49
+ public void allColumnTypesAreHashed() {
50
+ final String inConfigPath = "yaml/input_column_types.yml";
51
+
52
+ ConfigSource config = embulk.newConfig()
53
+ .set("type", "hash")
54
+ .set("columns", Arrays.asList(
55
+ config().set("name", "username"),
56
+ config().set("name", "age"),
57
+ config().set("name", "weight"),
58
+ config().set("name", "active"),
59
+ config().set("name", "created_at"),
60
+ config().set("name", "options")
61
+ )
62
+ );
63
+
64
+ embulk.runFilter(config, inConfigPath);
65
+
66
+ assertSchema(
67
+ column("username", STRING),
68
+ column("age", STRING),
69
+ column("weight", STRING),
70
+ column("active", STRING),
71
+ column("created_at", STRING),
72
+ column("options", STRING)
73
+ );
74
+
75
+ assertRecords(
76
+ record(
77
+ "0a041b9462caa4a31bac3567e0b6e6fd9100787db2ab433d96f6d178cabfce90",
78
+ "6f4b6612125fb3a0daecd2799dfd6c9c299424fd920f9b308110a2c1fbd8f443",
79
+ "70822ecbef5bee37d162492107a3127fc0a4de0564f34ce92713a7baaeb582b0",
80
+ "b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b",
81
+ "9673fe7b67d880e2c9071428c63f6e1bea9dde98283297277a20b92ea0acdc72",
82
+ "3ff0e331ca59a2a1194bac0e36359ed4540a97383e1cdf6eb95c7de9309143fc"
83
+ )
84
+ );
85
+ }
86
+
87
+ private ConfigSource config() {
88
+ return embulk.newConfig();
89
+ }
27
90
  }
@@ -0,0 +1,8 @@
1
+ type: test
2
+ data:
3
+ - user1,20
4
+ parser:
5
+ type: csv
6
+ columns:
7
+ - {name: username, type: string}
8
+ - {name: age, type: long}
@@ -0,0 +1,13 @@
1
+ type: test
2
+ data:
3
+ - >-
4
+ user1,21,65.4,true,2016-03-27 01:23:45,{"a":{"b":"c"}}"
5
+ parser:
6
+ type: csv
7
+ columns:
8
+ - {name: username, type: string}
9
+ - {name: age, type: long}
10
+ - {name: weight, type: double}
11
+ - {name: active, type: boolean}
12
+ - {name: created_at, type: timestamp, format: '%Y-%m-%d %H:%M:%S'}
13
+ - {name: options, type: json}
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-filter-hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinichi Ishimura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-24 00:00:00.000000000 Z
11
+ date: 2017-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
14
  requirement: !ruby/object:Gem::Requirement
21
15
  requirements:
22
16
  - - ~>
23
17
  - !ruby/object:Gem::Version
24
18
  version: '1.0'
19
+ name: bundler
25
20
  prerelease: false
26
21
  type: :development
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
22
  version_requirements: !ruby/object:Gem::Requirement
30
23
  requirements:
31
- - - '>='
24
+ - - ~>
32
25
  - !ruby/object:Gem::Version
33
- version: '10.0'
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
34
28
  requirement: !ruby/object:Gem::Requirement
35
29
  requirements:
36
30
  - - '>='
37
31
  - !ruby/object:Gem::Version
38
32
  version: '10.0'
33
+ name: rake
39
34
  prerelease: false
40
35
  type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
41
  description: Embulk filter plugin to convert a input to hash.
42
42
  email:
43
43
  - shiketaudonko41@gmail.com
@@ -46,6 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - .gitignore
49
+ - .travis.yml
49
50
  - LICENSE.txt
50
51
  - README.md
51
52
  - build.gradle
@@ -54,10 +55,12 @@ files:
54
55
  - gradlew
55
56
  - gradlew.bat
56
57
  - lib/embulk/filter/hash.rb
57
- - sample.csv
58
+ - settings.gradle
58
59
  - src/main/java/org/embulk/filter/hash/HashFilterPlugin.java
59
60
  - src/test/java/org/embulk/filter/hash/TestHashFilterPlugin.java
60
- - classpath/embulk-filter-hash-0.1.2.jar
61
+ - src/test/resources/yaml/input_basic.yml
62
+ - src/test/resources/yaml/input_column_types.yml
63
+ - classpath/embulk-filter-hash-0.2.0.jar
61
64
  homepage: https://github.com/kamatama41/embulk-filter-hash
62
65
  licenses:
63
66
  - MIT
data/sample.csv DELETED
@@ -1,2 +0,0 @@
1
- id,name,json
2
- 1,あ,{"a":{"b":"c"}}