wordfilter_client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +19 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/doc/gen.txt +1 -0
- data/doc/wordfilter.thrift +102 -0
- data/lib/word_filters_service.rb +328 -0
- data/lib/wordfilter_client.rb +6 -0
- data/lib/wordfilter_client/version.rb +5 -0
- data/lib/wordfilter_constants.rb +13 -0
- data/lib/wordfilter_types.rb +31 -0
- data/test/thrift_wordfilter_client_test.rb +28 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6c81273157226f3fc6768fee385ee70124ef2e37
|
4
|
+
data.tar.gz: 71bc69d5245443c996892fd647021910c2add7f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e5f38a21b9383c74b56b6f73291fda7581769bfd0fac7a521ef313676810cae8721ce0214be1732444408fe955fe562e9b3aad0ffd9c5b2685e25c0d980a809
|
7
|
+
data.tar.gz: de28821c470908cae293391187b753204aa9052a2c25370148c9262026bafa01e2470ce424db595d3f0e4b45a9d7a24a1bc0aef220330310af96cc24bb466740
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wordfilter-client (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
remote: http://192.168.3.220:9292/
|
9
|
+
specs:
|
10
|
+
thrift (0.9.1)
|
11
|
+
thrift-client (0.0.6)
|
12
|
+
thrift (~> 0.9.0)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
thrift-client
|
19
|
+
wordfilter-client!
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Stat::Count::Client
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'stat-count-client'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install stat-count-client
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/doc/gen.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
thrift -out /workspaces/ruby/wordfilter-client/lib/wordfilter-client --gen rb /workspaces/ruby/wordfilter-client/doc/wordfilter.thrift
|
@@ -0,0 +1,102 @@
|
|
1
|
+
namespace java com.nali.wordfilter.thrift
|
2
|
+
namespace rb wordfilter.thrift
|
3
|
+
|
4
|
+
/**
|
5
|
+
* 当同时检测多种文本时,返回具体某种文本出错
|
6
|
+
*/
|
7
|
+
struct PartResult{
|
8
|
+
1:i32 error,
|
9
|
+
2:string part
|
10
|
+
}
|
11
|
+
|
12
|
+
/**
|
13
|
+
* 敏感词过滤服务,目前提供的服务有:
|
14
|
+
* <ul>
|
15
|
+
* <li>文本过滤</li>
|
16
|
+
* <li>用户行为检测跟踪</li>
|
17
|
+
* <li>IP行为检测跟踪</li>
|
18
|
+
* <li>其他客户端相关</li>
|
19
|
+
* <ul>
|
20
|
+
*/
|
21
|
+
service WordFiltersService {
|
22
|
+
/**
|
23
|
+
* 过滤词判断
|
24
|
+
*
|
25
|
+
* @param application
|
26
|
+
* 应用ID(话题,投票...)
|
27
|
+
* @param userId
|
28
|
+
* 发表人ID
|
29
|
+
* @param ip
|
30
|
+
* 发表人的IP
|
31
|
+
* @param txt
|
32
|
+
* 发表内容
|
33
|
+
* @return 0:正常通过 <br />
|
34
|
+
* -1:用户在黑名单中,不允许用户操作 <br />
|
35
|
+
* -2:用户发帖太快 <br />
|
36
|
+
* -3:ip被禁止 <br />
|
37
|
+
* -4:对应该IP的主机发帖太快 <br />
|
38
|
+
* -5:被禁止的浏览器类型 <br />
|
39
|
+
* -6:文本太长 <br />
|
40
|
+
* -7:连续的中文字符太长 <br />
|
41
|
+
* -8:连续的非中文字符太长 <br />
|
42
|
+
* -9:文本内容结构太窄 <br />
|
43
|
+
* -10:过多的空字符 <br />
|
44
|
+
* -11:文本内容中包含了不合法的词汇 <br />
|
45
|
+
* -12:用户重复发帖过于频繁 <br />
|
46
|
+
* -13:IP对应的主机重复发帖过于频繁 <br />
|
47
|
+
* -14:因为用户之前重复发帖,而被禁止操作 <br />
|
48
|
+
* -15:因为该IP对应主机重复发帖,而被禁止操作 <br />
|
49
|
+
* -99:未知的应用
|
50
|
+
* @throws IOException
|
51
|
+
*/
|
52
|
+
i32 wordFilter(1:i32 application, 2:i64 userId, 3:string ip, 4:binary txtData);
|
53
|
+
|
54
|
+
/**
|
55
|
+
* 过滤文本字符串
|
56
|
+
* @param application 应用id
|
57
|
+
* @param userId 用户id
|
58
|
+
* @param ip ip地址
|
59
|
+
* @param txtData 文本内容
|
60
|
+
* @return @see {@link #wordFilter(int, long, String, byte[])}
|
61
|
+
* @throws IOException
|
62
|
+
*/
|
63
|
+
i32 wordFilters(1:i32 application, 2:i64 userId, 3:string ip,
|
64
|
+
4:string txtData);
|
65
|
+
|
66
|
+
/**
|
67
|
+
* 批量过滤敏感词,遇到第一个出错的文本就返回
|
68
|
+
* @param application 应用id
|
69
|
+
* @param userId 用户id
|
70
|
+
* @param ip 用户ip
|
71
|
+
* @param txtData 检测的多个样本
|
72
|
+
* @return PartResult 出错文本
|
73
|
+
* @throws IOException
|
74
|
+
*/
|
75
|
+
PartResult mutilWordFilter(1:i32 application, 2:i64 userId,
|
76
|
+
3:string ip, 4:map<string, string> txtData);
|
77
|
+
|
78
|
+
/**
|
79
|
+
* 只判敏感词,其他忽略
|
80
|
+
* @param application
|
81
|
+
* @param userId
|
82
|
+
* @param ip
|
83
|
+
* @param txtData
|
84
|
+
* @return
|
85
|
+
* @throws IOException
|
86
|
+
*/
|
87
|
+
PartResult onlyWordFilters(1:i32 application, 2:i64 userId,
|
88
|
+
3:string ip, 4:map<string, string> txtData);
|
89
|
+
|
90
|
+
/**
|
91
|
+
* 只判敏感词,其他忽略
|
92
|
+
* @param application
|
93
|
+
* @param userId
|
94
|
+
* @param ip
|
95
|
+
* @param txtData
|
96
|
+
* @return
|
97
|
+
* @throws IOException
|
98
|
+
*/
|
99
|
+
i32 onlyWordFilter(1:i32 application, 2:i64 userId, 3:string ip,
|
100
|
+
4:string txtData);
|
101
|
+
}
|
102
|
+
|
@@ -0,0 +1,328 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (0.9.0)
|
3
|
+
#
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'thrift'
|
8
|
+
require 'wordfilter_types'
|
9
|
+
|
10
|
+
module Wordfilter
|
11
|
+
module Thrift
|
12
|
+
module WordFiltersService
|
13
|
+
class Client
|
14
|
+
include ::Thrift::Client
|
15
|
+
|
16
|
+
def wordFilter(application, userId, ip, txtData)
|
17
|
+
send_wordFilter(application, userId, ip, txtData)
|
18
|
+
return recv_wordFilter()
|
19
|
+
end
|
20
|
+
|
21
|
+
def send_wordFilter(application, userId, ip, txtData)
|
22
|
+
send_message('wordFilter', WordFilter_args, :application => application, :userId => userId, :ip => ip, :txtData => txtData)
|
23
|
+
end
|
24
|
+
|
25
|
+
def recv_wordFilter()
|
26
|
+
result = receive_message(WordFilter_result)
|
27
|
+
return result.success unless result.success.nil?
|
28
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'wordFilter failed: unknown result')
|
29
|
+
end
|
30
|
+
|
31
|
+
def wordFilters(application, userId, ip, txtData)
|
32
|
+
send_wordFilters(application, userId, ip, txtData)
|
33
|
+
return recv_wordFilters()
|
34
|
+
end
|
35
|
+
|
36
|
+
def send_wordFilters(application, userId, ip, txtData)
|
37
|
+
send_message('wordFilters', WordFilters_args, :application => application, :userId => userId, :ip => ip, :txtData => txtData)
|
38
|
+
end
|
39
|
+
|
40
|
+
def recv_wordFilters()
|
41
|
+
result = receive_message(WordFilters_result)
|
42
|
+
return result.success unless result.success.nil?
|
43
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'wordFilters failed: unknown result')
|
44
|
+
end
|
45
|
+
|
46
|
+
def mutilWordFilter(application, userId, ip, txtData)
|
47
|
+
send_mutilWordFilter(application, userId, ip, txtData)
|
48
|
+
return recv_mutilWordFilter()
|
49
|
+
end
|
50
|
+
|
51
|
+
def send_mutilWordFilter(application, userId, ip, txtData)
|
52
|
+
send_message('mutilWordFilter', MutilWordFilter_args, :application => application, :userId => userId, :ip => ip, :txtData => txtData)
|
53
|
+
end
|
54
|
+
|
55
|
+
def recv_mutilWordFilter()
|
56
|
+
result = receive_message(MutilWordFilter_result)
|
57
|
+
return result.success unless result.success.nil?
|
58
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'mutilWordFilter failed: unknown result')
|
59
|
+
end
|
60
|
+
|
61
|
+
def onlyWordFilters(application, userId, ip, txtData)
|
62
|
+
send_onlyWordFilters(application, userId, ip, txtData)
|
63
|
+
return recv_onlyWordFilters()
|
64
|
+
end
|
65
|
+
|
66
|
+
def send_onlyWordFilters(application, userId, ip, txtData)
|
67
|
+
send_message('onlyWordFilters', OnlyWordFilters_args, :application => application, :userId => userId, :ip => ip, :txtData => txtData)
|
68
|
+
end
|
69
|
+
|
70
|
+
def recv_onlyWordFilters()
|
71
|
+
result = receive_message(OnlyWordFilters_result)
|
72
|
+
return result.success unless result.success.nil?
|
73
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'onlyWordFilters failed: unknown result')
|
74
|
+
end
|
75
|
+
|
76
|
+
def onlyWordFilter(application, userId, ip, txtData)
|
77
|
+
send_onlyWordFilter(application, userId, ip, txtData)
|
78
|
+
return recv_onlyWordFilter()
|
79
|
+
end
|
80
|
+
|
81
|
+
def send_onlyWordFilter(application, userId, ip, txtData)
|
82
|
+
send_message('onlyWordFilter', OnlyWordFilter_args, :application => application, :userId => userId, :ip => ip, :txtData => txtData)
|
83
|
+
end
|
84
|
+
|
85
|
+
def recv_onlyWordFilter()
|
86
|
+
result = receive_message(OnlyWordFilter_result)
|
87
|
+
return result.success unless result.success.nil?
|
88
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'onlyWordFilter failed: unknown result')
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
class Processor
|
94
|
+
include ::Thrift::Processor
|
95
|
+
|
96
|
+
def process_wordFilter(seqid, iprot, oprot)
|
97
|
+
args = read_args(iprot, WordFilter_args)
|
98
|
+
result = WordFilter_result.new()
|
99
|
+
result.success = @handler.wordFilter(args.application, args.userId, args.ip, args.txtData)
|
100
|
+
write_result(result, oprot, 'wordFilter', seqid)
|
101
|
+
end
|
102
|
+
|
103
|
+
def process_wordFilters(seqid, iprot, oprot)
|
104
|
+
args = read_args(iprot, WordFilters_args)
|
105
|
+
result = WordFilters_result.new()
|
106
|
+
result.success = @handler.wordFilters(args.application, args.userId, args.ip, args.txtData)
|
107
|
+
write_result(result, oprot, 'wordFilters', seqid)
|
108
|
+
end
|
109
|
+
|
110
|
+
def process_mutilWordFilter(seqid, iprot, oprot)
|
111
|
+
args = read_args(iprot, MutilWordFilter_args)
|
112
|
+
result = MutilWordFilter_result.new()
|
113
|
+
result.success = @handler.mutilWordFilter(args.application, args.userId, args.ip, args.txtData)
|
114
|
+
write_result(result, oprot, 'mutilWordFilter', seqid)
|
115
|
+
end
|
116
|
+
|
117
|
+
def process_onlyWordFilters(seqid, iprot, oprot)
|
118
|
+
args = read_args(iprot, OnlyWordFilters_args)
|
119
|
+
result = OnlyWordFilters_result.new()
|
120
|
+
result.success = @handler.onlyWordFilters(args.application, args.userId, args.ip, args.txtData)
|
121
|
+
write_result(result, oprot, 'onlyWordFilters', seqid)
|
122
|
+
end
|
123
|
+
|
124
|
+
def process_onlyWordFilter(seqid, iprot, oprot)
|
125
|
+
args = read_args(iprot, OnlyWordFilter_args)
|
126
|
+
result = OnlyWordFilter_result.new()
|
127
|
+
result.success = @handler.onlyWordFilter(args.application, args.userId, args.ip, args.txtData)
|
128
|
+
write_result(result, oprot, 'onlyWordFilter', seqid)
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
# HELPER FUNCTIONS AND STRUCTURES
|
134
|
+
|
135
|
+
class WordFilter_args
|
136
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
137
|
+
APPLICATION = 1
|
138
|
+
USERID = 2
|
139
|
+
IP = 3
|
140
|
+
TXTDATA = 4
|
141
|
+
|
142
|
+
FIELDS = {
|
143
|
+
APPLICATION => {:type => ::Thrift::Types::I32, :name => 'application'},
|
144
|
+
USERID => {:type => ::Thrift::Types::I64, :name => 'userId'},
|
145
|
+
IP => {:type => ::Thrift::Types::STRING, :name => 'ip'},
|
146
|
+
TXTDATA => {:type => ::Thrift::Types::STRING, :name => 'txtData', :binary => true}
|
147
|
+
}
|
148
|
+
|
149
|
+
def struct_fields; FIELDS; end
|
150
|
+
|
151
|
+
def validate
|
152
|
+
end
|
153
|
+
|
154
|
+
::Thrift::Struct.generate_accessors self
|
155
|
+
end
|
156
|
+
|
157
|
+
class WordFilter_result
|
158
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
159
|
+
SUCCESS = 0
|
160
|
+
|
161
|
+
FIELDS = {
|
162
|
+
SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
|
163
|
+
}
|
164
|
+
|
165
|
+
def struct_fields; FIELDS; end
|
166
|
+
|
167
|
+
def validate
|
168
|
+
end
|
169
|
+
|
170
|
+
::Thrift::Struct.generate_accessors self
|
171
|
+
end
|
172
|
+
|
173
|
+
class WordFilters_args
|
174
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
175
|
+
APPLICATION = 1
|
176
|
+
USERID = 2
|
177
|
+
IP = 3
|
178
|
+
TXTDATA = 4
|
179
|
+
|
180
|
+
FIELDS = {
|
181
|
+
APPLICATION => {:type => ::Thrift::Types::I32, :name => 'application'},
|
182
|
+
USERID => {:type => ::Thrift::Types::I64, :name => 'userId'},
|
183
|
+
IP => {:type => ::Thrift::Types::STRING, :name => 'ip'},
|
184
|
+
TXTDATA => {:type => ::Thrift::Types::STRING, :name => 'txtData'}
|
185
|
+
}
|
186
|
+
|
187
|
+
def struct_fields; FIELDS; end
|
188
|
+
|
189
|
+
def validate
|
190
|
+
end
|
191
|
+
|
192
|
+
::Thrift::Struct.generate_accessors self
|
193
|
+
end
|
194
|
+
|
195
|
+
class WordFilters_result
|
196
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
197
|
+
SUCCESS = 0
|
198
|
+
|
199
|
+
FIELDS = {
|
200
|
+
SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
|
201
|
+
}
|
202
|
+
|
203
|
+
def struct_fields; FIELDS; end
|
204
|
+
|
205
|
+
def validate
|
206
|
+
end
|
207
|
+
|
208
|
+
::Thrift::Struct.generate_accessors self
|
209
|
+
end
|
210
|
+
|
211
|
+
class MutilWordFilter_args
|
212
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
213
|
+
APPLICATION = 1
|
214
|
+
USERID = 2
|
215
|
+
IP = 3
|
216
|
+
TXTDATA = 4
|
217
|
+
|
218
|
+
FIELDS = {
|
219
|
+
APPLICATION => {:type => ::Thrift::Types::I32, :name => 'application'},
|
220
|
+
USERID => {:type => ::Thrift::Types::I64, :name => 'userId'},
|
221
|
+
IP => {:type => ::Thrift::Types::STRING, :name => 'ip'},
|
222
|
+
TXTDATA => {:type => ::Thrift::Types::MAP, :name => 'txtData', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
|
223
|
+
}
|
224
|
+
|
225
|
+
def struct_fields; FIELDS; end
|
226
|
+
|
227
|
+
def validate
|
228
|
+
end
|
229
|
+
|
230
|
+
::Thrift::Struct.generate_accessors self
|
231
|
+
end
|
232
|
+
|
233
|
+
class MutilWordFilter_result
|
234
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
235
|
+
SUCCESS = 0
|
236
|
+
|
237
|
+
FIELDS = {
|
238
|
+
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::Wordfilter::Thrift::PartResult}
|
239
|
+
}
|
240
|
+
|
241
|
+
def struct_fields; FIELDS; end
|
242
|
+
|
243
|
+
def validate
|
244
|
+
end
|
245
|
+
|
246
|
+
::Thrift::Struct.generate_accessors self
|
247
|
+
end
|
248
|
+
|
249
|
+
class OnlyWordFilters_args
|
250
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
251
|
+
APPLICATION = 1
|
252
|
+
USERID = 2
|
253
|
+
IP = 3
|
254
|
+
TXTDATA = 4
|
255
|
+
|
256
|
+
FIELDS = {
|
257
|
+
APPLICATION => {:type => ::Thrift::Types::I32, :name => 'application'},
|
258
|
+
USERID => {:type => ::Thrift::Types::I64, :name => 'userId'},
|
259
|
+
IP => {:type => ::Thrift::Types::STRING, :name => 'ip'},
|
260
|
+
TXTDATA => {:type => ::Thrift::Types::MAP, :name => 'txtData', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
|
261
|
+
}
|
262
|
+
|
263
|
+
def struct_fields; FIELDS; end
|
264
|
+
|
265
|
+
def validate
|
266
|
+
end
|
267
|
+
|
268
|
+
::Thrift::Struct.generate_accessors self
|
269
|
+
end
|
270
|
+
|
271
|
+
class OnlyWordFilters_result
|
272
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
273
|
+
SUCCESS = 0
|
274
|
+
|
275
|
+
FIELDS = {
|
276
|
+
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::Wordfilter::Thrift::PartResult}
|
277
|
+
}
|
278
|
+
|
279
|
+
def struct_fields; FIELDS; end
|
280
|
+
|
281
|
+
def validate
|
282
|
+
end
|
283
|
+
|
284
|
+
::Thrift::Struct.generate_accessors self
|
285
|
+
end
|
286
|
+
|
287
|
+
class OnlyWordFilter_args
|
288
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
289
|
+
APPLICATION = 1
|
290
|
+
USERID = 2
|
291
|
+
IP = 3
|
292
|
+
TXTDATA = 4
|
293
|
+
|
294
|
+
FIELDS = {
|
295
|
+
APPLICATION => {:type => ::Thrift::Types::I32, :name => 'application'},
|
296
|
+
USERID => {:type => ::Thrift::Types::I64, :name => 'userId'},
|
297
|
+
IP => {:type => ::Thrift::Types::STRING, :name => 'ip'},
|
298
|
+
TXTDATA => {:type => ::Thrift::Types::STRING, :name => 'txtData'}
|
299
|
+
}
|
300
|
+
|
301
|
+
def struct_fields; FIELDS; end
|
302
|
+
|
303
|
+
def validate
|
304
|
+
end
|
305
|
+
|
306
|
+
::Thrift::Struct.generate_accessors self
|
307
|
+
end
|
308
|
+
|
309
|
+
class OnlyWordFilter_result
|
310
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
311
|
+
SUCCESS = 0
|
312
|
+
|
313
|
+
FIELDS = {
|
314
|
+
SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
|
315
|
+
}
|
316
|
+
|
317
|
+
def struct_fields; FIELDS; end
|
318
|
+
|
319
|
+
def validate
|
320
|
+
end
|
321
|
+
|
322
|
+
::Thrift::Struct.generate_accessors self
|
323
|
+
end
|
324
|
+
|
325
|
+
end
|
326
|
+
|
327
|
+
end
|
328
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (0.9.0)
|
3
|
+
#
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'thrift'
|
8
|
+
|
9
|
+
module Wordfilter
|
10
|
+
module Thrift
|
11
|
+
# 当同时检测多种文本时,返回具体某种文本出错
|
12
|
+
class PartResult
|
13
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
14
|
+
ERROR = 1
|
15
|
+
PART = 2
|
16
|
+
|
17
|
+
FIELDS = {
|
18
|
+
ERROR => {:type => ::Thrift::Types::I32, :name => 'error'},
|
19
|
+
PART => {:type => ::Thrift::Types::STRING, :name => 'part'}
|
20
|
+
}
|
21
|
+
|
22
|
+
def struct_fields; FIELDS; end
|
23
|
+
|
24
|
+
def validate
|
25
|
+
end
|
26
|
+
|
27
|
+
::Thrift::Struct.generate_accessors self
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__),"..")
|
5
|
+
|
6
|
+
require "rubygems"
|
7
|
+
require "wordfilter_client"
|
8
|
+
require "thrift_client"
|
9
|
+
require "test/unit"
|
10
|
+
|
11
|
+
class TC_WordFilterClientTest < Test::Unit::TestCase
|
12
|
+
# Called before every test method runs. Can be used
|
13
|
+
# to set up fixture information.
|
14
|
+
def setup
|
15
|
+
@client = ThriftClient.new({"servers" => "localhost:9096", "client_class" => "Wordfilter::Thrift::WordFiltersService::Client"});
|
16
|
+
end
|
17
|
+
|
18
|
+
# Called after every test method runs. Can be used to tear
|
19
|
+
# down fixture information.
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
# Do nothing
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_mutilWordFilter()
|
26
|
+
partResult=@client.mutilWordFilter(2, 1, "127.0.0.1", {"body"=>"找小姐"});
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wordfilter_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- gavin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thrift-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: ruby thrift client for wordfilter service
|
28
|
+
email:
|
29
|
+
- gavin@ximalya.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- Gemfile
|
35
|
+
- Gemfile.lock
|
36
|
+
- LICENSE
|
37
|
+
- Rakefile
|
38
|
+
- README.md
|
39
|
+
- test/thrift_wordfilter_client_test.rb
|
40
|
+
- lib/word_filters_service.rb
|
41
|
+
- lib/wordfilter_client/version.rb
|
42
|
+
- lib/wordfilter_client.rb
|
43
|
+
- lib/wordfilter_constants.rb
|
44
|
+
- lib/wordfilter_types.rb
|
45
|
+
- doc/gen.txt
|
46
|
+
- doc/wordfilter.thrift
|
47
|
+
homepage: http://www.ximalaya.com
|
48
|
+
licenses: []
|
49
|
+
metadata: {}
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
- test
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 2.0.3
|
68
|
+
signing_key:
|
69
|
+
specification_version: 4
|
70
|
+
summary: wordfilter client
|
71
|
+
test_files:
|
72
|
+
- test/thrift_wordfilter_client_test.rb
|
73
|
+
has_rdoc:
|