embulk-input-twitter_search 0.1.0
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 +13 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/build.gradle +114 -0
- data/classpath/embulk-input-twitter_search-0.1.0.jar +0 -0
- data/classpath/log4j-1.2.17.jar +0 -0
- data/classpath/slf4j-api-1.7.21.jar +0 -0
- data/classpath/slf4j-log4j12-1.7.21.jar +0 -0
- data/classpath/twitter4j-core-4.0.7.jar +0 -0
- data/config/checkstyle/checkstyle.xml +130 -0
- data/config/checkstyle/default.xml +110 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +5 -0
- data/gradlew +172 -0
- data/gradlew.bat +84 -0
- data/lib/embulk/input/twitter_search.rb +3 -0
- data/src/main/java/org/embulk/input/twitter_search/TwitterSearch.java +89 -0
- data/src/main/java/org/embulk/input/twitter_search/TwitterSearchInputPlugin.java +90 -0
- data/src/main/resources/log4j.properties +2 -0
- data/src/test/java/org/embulk/input/twitter_search/TestTwitterSearch.java +86 -0
- data/src/test/java/org/embulk/input/twitter_search/TestTwitterSearchInputPlugin.java +25 -0
- data/src/test/resources/java/org/embulk/input/twitter_search/test.yml +8 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9f59f9267526027e1aae58a316aee8ced590cd15
|
4
|
+
data.tar.gz: 2ab082d6ab1cf6eebf0a327157b4ddc32425b8c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e3fecb8c9d5d4e51953dc5a22099ba4862fc8d325f729ab454731a51406c1c693d16c05c3e0e50ffc0aac06394d113bca05711f47b357a5a9c9775a55f467794
|
7
|
+
data.tar.gz: 605fe9ce2d9830d33647d2bd44cbcbed038040591362efa9e7478bce766897e490aad332b30004a5d2b35018f066929b0b13ae78a7af0e1af666488ed2a05623
|
data/.gitignore
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Twitter Search input plugin for Embulk
|
2
|
+
|
3
|
+
Input Twitter Search API plugin for Embulk.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
* **Plugin type**: input
|
8
|
+
* **Resume supported**: no
|
9
|
+
* **Cleanup supported**: no
|
10
|
+
* **Guess supported**: no
|
11
|
+
|
12
|
+
## Example
|
13
|
+
|
14
|
+
```yaml
|
15
|
+
input:
|
16
|
+
type: twitter_search
|
17
|
+
auth:
|
18
|
+
consumer_key: "sample_consumer_key"
|
19
|
+
consumer_secret: "sample_consumer_secret"
|
20
|
+
access_token: "sample_access_token"
|
21
|
+
access_secret: "sample_access_secret"
|
22
|
+
queries:
|
23
|
+
- "from:@nishiogi_now exclude:retweets"
|
24
|
+
```
|
25
|
+
|
26
|
+
## TODO
|
27
|
+
|
28
|
+
- exp backeff and full-jitter
|
29
|
+
- Resume and Cleanup
|
data/build.gradle
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
plugins {
|
2
|
+
id "com.jfrog.bintray" version "1.1"
|
3
|
+
id "com.github.jruby-gradle.base" version "1.5.0"
|
4
|
+
id "java"
|
5
|
+
id "checkstyle"
|
6
|
+
}
|
7
|
+
import com.github.jrubygradle.JRubyExec
|
8
|
+
repositories {
|
9
|
+
mavenCentral()
|
10
|
+
jcenter()
|
11
|
+
}
|
12
|
+
configurations {
|
13
|
+
provided
|
14
|
+
}
|
15
|
+
|
16
|
+
version = "0.1.0"
|
17
|
+
|
18
|
+
sourceCompatibility = 1.8
|
19
|
+
targetCompatibility = 1.8
|
20
|
+
|
21
|
+
dependencies {
|
22
|
+
compile "org.embulk:embulk-core:0.9.23"
|
23
|
+
provided "org.embulk:embulk-core:0.9.23"
|
24
|
+
compile "org.twitter4j:twitter4j-core:4.0.7"
|
25
|
+
compile "org.slf4j:slf4j-log4j12:1.7.21"
|
26
|
+
// compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
|
27
|
+
testCompile "junit:junit:4.12"
|
28
|
+
testCompile "org.mockito:mockito-all:1.10.19"
|
29
|
+
testCompile 'org.powermock:powermock-module-junit4:1.6.4'
|
30
|
+
testCompile 'org.powermock:powermock-api-mockito:1.6.4'
|
31
|
+
testCompile 'org.embulk:embulk-test:0.9.23'
|
32
|
+
testCompile "org.embulk:embulk-deps-buffer:0.9.23"
|
33
|
+
testCompile "org.embulk:embulk-deps-config:0.9.23"
|
34
|
+
}
|
35
|
+
|
36
|
+
test {
|
37
|
+
dependsOn cleanTest
|
38
|
+
testLogging.showStandardStreams = true
|
39
|
+
}
|
40
|
+
|
41
|
+
checkstyle {
|
42
|
+
configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
|
43
|
+
toolVersion = '6.14.1'
|
44
|
+
}
|
45
|
+
|
46
|
+
checkstyleMain {
|
47
|
+
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
|
48
|
+
ignoreFailures = true
|
49
|
+
}
|
50
|
+
|
51
|
+
checkstyleTest {
|
52
|
+
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
|
53
|
+
ignoreFailures = true
|
54
|
+
}
|
55
|
+
|
56
|
+
task checkstyle(type: Checkstyle) {
|
57
|
+
classpath = sourceSets.main.output + sourceSets.test.output
|
58
|
+
source = sourceSets.main.allJava + sourceSets.test.allJava
|
59
|
+
}
|
60
|
+
|
61
|
+
task classpath(type: Copy, dependsOn: ["jar"]) {
|
62
|
+
doFirst { file("classpath").deleteDir() }
|
63
|
+
from (configurations.runtime - configurations.provided + files(jar.archivePath))
|
64
|
+
into "classpath"
|
65
|
+
}
|
66
|
+
clean { delete "classpath" }
|
67
|
+
|
68
|
+
task gem(type: JRubyExec, dependsOn: ["gemspec", "classpath"]) {
|
69
|
+
jrubyArgs "-S"
|
70
|
+
script "gem"
|
71
|
+
scriptArgs "build", "${project.name}.gemspec"
|
72
|
+
doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
|
73
|
+
}
|
74
|
+
|
75
|
+
task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
|
76
|
+
jrubyArgs "-S"
|
77
|
+
script "gem"
|
78
|
+
scriptArgs "push", "pkg/${project.name}-${project.version}.gem"
|
79
|
+
}
|
80
|
+
|
81
|
+
task "package"(dependsOn: ["gemspec", "classpath"]) {
|
82
|
+
doLast {
|
83
|
+
println "> Build succeeded."
|
84
|
+
println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
task gemspec {
|
89
|
+
ext.gemspecFile = file("${project.name}.gemspec")
|
90
|
+
inputs.file "build.gradle"
|
91
|
+
outputs.file gemspecFile
|
92
|
+
doLast { gemspecFile.write($/
|
93
|
+
Gem::Specification.new do |spec|
|
94
|
+
spec.name = "${project.name}"
|
95
|
+
spec.version = "${project.version}"
|
96
|
+
spec.authors = ["KentFujii"]
|
97
|
+
spec.summary = %[Twitter Search input plugin for Embulk]
|
98
|
+
spec.description = %[Loads records from Twitter Search.]
|
99
|
+
spec.email = ["kent.where.the.light.is@gmail.com"]
|
100
|
+
spec.licenses = ["MIT"]
|
101
|
+
# TODO set this: spec.homepage = "https://github.com/kent.where.the.light.is/embulk-input-twitter_search"
|
102
|
+
|
103
|
+
spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
|
104
|
+
spec.test_files = spec.files.grep(%r"^(test|spec)/")
|
105
|
+
spec.require_paths = ["lib"]
|
106
|
+
|
107
|
+
#spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
|
108
|
+
spec.add_development_dependency 'bundler', ['~> 1.0']
|
109
|
+
spec.add_development_dependency 'rake', ['~> 12.0']
|
110
|
+
end
|
111
|
+
/$)
|
112
|
+
}
|
113
|
+
}
|
114
|
+
clean { delete "${project.name}.gemspec" }
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,130 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE module PUBLIC
|
3
|
+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
4
|
+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
5
|
+
<module name="Checker">
|
6
|
+
<!-- https://github.com/facebook/presto/blob/master/src/checkstyle/checks.xml -->
|
7
|
+
<property name="localeCountry" value="JP"/>
|
8
|
+
<property name="localeLanguage" value="en"/>
|
9
|
+
<module name="FileTabCharacter"/>
|
10
|
+
<module name="NewlineAtEndOfFile">
|
11
|
+
<property name="lineSeparator" value="lf"/>
|
12
|
+
</module>
|
13
|
+
<module name="RegexpMultiline">
|
14
|
+
<property name="format" value="\r"/>
|
15
|
+
<property name="message" value="Line contains carriage return"/>
|
16
|
+
</module>
|
17
|
+
<module name="RegexpMultiline">
|
18
|
+
<property name="format" value=" \n"/>
|
19
|
+
<property name="message" value="Line has trailing whitespace"/>
|
20
|
+
</module>
|
21
|
+
<module name="RegexpMultiline">
|
22
|
+
<property name="format" value="\{\n\n"/>
|
23
|
+
<property name="message" value="Blank line after opening brace"/>
|
24
|
+
</module>
|
25
|
+
<module name="RegexpMultiline">
|
26
|
+
<property name="format" value="\n\n\s*\}"/>
|
27
|
+
<property name="message" value="Blank line before closing brace"/>
|
28
|
+
</module>
|
29
|
+
<module name="RegexpMultiline">
|
30
|
+
<property name="format" value="\n\n\n"/>
|
31
|
+
<property name="message" value="Multiple consecutive blank lines"/>
|
32
|
+
</module>
|
33
|
+
<module name="RegexpMultiline">
|
34
|
+
<property name="format" value="\n\n\Z"/>
|
35
|
+
<property name="message" value="Blank line before end of file"/>
|
36
|
+
</module>
|
37
|
+
<module name="RegexpMultiline">
|
38
|
+
<property name="format" value="Preconditions\.checkNotNull"/>
|
39
|
+
<property name="message" value="Use of checkNotNull"/>
|
40
|
+
</module>
|
41
|
+
|
42
|
+
<module name="TreeWalker">
|
43
|
+
<module name="EmptyBlock">
|
44
|
+
<property name="option" value="text"/>
|
45
|
+
<property name="tokens" value="
|
46
|
+
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
|
47
|
+
LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
|
48
|
+
</module>
|
49
|
+
<module name="EmptyStatement"/>
|
50
|
+
<module name="EmptyForInitializerPad"/>
|
51
|
+
<module name="EmptyForIteratorPad">
|
52
|
+
<property name="option" value="space"/>
|
53
|
+
</module>
|
54
|
+
<module name="MethodParamPad">
|
55
|
+
<property name="allowLineBreaks" value="true"/>
|
56
|
+
<property name="option" value="nospace"/>
|
57
|
+
</module>
|
58
|
+
<module name="ParenPad"/>
|
59
|
+
<module name="TypecastParenPad"/>
|
60
|
+
<module name="NeedBraces"/>
|
61
|
+
<module name="LeftCurly">
|
62
|
+
<property name="option" value="nl"/>
|
63
|
+
<property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
|
64
|
+
</module>
|
65
|
+
<module name="LeftCurly">
|
66
|
+
<property name="option" value="eol"/>
|
67
|
+
<property name="tokens" value="
|
68
|
+
LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
|
69
|
+
LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
|
70
|
+
</module>
|
71
|
+
<module name="RightCurly">
|
72
|
+
<property name="option" value="alone"/>
|
73
|
+
</module>
|
74
|
+
<module name="GenericWhitespace"/>
|
75
|
+
<module name="WhitespaceAfter"/>
|
76
|
+
<module name="NoWhitespaceBefore"/>
|
77
|
+
|
78
|
+
<module name="UpperEll"/>
|
79
|
+
<module name="DefaultComesLast"/>
|
80
|
+
<module name="ArrayTypeStyle"/>
|
81
|
+
<module name="MultipleVariableDeclarations"/>
|
82
|
+
<module name="ModifierOrder"/>
|
83
|
+
<module name="OneStatementPerLine"/>
|
84
|
+
<module name="StringLiteralEquality"/>
|
85
|
+
<module name="MutableException"/>
|
86
|
+
<module name="EqualsHashCode"/>
|
87
|
+
<module name="InnerAssignment"/>
|
88
|
+
<module name="InterfaceIsType"/>
|
89
|
+
<module name="HideUtilityClassConstructor"/>
|
90
|
+
|
91
|
+
<module name="MemberName"/>
|
92
|
+
<module name="LocalVariableName"/>
|
93
|
+
<module name="LocalFinalVariableName"/>
|
94
|
+
<module name="TypeName"/>
|
95
|
+
<module name="PackageName"/>
|
96
|
+
<module name="ParameterName"/>
|
97
|
+
<module name="StaticVariableName"/>
|
98
|
+
<module name="ClassTypeParameterName">
|
99
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
100
|
+
</module>
|
101
|
+
<module name="MethodTypeParameterName">
|
102
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
103
|
+
</module>
|
104
|
+
|
105
|
+
<module name="AvoidStarImport"/>
|
106
|
+
<module name="RedundantImport"/>
|
107
|
+
<module name="UnusedImports"/>
|
108
|
+
<module name="ImportOrder">
|
109
|
+
<property name="groups" value="*,javax,java"/>
|
110
|
+
<property name="separated" value="true"/>
|
111
|
+
<property name="option" value="bottom"/>
|
112
|
+
<property name="sortStaticImportsAlphabetically" value="true"/>
|
113
|
+
</module>
|
114
|
+
|
115
|
+
<module name="WhitespaceAround">
|
116
|
+
<property name="allowEmptyConstructors" value="true"/>
|
117
|
+
<property name="allowEmptyMethods" value="true"/>
|
118
|
+
<property name="ignoreEnhancedForColon" value="false"/>
|
119
|
+
<property name="tokens" value="
|
120
|
+
ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
|
121
|
+
BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
|
122
|
+
LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
|
123
|
+
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
|
124
|
+
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
|
125
|
+
LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
|
126
|
+
PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
|
127
|
+
STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
|
128
|
+
</module>
|
129
|
+
</module>
|
130
|
+
</module>
|
@@ -0,0 +1,110 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE module PUBLIC
|
3
|
+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
4
|
+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
5
|
+
<!--
|
6
|
+
This is a subset of ./checkstyle.xml which allows some loose styles
|
7
|
+
-->
|
8
|
+
<module name="Checker">
|
9
|
+
<property name="localeCountry" value="JP"/>
|
10
|
+
<property name="localeLanguage" value="en"/>
|
11
|
+
<module name="FileTabCharacter"/>
|
12
|
+
<module name="NewlineAtEndOfFile">
|
13
|
+
<property name="lineSeparator" value="lf"/>
|
14
|
+
</module>
|
15
|
+
<module name="RegexpMultiline">
|
16
|
+
<property name="format" value="\r"/>
|
17
|
+
<property name="message" value="Line contains carriage return"/>
|
18
|
+
</module>
|
19
|
+
<module name="RegexpMultiline">
|
20
|
+
<property name="format" value=" \n"/>
|
21
|
+
<property name="message" value="Line has trailing whitespace"/>
|
22
|
+
</module>
|
23
|
+
<module name="RegexpMultiline">
|
24
|
+
<property name="format" value="\n\n\n"/>
|
25
|
+
<property name="message" value="Multiple consecutive blank lines"/>
|
26
|
+
</module>
|
27
|
+
<module name="RegexpMultiline">
|
28
|
+
<property name="format" value="\n\n\Z"/>
|
29
|
+
<property name="message" value="Blank line before end of file"/>
|
30
|
+
</module>
|
31
|
+
|
32
|
+
<module name="TreeWalker">
|
33
|
+
<module name="EmptyBlock">
|
34
|
+
<property name="option" value="text"/>
|
35
|
+
<property name="tokens" value="
|
36
|
+
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
|
37
|
+
LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
|
38
|
+
</module>
|
39
|
+
<module name="EmptyStatement"/>
|
40
|
+
<module name="EmptyForInitializerPad"/>
|
41
|
+
<module name="EmptyForIteratorPad">
|
42
|
+
<property name="option" value="space"/>
|
43
|
+
</module>
|
44
|
+
<module name="MethodParamPad">
|
45
|
+
<property name="allowLineBreaks" value="true"/>
|
46
|
+
<property name="option" value="nospace"/>
|
47
|
+
</module>
|
48
|
+
<module name="ParenPad"/>
|
49
|
+
<module name="TypecastParenPad"/>
|
50
|
+
<module name="NeedBraces"/>
|
51
|
+
<module name="LeftCurly">
|
52
|
+
<property name="option" value="nl"/>
|
53
|
+
<property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
|
54
|
+
</module>
|
55
|
+
<module name="LeftCurly">
|
56
|
+
<property name="option" value="eol"/>
|
57
|
+
<property name="tokens" value="
|
58
|
+
LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
|
59
|
+
LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
|
60
|
+
</module>
|
61
|
+
<module name="RightCurly">
|
62
|
+
<property name="option" value="alone"/>
|
63
|
+
</module>
|
64
|
+
<module name="GenericWhitespace"/>
|
65
|
+
<module name="WhitespaceAfter"/>
|
66
|
+
<module name="NoWhitespaceBefore"/>
|
67
|
+
|
68
|
+
<module name="UpperEll"/>
|
69
|
+
<module name="DefaultComesLast"/>
|
70
|
+
<module name="ArrayTypeStyle"/>
|
71
|
+
<module name="MultipleVariableDeclarations"/>
|
72
|
+
<module name="ModifierOrder"/>
|
73
|
+
<module name="OneStatementPerLine"/>
|
74
|
+
<module name="StringLiteralEquality"/>
|
75
|
+
<module name="MutableException"/>
|
76
|
+
<module name="EqualsHashCode"/>
|
77
|
+
<module name="InnerAssignment"/>
|
78
|
+
<module name="InterfaceIsType"/>
|
79
|
+
<module name="HideUtilityClassConstructor"/>
|
80
|
+
|
81
|
+
<module name="MemberName"/>
|
82
|
+
<module name="LocalVariableName"/>
|
83
|
+
<module name="LocalFinalVariableName"/>
|
84
|
+
<module name="TypeName"/>
|
85
|
+
<module name="PackageName"/>
|
86
|
+
<module name="ParameterName"/>
|
87
|
+
<module name="StaticVariableName"/>
|
88
|
+
<module name="ClassTypeParameterName">
|
89
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
90
|
+
</module>
|
91
|
+
<module name="MethodTypeParameterName">
|
92
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
93
|
+
</module>
|
94
|
+
|
95
|
+
<module name="WhitespaceAround">
|
96
|
+
<property name="allowEmptyConstructors" value="true"/>
|
97
|
+
<property name="allowEmptyMethods" value="true"/>
|
98
|
+
<property name="ignoreEnhancedForColon" value="false"/>
|
99
|
+
<property name="tokens" value="
|
100
|
+
ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
|
101
|
+
BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
|
102
|
+
LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
|
103
|
+
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
|
104
|
+
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
|
105
|
+
LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
|
106
|
+
PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
|
107
|
+
STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
|
108
|
+
</module>
|
109
|
+
</module>
|
110
|
+
</module>
|
Binary file
|
data/gradlew
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
#!/usr/bin/env sh
|
2
|
+
|
3
|
+
##############################################################################
|
4
|
+
##
|
5
|
+
## Gradle start up script for UN*X
|
6
|
+
##
|
7
|
+
##############################################################################
|
8
|
+
|
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
|
26
|
+
|
27
|
+
APP_NAME="Gradle"
|
28
|
+
APP_BASE_NAME=`basename "$0"`
|
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
|
+
|
33
|
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
34
|
+
MAX_FD="maximum"
|
35
|
+
|
36
|
+
warn () {
|
37
|
+
echo "$*"
|
38
|
+
}
|
39
|
+
|
40
|
+
die () {
|
41
|
+
echo
|
42
|
+
echo "$*"
|
43
|
+
echo
|
44
|
+
exit 1
|
45
|
+
}
|
46
|
+
|
47
|
+
# OS specific support (must be 'true' or 'false').
|
48
|
+
cygwin=false
|
49
|
+
msys=false
|
50
|
+
darwin=false
|
51
|
+
nonstop=false
|
52
|
+
case "`uname`" in
|
53
|
+
CYGWIN* )
|
54
|
+
cygwin=true
|
55
|
+
;;
|
56
|
+
Darwin* )
|
57
|
+
darwin=true
|
58
|
+
;;
|
59
|
+
MINGW* )
|
60
|
+
msys=true
|
61
|
+
;;
|
62
|
+
NONSTOP* )
|
63
|
+
nonstop=true
|
64
|
+
;;
|
65
|
+
esac
|
66
|
+
|
67
|
+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
68
|
+
|
69
|
+
# Determine the Java command to use to start the JVM.
|
70
|
+
if [ -n "$JAVA_HOME" ] ; then
|
71
|
+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
72
|
+
# IBM's JDK on AIX uses strange locations for the executables
|
73
|
+
JAVACMD="$JAVA_HOME/jre/sh/java"
|
74
|
+
else
|
75
|
+
JAVACMD="$JAVA_HOME/bin/java"
|
76
|
+
fi
|
77
|
+
if [ ! -x "$JAVACMD" ] ; then
|
78
|
+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
79
|
+
|
80
|
+
Please set the JAVA_HOME variable in your environment to match the
|
81
|
+
location of your Java installation."
|
82
|
+
fi
|
83
|
+
else
|
84
|
+
JAVACMD="java"
|
85
|
+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
86
|
+
|
87
|
+
Please set the JAVA_HOME variable in your environment to match the
|
88
|
+
location of your Java installation."
|
89
|
+
fi
|
90
|
+
|
91
|
+
# Increase the maximum file descriptors if we can.
|
92
|
+
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
93
|
+
MAX_FD_LIMIT=`ulimit -H -n`
|
94
|
+
if [ $? -eq 0 ] ; then
|
95
|
+
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
96
|
+
MAX_FD="$MAX_FD_LIMIT"
|
97
|
+
fi
|
98
|
+
ulimit -n $MAX_FD
|
99
|
+
if [ $? -ne 0 ] ; then
|
100
|
+
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
101
|
+
fi
|
102
|
+
else
|
103
|
+
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
104
|
+
fi
|
105
|
+
fi
|
106
|
+
|
107
|
+
# For Darwin, add options to specify how the application appears in the dock
|
108
|
+
if $darwin; then
|
109
|
+
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
110
|
+
fi
|
111
|
+
|
112
|
+
# For Cygwin, switch paths to Windows format before running java
|
113
|
+
if $cygwin ; then
|
114
|
+
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
115
|
+
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
116
|
+
JAVACMD=`cygpath --unix "$JAVACMD"`
|
117
|
+
|
118
|
+
# We build the pattern for arguments to be converted via cygpath
|
119
|
+
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
120
|
+
SEP=""
|
121
|
+
for dir in $ROOTDIRSRAW ; do
|
122
|
+
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
123
|
+
SEP="|"
|
124
|
+
done
|
125
|
+
OURCYGPATTERN="(^($ROOTDIRS))"
|
126
|
+
# Add a user-defined pattern to the cygpath arguments
|
127
|
+
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
128
|
+
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
129
|
+
fi
|
130
|
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
131
|
+
i=0
|
132
|
+
for arg in "$@" ; do
|
133
|
+
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
134
|
+
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
135
|
+
|
136
|
+
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
137
|
+
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
138
|
+
else
|
139
|
+
eval `echo args$i`="\"$arg\""
|
140
|
+
fi
|
141
|
+
i=$((i+1))
|
142
|
+
done
|
143
|
+
case $i in
|
144
|
+
(0) set -- ;;
|
145
|
+
(1) set -- "$args0" ;;
|
146
|
+
(2) set -- "$args0" "$args1" ;;
|
147
|
+
(3) set -- "$args0" "$args1" "$args2" ;;
|
148
|
+
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
149
|
+
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
150
|
+
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
151
|
+
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
152
|
+
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
153
|
+
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
154
|
+
esac
|
155
|
+
fi
|
156
|
+
|
157
|
+
# Escape application args
|
158
|
+
save () {
|
159
|
+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
160
|
+
echo " "
|
161
|
+
}
|
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
|
171
|
+
|
172
|
+
exec "$JAVACMD" "$@"
|
data/gradlew.bat
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
@if "%DEBUG%" == "" @echo off
|
2
|
+
@rem ##########################################################################
|
3
|
+
@rem
|
4
|
+
@rem Gradle startup script for Windows
|
5
|
+
@rem
|
6
|
+
@rem ##########################################################################
|
7
|
+
|
8
|
+
@rem Set local scope for the variables with windows NT shell
|
9
|
+
if "%OS%"=="Windows_NT" setlocal
|
10
|
+
|
11
|
+
set DIRNAME=%~dp0
|
12
|
+
if "%DIRNAME%" == "" set DIRNAME=.
|
13
|
+
set APP_BASE_NAME=%~n0
|
14
|
+
set APP_HOME=%DIRNAME%
|
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
|
+
@rem Find java.exe
|
20
|
+
if defined JAVA_HOME goto findJavaFromJavaHome
|
21
|
+
|
22
|
+
set JAVA_EXE=java.exe
|
23
|
+
%JAVA_EXE% -version >NUL 2>&1
|
24
|
+
if "%ERRORLEVEL%" == "0" goto init
|
25
|
+
|
26
|
+
echo.
|
27
|
+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
28
|
+
echo.
|
29
|
+
echo Please set the JAVA_HOME variable in your environment to match the
|
30
|
+
echo location of your Java installation.
|
31
|
+
|
32
|
+
goto fail
|
33
|
+
|
34
|
+
:findJavaFromJavaHome
|
35
|
+
set JAVA_HOME=%JAVA_HOME:"=%
|
36
|
+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
37
|
+
|
38
|
+
if exist "%JAVA_EXE%" goto init
|
39
|
+
|
40
|
+
echo.
|
41
|
+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
42
|
+
echo.
|
43
|
+
echo Please set the JAVA_HOME variable in your environment to match the
|
44
|
+
echo location of your Java installation.
|
45
|
+
|
46
|
+
goto fail
|
47
|
+
|
48
|
+
:init
|
49
|
+
@rem Get command-line arguments, handling Windows variants
|
50
|
+
|
51
|
+
if not "%OS%" == "Windows_NT" goto win9xME_args
|
52
|
+
|
53
|
+
:win9xME_args
|
54
|
+
@rem Slurp the command line arguments.
|
55
|
+
set CMD_LINE_ARGS=
|
56
|
+
set _SKIP=2
|
57
|
+
|
58
|
+
:win9xME_args_slurp
|
59
|
+
if "x%~1" == "x" goto execute
|
60
|
+
|
61
|
+
set CMD_LINE_ARGS=%*
|
62
|
+
|
63
|
+
:execute
|
64
|
+
@rem Setup the command line
|
65
|
+
|
66
|
+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
67
|
+
|
68
|
+
@rem Execute Gradle
|
69
|
+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
70
|
+
|
71
|
+
:end
|
72
|
+
@rem End local scope for the variables with windows NT shell
|
73
|
+
if "%ERRORLEVEL%"=="0" goto mainEnd
|
74
|
+
|
75
|
+
:fail
|
76
|
+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
77
|
+
rem the _cmd.exe /c_ return code!
|
78
|
+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
79
|
+
exit /b 1
|
80
|
+
|
81
|
+
:mainEnd
|
82
|
+
if "%OS%"=="Windows_NT" endlocal
|
83
|
+
|
84
|
+
:omega
|
@@ -0,0 +1,89 @@
|
|
1
|
+
package org.embulk.input.twitter_search;
|
2
|
+
|
3
|
+
import twitter4j.Twitter;
|
4
|
+
import twitter4j.TwitterFactory;
|
5
|
+
import twitter4j.Query;
|
6
|
+
import twitter4j.QueryResult;
|
7
|
+
import twitter4j.Status;
|
8
|
+
import twitter4j.TwitterException;
|
9
|
+
import twitter4j.conf.ConfigurationBuilder;
|
10
|
+
import twitter4j.conf.Configuration;
|
11
|
+
import org.slf4j.Logger;
|
12
|
+
import org.slf4j.LoggerFactory;
|
13
|
+
import java.util.LinkedList;
|
14
|
+
import java.util.Iterator;
|
15
|
+
import java.util.List;
|
16
|
+
import java.util.concurrent.TimeUnit;
|
17
|
+
|
18
|
+
public class TwitterSearch implements Iterator<Status>
|
19
|
+
{
|
20
|
+
private final Twitter twitter;
|
21
|
+
private QueryResult queryResult;
|
22
|
+
private LinkedList<Status> twitterStatuses;
|
23
|
+
private static final Logger logger = LoggerFactory.getLogger(TwitterSearch.class);
|
24
|
+
|
25
|
+
public TwitterSearch(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret)
|
26
|
+
{
|
27
|
+
ConfigurationBuilder cb = new ConfigurationBuilder();
|
28
|
+
cb.setDebugEnabled(true)
|
29
|
+
.setJSONStoreEnabled(true)
|
30
|
+
.setOAuthConsumerKey(consumerKey)
|
31
|
+
.setOAuthConsumerSecret(consumerSecret)
|
32
|
+
.setOAuthAccessToken(accessToken)
|
33
|
+
.setOAuthAccessTokenSecret(accessTokenSecret);
|
34
|
+
Configuration configuration = cb.build();
|
35
|
+
TwitterFactory twitterFactory = new TwitterFactory(configuration);
|
36
|
+
twitter = twitterFactory.getInstance();
|
37
|
+
}
|
38
|
+
|
39
|
+
public void search(String queryString)
|
40
|
+
{
|
41
|
+
try {
|
42
|
+
Query query = new Query(queryString);
|
43
|
+
queryResult = twitter.search(query);
|
44
|
+
List<Status> statuses = queryResult.getTweets();
|
45
|
+
twitterStatuses = new LinkedList<>(statuses);
|
46
|
+
} catch (TwitterException te) {
|
47
|
+
waitTillReset(te);
|
48
|
+
search(queryString);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
public boolean hasNext()
|
53
|
+
{
|
54
|
+
if (twitterStatuses.isEmpty() && queryResult.hasNext()) {
|
55
|
+
try {
|
56
|
+
queryResult = twitter.search(queryResult.nextQuery());
|
57
|
+
twitterStatuses.addAll(queryResult.getTweets());
|
58
|
+
} catch (TwitterException te) {
|
59
|
+
waitTillReset(te);
|
60
|
+
return hasNext();
|
61
|
+
}
|
62
|
+
}
|
63
|
+
return !twitterStatuses.isEmpty();
|
64
|
+
}
|
65
|
+
|
66
|
+
public Status next()
|
67
|
+
{
|
68
|
+
return twitterStatuses.removeFirst();
|
69
|
+
}
|
70
|
+
|
71
|
+
private void waitTillReset(TwitterException te)
|
72
|
+
{
|
73
|
+
if (te.getErrorMessage().equals("Rate limit exceeded")) {
|
74
|
+
try {
|
75
|
+
//TODO: exp backeff and full-jitter
|
76
|
+
int seconds = te.getRateLimitStatus().getSecondsUntilReset();
|
77
|
+
logger.warn(String.format("%ss waiting...", seconds));
|
78
|
+
TimeUnit.SECONDS.sleep(seconds);
|
79
|
+
} catch (InterruptedException e) {
|
80
|
+
e.printStackTrace();
|
81
|
+
System.exit(-1);
|
82
|
+
}
|
83
|
+
} else {
|
84
|
+
te.printStackTrace();
|
85
|
+
logger.warn(String.format("Messages: (%s)", te.getMessage()));
|
86
|
+
System.exit(-1);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
@@ -0,0 +1,90 @@
|
|
1
|
+
package org.embulk.input.twitter_search;
|
2
|
+
|
3
|
+
import java.util.List;
|
4
|
+
import java.util.Map;
|
5
|
+
import org.embulk.config.Config;
|
6
|
+
import org.embulk.config.ConfigDiff;
|
7
|
+
import org.embulk.config.ConfigSource;
|
8
|
+
import org.embulk.config.Task;
|
9
|
+
import org.embulk.config.TaskReport;
|
10
|
+
import org.embulk.config.TaskSource;
|
11
|
+
import org.embulk.spi.Exec;
|
12
|
+
import org.embulk.spi.InputPlugin;
|
13
|
+
import org.embulk.spi.PageOutput;
|
14
|
+
import org.embulk.spi.Schema;
|
15
|
+
import org.embulk.spi.PageBuilder;
|
16
|
+
import org.embulk.spi.json.JsonParser;
|
17
|
+
import org.embulk.spi.type.Types;
|
18
|
+
import twitter4j.Status;
|
19
|
+
import twitter4j.TwitterObjectFactory;
|
20
|
+
|
21
|
+
public class TwitterSearchInputPlugin implements InputPlugin
|
22
|
+
{
|
23
|
+
public interface PluginTask extends Task
|
24
|
+
{
|
25
|
+
@Config("auth")
|
26
|
+
Map<String, String> getAuth();
|
27
|
+
|
28
|
+
@Config("queries")
|
29
|
+
List<String> getQueries();
|
30
|
+
}
|
31
|
+
|
32
|
+
@Override
|
33
|
+
public ConfigDiff transaction(ConfigSource config, InputPlugin.Control control)
|
34
|
+
{
|
35
|
+
PluginTask task = config.loadConfig(PluginTask.class);
|
36
|
+
|
37
|
+
Schema schema = Schema.builder().add("status", Types.JSON).build();
|
38
|
+
int taskCount = task.getQueries().size();
|
39
|
+
|
40
|
+
return resume(task.dump(), schema, taskCount, control);
|
41
|
+
}
|
42
|
+
|
43
|
+
@Override
|
44
|
+
public ConfigDiff resume(TaskSource taskSource, Schema schema, int taskCount, InputPlugin.Control control)
|
45
|
+
{
|
46
|
+
control.run(taskSource, schema, taskCount);
|
47
|
+
return Exec.newConfigDiff();
|
48
|
+
}
|
49
|
+
|
50
|
+
@Override
|
51
|
+
public void cleanup(TaskSource taskSource, Schema schema, int taskCount, List<TaskReport> successTaskReports)
|
52
|
+
{
|
53
|
+
}
|
54
|
+
|
55
|
+
@Override
|
56
|
+
public TaskReport run(TaskSource taskSource, Schema schema, int taskIndex, PageOutput output)
|
57
|
+
{
|
58
|
+
PluginTask task = taskSource.loadTask(PluginTask.class);
|
59
|
+
|
60
|
+
PageBuilder pagebuilder =
|
61
|
+
new PageBuilder(Exec.getBufferAllocator(), schema, output);
|
62
|
+
|
63
|
+
TwitterSearch twitter = new TwitterSearch(
|
64
|
+
task.getAuth().get("consumer_key"),
|
65
|
+
task.getAuth().get("consumer_secret"),
|
66
|
+
task.getAuth().get("access_token"),
|
67
|
+
task.getAuth().get("access_secret")
|
68
|
+
);
|
69
|
+
|
70
|
+
twitter.search(task.getQueries().get(taskIndex));
|
71
|
+
while (twitter.hasNext()) {
|
72
|
+
Status status = twitter.next();
|
73
|
+
String statusJson = TwitterObjectFactory.getRawJSON(status);
|
74
|
+
pagebuilder.setJson(
|
75
|
+
schema.getColumn(0),
|
76
|
+
new JsonParser().parse(statusJson));
|
77
|
+
pagebuilder.addRecord();
|
78
|
+
}
|
79
|
+
|
80
|
+
pagebuilder.finish();
|
81
|
+
|
82
|
+
return Exec.newTaskReport();
|
83
|
+
}
|
84
|
+
|
85
|
+
@Override
|
86
|
+
public ConfigDiff guess(ConfigSource config)
|
87
|
+
{
|
88
|
+
return Exec.newConfigDiff();
|
89
|
+
}
|
90
|
+
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
package org.embulk.input.twitter_search;
|
2
|
+
|
3
|
+
import org.junit.Before;
|
4
|
+
import org.junit.Test;
|
5
|
+
import org.junit.runner.RunWith;
|
6
|
+
import org.junit.Assert;
|
7
|
+
import org.mockito.Mockito;
|
8
|
+
import org.mockito.internal.util.reflection.Whitebox;
|
9
|
+
import org.powermock.api.mockito.PowerMockito;
|
10
|
+
import org.powermock.modules.junit4.PowerMockRunner;
|
11
|
+
import org.powermock.core.classloader.annotations.PrepareForTest;
|
12
|
+
import twitter4j.*;
|
13
|
+
import twitter4j.conf.ConfigurationBuilder;
|
14
|
+
import twitter4j.conf.Configuration;
|
15
|
+
import java.util.ArrayList;
|
16
|
+
import java.util.LinkedList;
|
17
|
+
import java.util.List;
|
18
|
+
|
19
|
+
@RunWith(PowerMockRunner.class)
|
20
|
+
@PrepareForTest({TwitterSearch.class, ConfigurationBuilder.class, Query.class})
|
21
|
+
public class TestTwitterSearch
|
22
|
+
{
|
23
|
+
private Twitter twitter;
|
24
|
+
private TwitterSearch twitterSearch;
|
25
|
+
|
26
|
+
@Before
|
27
|
+
public void setup() throws Exception {
|
28
|
+
ConfigurationBuilder configurationBuilder = Mockito.mock(ConfigurationBuilder.class);
|
29
|
+
PowerMockito.whenNew(ConfigurationBuilder.class).withNoArguments().thenReturn(configurationBuilder);
|
30
|
+
Mockito.when(configurationBuilder.setDebugEnabled(true)).thenReturn(configurationBuilder);
|
31
|
+
Mockito.when(configurationBuilder.setJSONStoreEnabled(true)).thenReturn(configurationBuilder);
|
32
|
+
Mockito.when(configurationBuilder.setOAuthConsumerKey("consumer-***-key")).thenReturn(configurationBuilder);
|
33
|
+
Mockito.when(configurationBuilder.setOAuthConsumerSecret("consumer-***-secret")).thenReturn(configurationBuilder);
|
34
|
+
Mockito.when(configurationBuilder.setOAuthAccessToken("access-***-token")).thenReturn(configurationBuilder);
|
35
|
+
Mockito.when(configurationBuilder.setOAuthAccessTokenSecret("access-***-secret")).thenReturn(configurationBuilder);
|
36
|
+
Configuration configuration = Mockito.mock(Configuration.class);
|
37
|
+
Mockito.when(configurationBuilder.build()).thenReturn(configuration);
|
38
|
+
TwitterFactory twitterFactory = Mockito.mock(TwitterFactory.class);
|
39
|
+
PowerMockito.whenNew(TwitterFactory.class).withArguments(configuration).thenReturn(twitterFactory);
|
40
|
+
twitter = Mockito.mock(Twitter.class);
|
41
|
+
Mockito.when(twitterFactory.getInstance()).thenReturn(twitter);
|
42
|
+
twitterSearch = new TwitterSearch(
|
43
|
+
"consumer-***-key",
|
44
|
+
"consumer-***-secret",
|
45
|
+
"access-***-token",
|
46
|
+
"access-***-secret"
|
47
|
+
);
|
48
|
+
Mockito.verify(configurationBuilder).setDebugEnabled(true);
|
49
|
+
}
|
50
|
+
|
51
|
+
@Test
|
52
|
+
public void testSearch() throws Exception {
|
53
|
+
Query query = Mockito.mock(Query.class);
|
54
|
+
QueryResult queryResult = Mockito.mock(QueryResult.class);
|
55
|
+
PowerMockito.whenNew(Query.class).withArguments("from:@nishiogi_now").thenReturn(query);
|
56
|
+
Mockito.when(twitter.search(query)).thenReturn(queryResult);
|
57
|
+
List<Status> statuses = new ArrayList<>();
|
58
|
+
Mockito.when(queryResult.getTweets()).thenReturn(statuses);
|
59
|
+
twitterSearch.search("from:@nishiogi_now");
|
60
|
+
}
|
61
|
+
|
62
|
+
@Test
|
63
|
+
public void testHasNext()
|
64
|
+
{
|
65
|
+
Status status = Mockito.mock(Status.class);
|
66
|
+
LinkedList<Status> twitterStatuses = new LinkedList<>();
|
67
|
+
twitterStatuses.add(status);
|
68
|
+
Whitebox.setInternalState(twitterSearch, "twitterStatuses", twitterStatuses);
|
69
|
+
QueryResult queryResult = Mockito.mock(QueryResult.class);
|
70
|
+
Mockito.when(queryResult.hasNext()).thenReturn(true);
|
71
|
+
Whitebox.setInternalState(twitterSearch, "queryResult", queryResult);
|
72
|
+
boolean hasNext = twitterSearch.hasNext();
|
73
|
+
Assert.assertTrue(hasNext);
|
74
|
+
}
|
75
|
+
|
76
|
+
@Test
|
77
|
+
public void testNext()
|
78
|
+
{
|
79
|
+
Status status = Mockito.mock(Status.class);
|
80
|
+
LinkedList<Status> twitterStatuses = new LinkedList<>();
|
81
|
+
twitterStatuses.add(status);
|
82
|
+
Whitebox.setInternalState(twitterSearch, "twitterStatuses", twitterStatuses);
|
83
|
+
Status nextStatus = twitterSearch.next();
|
84
|
+
Assert.assertEquals(status, nextStatus);
|
85
|
+
}
|
86
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
package org.embulk.input.twitter_search;
|
2
|
+
|
3
|
+
import org.embulk.test.TestingEmbulk;
|
4
|
+
import org.embulk.spi.InputPlugin;
|
5
|
+
import org.embulk.config.ConfigSource;
|
6
|
+
import org.junit.Rule;
|
7
|
+
import org.junit.Test;
|
8
|
+
import static org.junit.Assert.assertEquals;
|
9
|
+
|
10
|
+
public class TestTwitterSearchInputPlugin
|
11
|
+
{
|
12
|
+
|
13
|
+
@Rule
|
14
|
+
public TestingEmbulk embulk = TestingEmbulk.builder()
|
15
|
+
.registerPlugin(InputPlugin.class, "twitter_search", TwitterSearchInputPlugin.class)
|
16
|
+
.build();
|
17
|
+
|
18
|
+
@Test
|
19
|
+
public void testGetConfig()
|
20
|
+
{
|
21
|
+
ConfigSource config = embulk.loadYamlResource("java/org/embulk/input/twitter_search/test.yml");
|
22
|
+
TwitterSearchInputPlugin.PluginTask task = config.loadConfig(TwitterSearchInputPlugin.PluginTask.class);
|
23
|
+
assertEquals("sample_consumer_key", task.getAuth().get("consumer_key"));
|
24
|
+
}
|
25
|
+
}
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-input-twitter_search
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- KentFujii
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-09 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: '12.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: '12.0'
|
41
|
+
description: Loads records from Twitter Search.
|
42
|
+
email:
|
43
|
+
- kent.where.the.light.is@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- build.gradle
|
52
|
+
- classpath/embulk-input-twitter_search-0.1.0.jar
|
53
|
+
- classpath/log4j-1.2.17.jar
|
54
|
+
- classpath/slf4j-api-1.7.21.jar
|
55
|
+
- classpath/slf4j-log4j12-1.7.21.jar
|
56
|
+
- classpath/twitter4j-core-4.0.7.jar
|
57
|
+
- config/checkstyle/checkstyle.xml
|
58
|
+
- config/checkstyle/default.xml
|
59
|
+
- gradle/wrapper/gradle-wrapper.jar
|
60
|
+
- gradle/wrapper/gradle-wrapper.properties
|
61
|
+
- gradlew
|
62
|
+
- gradlew.bat
|
63
|
+
- lib/embulk/input/twitter_search.rb
|
64
|
+
- src/main/java/org/embulk/input/twitter_search/TwitterSearch.java
|
65
|
+
- src/main/java/org/embulk/input/twitter_search/TwitterSearchInputPlugin.java
|
66
|
+
- src/main/resources/log4j.properties
|
67
|
+
- src/test/java/org/embulk/input/twitter_search/TestTwitterSearch.java
|
68
|
+
- src/test/java/org/embulk/input/twitter_search/TestTwitterSearchInputPlugin.java
|
69
|
+
- src/test/resources/java/org/embulk/input/twitter_search/test.yml
|
70
|
+
homepage:
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.6.8
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Twitter Search input plugin for Embulk
|
94
|
+
test_files: []
|