webpurify 0.7.0 → 0.8.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 +4 -4
- data/README.md +60 -5
- data/lib/web_purify/client.rb +14 -3
- data/lib/web_purify/constants.rb +17 -6
- data/lib/web_purify/methods/blacklist.rb +3 -3
- data/lib/web_purify/methods/image_filters.rb +50 -0
- data/lib/web_purify/methods/{filters.rb → text_filters.rb} +8 -8
- data/lib/web_purify/methods/whitelist.rb +3 -3
- data/lib/web_purify/version.rb +1 -1
- data/spec/fixtures/vcr/WebPurify_ImageFilters/imgaccount/returns_the_number_of_image_submissions_remaining.yml +38 -0
- data/spec/fixtures/vcr/WebPurify_ImageFilters/imgcheck/returns_an_image_ID.yml +38 -0
- data/spec/fixtures/vcr/WebPurify_ImageFilters/imgstatus/returns_the_status_of_image_moderation.yml +74 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check/safe_text_returns_false.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check/text_with_a_URL_returns_false_by_default.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check/text_with_a_URL_when_URLs_are_prohibited_returns_true.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check/text_with_a_phone_number_returns_false_by_default.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check/text_with_a_phone_number_when_phone_numbers_are_prohibited_returns_true.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check/text_with_an_email_returns_false_by_default.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check/text_with_an_email_when_emails_are_prohibited_returns_true.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check/text_with_profanity_returns_true.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check_count/no_profanities_returns_0.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check_count/one_profanity_returns_1.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check_count/two_profanities_returns_2.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/replace/safe_text_returns_the_text_with_no_changes.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/replace/text_with_profanity_returns_the_text_with_profanities_replaced_by_symbols.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/return/no_profanities_returns_an_empty_array.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/return/one_profanity_returns_an_array_with_one_profanity.yml +0 -0
- data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/return/two_profanities_returns_an_array_with_two_profanities.yml +0 -0
- data/spec/web_purify/methods/image_filters_spec.rb +34 -0
- data/spec/web_purify/methods/{filters_spec.rb → text_filters_spec.rb} +4 -4
- metadata +45 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fd086c28b2e5acdf35f54cb703a2b2bb453ab10
|
4
|
+
data.tar.gz: 2008c40dcc8288ce9e068bbd0d85e6d704549374
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af01d847c4111e7c689ac36e28eb9f6aa0b39d63818902efe76f795c27cb5f0658954a7252c4989cd89e3076c1aaf561ca88ec64811ab3dbf837dd7b06f4c5dc
|
7
|
+
data.tar.gz: 811034a673516c955ee8db32fa3ae0742536be98378ef4b4d4f97f87dd94c6e14e340c67cad6c71c36636e73b883c5bb93e669c7dc2ff80344e0f1da5d74c61d
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ This gem allows simple interaction with the WebPurify API using Ruby. For more i
|
|
6
6
|
|
7
7
|
### Commands
|
8
8
|
|
9
|
-
##### Filters
|
9
|
+
##### Text Filters
|
10
10
|
* [check](#check)
|
11
11
|
* [check_count](#check_count)
|
12
12
|
* [replace](#replace)
|
@@ -22,6 +22,11 @@ This gem allows simple interaction with the WebPurify API using Ruby. For more i
|
|
22
22
|
* [remove_from_whitelist](#remove_from_whitelist)
|
23
23
|
* [get_whitelist](#get_whitelist)
|
24
24
|
|
25
|
+
##### Image Filters
|
26
|
+
* [imgcheck](#imgcheck)
|
27
|
+
* [imgstatus](#imgstatus)
|
28
|
+
* [imgaccount](#imgaccount)
|
29
|
+
|
25
30
|
|
26
31
|
Install & Initialize
|
27
32
|
--------------------
|
@@ -55,7 +60,6 @@ Commands
|
|
55
60
|
|
56
61
|
<a name="check" />
|
57
62
|
### check
|
58
|
-
|
59
63
|
Check a string of text for profanity. Returns true if profanity found, false if none.
|
60
64
|
|
61
65
|
```rb
|
@@ -65,7 +69,6 @@ puts @wp.check('some profane text')
|
|
65
69
|
|
66
70
|
<a name="check_count" />
|
67
71
|
### check_count
|
68
|
-
|
69
72
|
Check a string of text for profanity. Returns number of words if profanity found, 0 if none.
|
70
73
|
|
71
74
|
```rb
|
@@ -91,8 +94,8 @@ p @wp.return('profane text')
|
|
91
94
|
```
|
92
95
|
|
93
96
|
|
94
|
-
### Options
|
95
|
-
All filter commands can take an additional options object, just before the callback. The available options are:
|
97
|
+
### Text Filter Options
|
98
|
+
All text filter commands can take an additional options object, just before the callback. The available options are:
|
96
99
|
|
97
100
|
```rb
|
98
101
|
options = {
|
@@ -165,6 +168,58 @@ Get the whitelist as an array of words.
|
|
165
168
|
p @wp.get_whitelist
|
166
169
|
```
|
167
170
|
|
171
|
+
|
172
|
+
<a name="imgcheck" />
|
173
|
+
### imgcheck
|
174
|
+
Submit an image to the moderation service. Returns an image ID that is used to return the results of the moderation to a callback function.
|
175
|
+
|
176
|
+
```rb
|
177
|
+
puts @wp.imgcheck(imgurl)
|
178
|
+
```
|
179
|
+
|
180
|
+
|
181
|
+
### imgcheck Options
|
182
|
+
imgcheck can take an additional options object. The available options are:
|
183
|
+
|
184
|
+
```rb
|
185
|
+
options = {
|
186
|
+
customimgid: 1 # Custom ID that will be associated with the image
|
187
|
+
callback: url # Callback URL that will receive a GET request once the image has been moderated
|
188
|
+
}
|
189
|
+
|
190
|
+
puts @wp.imgcheck(imgurl, options)
|
191
|
+
```
|
192
|
+
|
193
|
+
|
194
|
+
<a name="imgstatus" />
|
195
|
+
### imgstatus
|
196
|
+
Check the moderation status of an image. Returns one of the following strings: pending, approved, declined.
|
197
|
+
|
198
|
+
```rb
|
199
|
+
puts @wp.imgstatus(imgid)
|
200
|
+
```
|
201
|
+
|
202
|
+
|
203
|
+
### imgstatus Options
|
204
|
+
imgstatus can take an additional options object. The available options are:
|
205
|
+
|
206
|
+
```rb
|
207
|
+
options = {
|
208
|
+
customimgid: 1 # Custom ID that is associated with the image
|
209
|
+
}
|
210
|
+
|
211
|
+
puts @wp.imgstatus(imgid, options)
|
212
|
+
```
|
213
|
+
|
214
|
+
|
215
|
+
<a name="imgaccount" />
|
216
|
+
### imgaccount
|
217
|
+
Check the number of image submissions remaining on your license. Returns an integer.
|
218
|
+
|
219
|
+
```rb
|
220
|
+
p @wp.imgaccount
|
221
|
+
```
|
222
|
+
|
168
223
|
## To-do:
|
169
224
|
* Handle error responses
|
170
225
|
* Tests
|
data/lib/web_purify/client.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
-
require_relative 'methods/
|
1
|
+
require_relative 'methods/text_filters'
|
2
2
|
require_relative 'methods/blacklist'
|
3
3
|
require_relative 'methods/whitelist'
|
4
|
+
require_relative 'methods/image_filters'
|
4
5
|
|
5
6
|
# WebPurify::Client
|
6
7
|
#
|
7
8
|
# The WebPurify::Client class maintains state of the request parameters like api_key, endpoint, etc.,
|
8
9
|
# and provides easy methods for accessing WebPurify
|
9
10
|
class WebPurify::Client
|
10
|
-
include WebPurify::
|
11
|
+
include WebPurify::TextFilters
|
11
12
|
include WebPurify::Blacklist
|
12
13
|
include WebPurify::Whitelist
|
14
|
+
include WebPurify::ImageFilters
|
13
15
|
|
14
16
|
# Initialize the class
|
15
17
|
#
|
@@ -26,7 +28,7 @@ class WebPurify::Client
|
|
26
28
|
end
|
27
29
|
|
28
30
|
@request_base = {
|
29
|
-
:host => WebPurify::Constants.
|
31
|
+
:host => WebPurify::Constants.text_endpoints.fetch(@endpoint),
|
30
32
|
:path => WebPurify::Constants.rest_path,
|
31
33
|
:scheme => WebPurify::Constants.scheme(@enterprise)
|
32
34
|
}
|
@@ -36,4 +38,13 @@ class WebPurify::Client
|
|
36
38
|
:format => WebPurify::Constants.format
|
37
39
|
}
|
38
40
|
end
|
41
|
+
|
42
|
+
def text_request_base
|
43
|
+
@request_base
|
44
|
+
end
|
45
|
+
|
46
|
+
def image_request_base
|
47
|
+
@request_base.merge(:host => WebPurify::Constants.image_endpoint)
|
48
|
+
end
|
49
|
+
|
39
50
|
end
|
data/lib/web_purify/constants.rb
CHANGED
@@ -5,18 +5,26 @@ module WebPurify
|
|
5
5
|
# WebPurify::Constants holds all the static variables used to access the API.
|
6
6
|
module Constants
|
7
7
|
|
8
|
-
# The
|
8
|
+
# The endpoints for the text moderation service
|
9
9
|
#
|
10
|
-
# @return [Hash] A hash of
|
11
|
-
def self.
|
10
|
+
# @return [Hash] A hash of endpoints
|
11
|
+
def self.text_endpoints
|
12
12
|
return {
|
13
13
|
:us => 'api1.webpurify.com',
|
14
14
|
:eu => 'api1-eu.webpurify.com',
|
15
15
|
:ap => 'api1-ap.webpurify.com'
|
16
16
|
}
|
17
17
|
end
|
18
|
-
|
19
|
-
|
18
|
+
|
19
|
+
|
20
|
+
# The endpoint for the image moderation service
|
21
|
+
#
|
22
|
+
# @return [String] The endpoint
|
23
|
+
def self.image_endpoint
|
24
|
+
return 'im-api1.webpurify.com'
|
25
|
+
end
|
26
|
+
|
27
|
+
|
20
28
|
# Path appended to the endpoint URI
|
21
29
|
#
|
22
30
|
# @return [String] The rest path
|
@@ -57,7 +65,10 @@ module WebPurify
|
|
57
65
|
:remove_from_blacklist => 'webpurify.live.removefromblacklist',
|
58
66
|
:remove_from_whitelist => 'webpurify.live.removefromwhitelist',
|
59
67
|
:get_blacklist => 'webpurify.live.getblacklist',
|
60
|
-
:get_whitelist => 'webpurify.live.getwhitelist'
|
68
|
+
:get_whitelist => 'webpurify.live.getwhitelist',
|
69
|
+
:imgcheck => 'webpurify.live.imgcheck',
|
70
|
+
:imgstatus => 'webpurify.live.imgstatus',
|
71
|
+
:imgaccount => 'webpurify.live.imgaccount'
|
61
72
|
}
|
62
73
|
end
|
63
74
|
|
@@ -16,7 +16,7 @@ module WebPurify
|
|
16
16
|
:word => word,
|
17
17
|
:ds => deep_search
|
18
18
|
}
|
19
|
-
parsed = WebPurify::Request.query(
|
19
|
+
parsed = WebPurify::Request.query(text_request_base, @query_base, params)
|
20
20
|
return parsed[:success]=='1'
|
21
21
|
end
|
22
22
|
|
@@ -30,7 +30,7 @@ module WebPurify
|
|
30
30
|
:method => WebPurify::Constants.methods[:remove_from_blacklist],
|
31
31
|
:word => word
|
32
32
|
}
|
33
|
-
parsed = WebPurify::Request.query(
|
33
|
+
parsed = WebPurify::Request.query(text_request_base, @query_base, params)
|
34
34
|
return parsed[:success]=='1'
|
35
35
|
end
|
36
36
|
|
@@ -42,7 +42,7 @@ module WebPurify
|
|
42
42
|
params = {
|
43
43
|
:method => WebPurify::Constants.methods[:get_blacklist]
|
44
44
|
}
|
45
|
-
parsed = WebPurify::Request.query(
|
45
|
+
parsed = WebPurify::Request.query(text_request_base, @query_base, params)
|
46
46
|
if parsed[:word]
|
47
47
|
return [] << parsed[:word]
|
48
48
|
else
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module WebPurify
|
2
|
+
|
3
|
+
# WebPurify::ImageFilters
|
4
|
+
#
|
5
|
+
# Handles methods related to determining/filtering prohibited image content
|
6
|
+
module ImageFilters
|
7
|
+
|
8
|
+
# Check for existence of prohibited image content
|
9
|
+
#
|
10
|
+
# @param imgurl [String] URL of the image to be moderated
|
11
|
+
# @param options [Hash] Options hash, used to set additional parameters
|
12
|
+
# @return [String] Image ID that is used to return results to the callback function
|
13
|
+
def imgcheck(imgurl, options={})
|
14
|
+
params = {
|
15
|
+
:method => WebPurify::Constants.methods[:imgcheck],
|
16
|
+
:imgurl => imgurl
|
17
|
+
}
|
18
|
+
parsed = WebPurify::Request.query(image_request_base, @query_base, params.merge(options))
|
19
|
+
return parsed[:imgid]
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
# Return status of image moderation
|
24
|
+
#
|
25
|
+
# @param imgid [String] ID of the image being moderated
|
26
|
+
# @param options [Hash] Options hash, used to set additional parameters
|
27
|
+
# @return [String] Status of image moderation
|
28
|
+
def imgstatus(imgid, options={})
|
29
|
+
params = {
|
30
|
+
:method => WebPurify::Constants.methods[:imgstatus],
|
31
|
+
:imgid => imgid
|
32
|
+
}
|
33
|
+
parsed = WebPurify::Request.query(image_request_base, @query_base, params.merge(options))
|
34
|
+
return parsed[:status]
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
# Return number of image submissions remaining on license
|
39
|
+
#
|
40
|
+
# @return [Integer] Number of image submissions remaining
|
41
|
+
def imgaccount
|
42
|
+
params = {
|
43
|
+
:method => WebPurify::Constants.methods[:imgaccount]
|
44
|
+
}
|
45
|
+
parsed = WebPurify::Request.query(image_request_base, @query_base, params)
|
46
|
+
return parsed[:remaining].to_i
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module WebPurify
|
2
2
|
|
3
|
-
# WebPurify::
|
3
|
+
# WebPurify::TextFilters
|
4
4
|
#
|
5
5
|
# Handles methods related to determining/filtering profane text
|
6
|
-
module
|
6
|
+
module TextFilters
|
7
7
|
|
8
8
|
# Check for existence of profanity
|
9
9
|
#
|
@@ -15,7 +15,7 @@ module WebPurify
|
|
15
15
|
:method => WebPurify::Constants.methods[:check],
|
16
16
|
:text => text
|
17
17
|
}
|
18
|
-
parsed = WebPurify::Request.query(
|
18
|
+
parsed = WebPurify::Request.query(text_request_base, @query_base, params.merge(options))
|
19
19
|
return parsed[:found]=='1'
|
20
20
|
end
|
21
21
|
|
@@ -30,7 +30,7 @@ module WebPurify
|
|
30
30
|
:method => WebPurify::Constants.methods[:check_count],
|
31
31
|
:text => text
|
32
32
|
}
|
33
|
-
parsed = WebPurify::Request.query(
|
33
|
+
parsed = WebPurify::Request.query(text_request_base, @query_base, params.merge(options))
|
34
34
|
return parsed[:found].to_i
|
35
35
|
end
|
36
36
|
|
@@ -43,11 +43,11 @@ module WebPurify
|
|
43
43
|
# @return [String] The original text, replaced with the provided symbol
|
44
44
|
def replace(text, symbol, options={})
|
45
45
|
params = {
|
46
|
-
:method
|
47
|
-
:text
|
46
|
+
:method => WebPurify::Constants.methods[:replace],
|
47
|
+
:text => text,
|
48
48
|
:replacesymbol => symbol
|
49
49
|
}
|
50
|
-
parsed = WebPurify::Request.query(
|
50
|
+
parsed = WebPurify::Request.query(text_request_base, @query_base, params.merge(options))
|
51
51
|
return parsed[:text]
|
52
52
|
end
|
53
53
|
|
@@ -62,7 +62,7 @@ module WebPurify
|
|
62
62
|
:method => WebPurify::Constants.methods[:return],
|
63
63
|
:text => text
|
64
64
|
}
|
65
|
-
parsed = WebPurify::Request.query(
|
65
|
+
parsed = WebPurify::Request.query(text_request_base, @query_base, params.merge(options))
|
66
66
|
if parsed[:expletive].is_a?(String)
|
67
67
|
return [] << parsed[:expletive]
|
68
68
|
else
|
@@ -14,7 +14,7 @@ module WebPurify
|
|
14
14
|
:method => WebPurify::Constants.methods[:add_to_whitelist],
|
15
15
|
:word => word
|
16
16
|
}
|
17
|
-
parsed = WebPurify::Request.query(
|
17
|
+
parsed = WebPurify::Request.query(text_request_base, @query_base, params)
|
18
18
|
return parsed[:success]=='1'
|
19
19
|
end
|
20
20
|
|
@@ -28,7 +28,7 @@ module WebPurify
|
|
28
28
|
:method => WebPurify::Constants.methods[:remove_from_whitelist],
|
29
29
|
:word => word
|
30
30
|
}
|
31
|
-
parsed = WebPurify::Request.query(
|
31
|
+
parsed = WebPurify::Request.query(text_request_base, @query_base, params)
|
32
32
|
return parsed[:success]=='1'
|
33
33
|
end
|
34
34
|
|
@@ -40,7 +40,7 @@ module WebPurify
|
|
40
40
|
params = {
|
41
41
|
:method => WebPurify::Constants.methods[:get_whitelist]
|
42
42
|
}
|
43
|
-
parsed = WebPurify::Request.query(
|
43
|
+
parsed = WebPurify::Request.query(text_request_base, @query_base, params)
|
44
44
|
if parsed[:word]
|
45
45
|
return [] << parsed[:word]
|
46
46
|
else
|
data/lib/web_purify/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://im-api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.imgaccount
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- im-api1.webpurify.com
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Tue, 28 Apr 2015 21:55:34 GMT
|
27
|
+
Content-Type:
|
28
|
+
- 'application/json; charset: utf-8'
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
body:
|
34
|
+
encoding: UTF-8
|
35
|
+
string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.imgaccount","format":"rest","remaining":"96","api_key":"<WEBPURIFY_API_KEY>"}}'
|
36
|
+
http_version:
|
37
|
+
recorded_at: Tue, 28 Apr 2015 21:55:04 GMT
|
38
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://im-api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&imgurl=http://www.example.com/test.jpg&method=webpurify.live.imgcheck
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- im-api1.webpurify.com
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Tue, 28 Apr 2015 20:13:38 GMT
|
27
|
+
Content-Type:
|
28
|
+
- 'application/json; charset: utf-8'
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
body:
|
34
|
+
encoding: UTF-8
|
35
|
+
string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.imgcheck","format":"rest","imgid":"a1c9800a4f4a27dd88055fa7529d5101","status":"pending","api_key":"<WEBPURIFY_API_KEY>"}}'
|
36
|
+
http_version:
|
37
|
+
recorded_at: Tue, 28 Apr 2015 20:13:08 GMT
|
38
|
+
recorded_with: VCR 2.9.3
|
data/spec/fixtures/vcr/WebPurify_ImageFilters/imgstatus/returns_the_status_of_image_moderation.yml
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://im-api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&imgurl=http://www.example.com/test.jpg&method=webpurify.live.imgcheck
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- im-api1.webpurify.com
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Tue, 28 Apr 2015 21:46:03 GMT
|
27
|
+
Content-Type:
|
28
|
+
- 'application/json; charset: utf-8'
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
body:
|
34
|
+
encoding: UTF-8
|
35
|
+
string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.imgcheck","format":"rest","imgid":"d334790fbc44e4b1d95a4fdbeb2f9d6f","status":"pending","api_key":"<WEBPURIFY_API_KEY>"}}'
|
36
|
+
http_version:
|
37
|
+
recorded_at: Tue, 28 Apr 2015 21:45:33 GMT
|
38
|
+
- request:
|
39
|
+
method: get
|
40
|
+
uri: http://im-api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&imgid=d334790fbc44e4b1d95a4fdbeb2f9d6f&method=webpurify.live.imgstatus
|
41
|
+
body:
|
42
|
+
encoding: US-ASCII
|
43
|
+
string: ''
|
44
|
+
headers:
|
45
|
+
Accept-Encoding:
|
46
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
47
|
+
Accept:
|
48
|
+
- "*/*"
|
49
|
+
User-Agent:
|
50
|
+
- Ruby
|
51
|
+
Host:
|
52
|
+
- im-api1.webpurify.com
|
53
|
+
response:
|
54
|
+
status:
|
55
|
+
code: 200
|
56
|
+
message: OK
|
57
|
+
headers:
|
58
|
+
Server:
|
59
|
+
- nginx
|
60
|
+
Date:
|
61
|
+
- Tue, 28 Apr 2015 21:46:03 GMT
|
62
|
+
Content-Type:
|
63
|
+
- 'application/json; charset: utf-8'
|
64
|
+
Transfer-Encoding:
|
65
|
+
- chunked
|
66
|
+
Connection:
|
67
|
+
- keep-alive
|
68
|
+
body:
|
69
|
+
encoding: UTF-8
|
70
|
+
string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.imgstatus","format":"rest","imgid":"d334790fbc44e4b1d95a4fdbeb2f9d6f","sdate":"2015-04-28
|
71
|
+
14:46:27","mdate":"","status":"pending","api_key":"<WEBPURIFY_API_KEY>"}}'
|
72
|
+
http_version:
|
73
|
+
recorded_at: Tue, 28 Apr 2015 21:45:33 GMT
|
74
|
+
recorded_with: VCR 2.9.3
|
data/spec/fixtures/vcr/{WebPurify_Filters → WebPurify_TextFilters}/check/safe_text_returns_false.yml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WebPurify::ImageFilters, "#imgcheck", vcr: true do
|
4
|
+
let(:client) { WebPurify::Client.new(api_key: ENV["WEBPURIFY_API_KEY"], service: :image) }
|
5
|
+
let(:imgurl) { "http://www.example.com/test.jpg" }
|
6
|
+
subject { client.imgcheck(imgurl) }
|
7
|
+
|
8
|
+
it "returns an image ID" do
|
9
|
+
expect(subject).to be_instance_of(String)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
describe WebPurify::ImageFilters, "#imgstatus", vcr: true do
|
15
|
+
let(:client) { WebPurify::Client.new(api_key: ENV["WEBPURIFY_API_KEY"], service: :image) }
|
16
|
+
let(:imgurl) { "http://www.example.com/test.jpg" }
|
17
|
+
let(:imgid) { client.imgcheck(imgurl) }
|
18
|
+
subject { client.imgstatus(imgid) }
|
19
|
+
|
20
|
+
it "returns the status of image moderation" do
|
21
|
+
expect(subject).to eq("pending")
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe WebPurify::ImageFilters, "#imgaccount", vcr: true do
|
27
|
+
let(:client) { WebPurify::Client.new(api_key: ENV["WEBPURIFY_API_KEY"], service: :image) }
|
28
|
+
subject { client.imgaccount }
|
29
|
+
|
30
|
+
it "returns the number of image submissions remaining" do
|
31
|
+
expect(subject).to be_kind_of(Integer)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe WebPurify::
|
3
|
+
describe WebPurify::TextFilters, "#check", vcr: true do
|
4
4
|
let(:client) { WebPurify::Client.new(ENV["WEBPURIFY_API_KEY"]) }
|
5
5
|
let(:options) { {} }
|
6
6
|
subject { client.check(text, options) }
|
@@ -71,7 +71,7 @@ describe WebPurify::Filters, "#check", vcr: true do
|
|
71
71
|
|
72
72
|
end
|
73
73
|
|
74
|
-
describe WebPurify::
|
74
|
+
describe WebPurify::TextFilters, "#check_count", vcr: true do
|
75
75
|
let(:client) { WebPurify::Client.new(ENV["WEBPURIFY_API_KEY"]) }
|
76
76
|
subject { client.check_count(text) }
|
77
77
|
|
@@ -101,7 +101,7 @@ describe WebPurify::Filters, "#check_count", vcr: true do
|
|
101
101
|
|
102
102
|
end
|
103
103
|
|
104
|
-
describe WebPurify::
|
104
|
+
describe WebPurify::TextFilters, "#replace", vcr: true do
|
105
105
|
let(:client) { WebPurify::Client.new(ENV["WEBPURIFY_API_KEY"]) }
|
106
106
|
subject { client.replace(text, "*") }
|
107
107
|
|
@@ -123,7 +123,7 @@ describe WebPurify::Filters, "#replace", vcr: true do
|
|
123
123
|
|
124
124
|
end
|
125
125
|
|
126
|
-
describe WebPurify::
|
126
|
+
describe WebPurify::TextFilters, "#return", vcr: true do
|
127
127
|
let(:client) { WebPurify::Client.new(ENV["WEBPURIFY_API_KEY"]) }
|
128
128
|
subject { client.return(text) }
|
129
129
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpurify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Zimmerman
|
@@ -80,29 +80,34 @@ files:
|
|
80
80
|
- lib/web_purify/client.rb
|
81
81
|
- lib/web_purify/constants.rb
|
82
82
|
- lib/web_purify/methods/blacklist.rb
|
83
|
-
- lib/web_purify/methods/
|
83
|
+
- lib/web_purify/methods/image_filters.rb
|
84
|
+
- lib/web_purify/methods/text_filters.rb
|
84
85
|
- lib/web_purify/methods/whitelist.rb
|
85
86
|
- lib/web_purify/request.rb
|
86
87
|
- lib/web_purify/version.rb
|
87
|
-
- spec/fixtures/vcr/
|
88
|
-
- spec/fixtures/vcr/
|
89
|
-
- spec/fixtures/vcr/
|
90
|
-
- spec/fixtures/vcr/
|
91
|
-
- spec/fixtures/vcr/
|
92
|
-
- spec/fixtures/vcr/
|
93
|
-
- spec/fixtures/vcr/
|
94
|
-
- spec/fixtures/vcr/
|
95
|
-
- spec/fixtures/vcr/
|
96
|
-
- spec/fixtures/vcr/
|
97
|
-
- spec/fixtures/vcr/
|
98
|
-
- spec/fixtures/vcr/
|
99
|
-
- spec/fixtures/vcr/
|
100
|
-
- spec/fixtures/vcr/
|
101
|
-
- spec/fixtures/vcr/
|
102
|
-
- spec/fixtures/vcr/
|
88
|
+
- spec/fixtures/vcr/WebPurify_ImageFilters/imgaccount/returns_the_number_of_image_submissions_remaining.yml
|
89
|
+
- spec/fixtures/vcr/WebPurify_ImageFilters/imgcheck/returns_an_image_ID.yml
|
90
|
+
- spec/fixtures/vcr/WebPurify_ImageFilters/imgstatus/returns_the_status_of_image_moderation.yml
|
91
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/safe_text_returns_false.yml
|
92
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_a_URL_returns_false_by_default.yml
|
93
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_a_URL_when_URLs_are_prohibited_returns_true.yml
|
94
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_a_phone_number_returns_false_by_default.yml
|
95
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_a_phone_number_when_phone_numbers_are_prohibited_returns_true.yml
|
96
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_an_email_returns_false_by_default.yml
|
97
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_an_email_when_emails_are_prohibited_returns_true.yml
|
98
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_profanity_returns_true.yml
|
99
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check_count/no_profanities_returns_0.yml
|
100
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check_count/one_profanity_returns_1.yml
|
101
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check_count/two_profanities_returns_2.yml
|
102
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/replace/safe_text_returns_the_text_with_no_changes.yml
|
103
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/replace/text_with_profanity_returns_the_text_with_profanities_replaced_by_symbols.yml
|
104
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/return/no_profanities_returns_an_empty_array.yml
|
105
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/return/one_profanity_returns_an_array_with_one_profanity.yml
|
106
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/return/two_profanities_returns_an_array_with_two_profanities.yml
|
103
107
|
- spec/spec_helper.rb
|
104
108
|
- spec/support/vcr.rb
|
105
|
-
- spec/web_purify/methods/
|
109
|
+
- spec/web_purify/methods/image_filters_spec.rb
|
110
|
+
- spec/web_purify/methods/text_filters_spec.rb
|
106
111
|
- web_purify.gemspec
|
107
112
|
homepage: https://github.com/mileszim/webpurify-gem
|
108
113
|
licenses: []
|
@@ -128,22 +133,26 @@ signing_key:
|
|
128
133
|
specification_version: 4
|
129
134
|
summary: A RubyGem for interfacing with the WebPurify API.
|
130
135
|
test_files:
|
131
|
-
- spec/fixtures/vcr/
|
132
|
-
- spec/fixtures/vcr/
|
133
|
-
- spec/fixtures/vcr/
|
134
|
-
- spec/fixtures/vcr/
|
135
|
-
- spec/fixtures/vcr/
|
136
|
-
- spec/fixtures/vcr/
|
137
|
-
- spec/fixtures/vcr/
|
138
|
-
- spec/fixtures/vcr/
|
139
|
-
- spec/fixtures/vcr/
|
140
|
-
- spec/fixtures/vcr/
|
141
|
-
- spec/fixtures/vcr/
|
142
|
-
- spec/fixtures/vcr/
|
143
|
-
- spec/fixtures/vcr/
|
144
|
-
- spec/fixtures/vcr/
|
145
|
-
- spec/fixtures/vcr/
|
146
|
-
- spec/fixtures/vcr/
|
136
|
+
- spec/fixtures/vcr/WebPurify_ImageFilters/imgaccount/returns_the_number_of_image_submissions_remaining.yml
|
137
|
+
- spec/fixtures/vcr/WebPurify_ImageFilters/imgcheck/returns_an_image_ID.yml
|
138
|
+
- spec/fixtures/vcr/WebPurify_ImageFilters/imgstatus/returns_the_status_of_image_moderation.yml
|
139
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/safe_text_returns_false.yml
|
140
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_a_URL_returns_false_by_default.yml
|
141
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_a_URL_when_URLs_are_prohibited_returns_true.yml
|
142
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_a_phone_number_returns_false_by_default.yml
|
143
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_a_phone_number_when_phone_numbers_are_prohibited_returns_true.yml
|
144
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_an_email_returns_false_by_default.yml
|
145
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_an_email_when_emails_are_prohibited_returns_true.yml
|
146
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check/text_with_profanity_returns_true.yml
|
147
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check_count/no_profanities_returns_0.yml
|
148
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check_count/one_profanity_returns_1.yml
|
149
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/check_count/two_profanities_returns_2.yml
|
150
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/replace/safe_text_returns_the_text_with_no_changes.yml
|
151
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/replace/text_with_profanity_returns_the_text_with_profanities_replaced_by_symbols.yml
|
152
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/return/no_profanities_returns_an_empty_array.yml
|
153
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/return/one_profanity_returns_an_array_with_one_profanity.yml
|
154
|
+
- spec/fixtures/vcr/WebPurify_TextFilters/return/two_profanities_returns_an_array_with_two_profanities.yml
|
147
155
|
- spec/spec_helper.rb
|
148
156
|
- spec/support/vcr.rb
|
149
|
-
- spec/web_purify/methods/
|
157
|
+
- spec/web_purify/methods/image_filters_spec.rb
|
158
|
+
- spec/web_purify/methods/text_filters_spec.rb
|