webpurify 0.6.0 → 0.7.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.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -1
  3. data/Gemfile +3 -0
  4. data/lib/web_purify/methods/filters.rb +2 -2
  5. data/lib/web_purify/version.rb +1 -1
  6. data/spec/fixtures/vcr/WebPurify_Filters/check/safe_text_returns_false.yml +36 -0
  7. data/spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_URL_returns_false_by_default.yml +36 -0
  8. data/spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_URL_when_URLs_are_prohibited_returns_true.yml +36 -0
  9. data/spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_phone_number_returns_false_by_default.yml +36 -0
  10. data/spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_phone_number_when_phone_numbers_are_prohibited_returns_true.yml +36 -0
  11. data/spec/fixtures/vcr/WebPurify_Filters/check/text_with_an_email_returns_false_by_default.yml +36 -0
  12. data/spec/fixtures/vcr/WebPurify_Filters/check/text_with_an_email_when_emails_are_prohibited_returns_true.yml +36 -0
  13. data/spec/fixtures/vcr/WebPurify_Filters/check/text_with_profanity_returns_true.yml +36 -0
  14. data/spec/fixtures/vcr/WebPurify_Filters/check_count/no_profanities_returns_0.yml +36 -0
  15. data/spec/fixtures/vcr/WebPurify_Filters/check_count/one_profanity_returns_1.yml +36 -0
  16. data/spec/fixtures/vcr/WebPurify_Filters/check_count/two_profanities_returns_2.yml +36 -0
  17. data/spec/fixtures/vcr/WebPurify_Filters/replace/safe_text_returns_the_text_with_no_changes.yml +37 -0
  18. data/spec/fixtures/vcr/WebPurify_Filters/replace/text_with_profanity_returns_the_text_with_profanities_replaced_by_symbols.yml +37 -0
  19. data/spec/fixtures/vcr/WebPurify_Filters/return/no_profanities_returns_an_empty_array.yml +36 -0
  20. data/spec/fixtures/vcr/WebPurify_Filters/return/one_profanity_returns_an_array_with_one_profanity.yml +36 -0
  21. data/spec/fixtures/vcr/WebPurify_Filters/return/two_profanities_returns_an_array_with_two_profanities.yml +36 -0
  22. data/spec/spec_helper.rb +5 -0
  23. data/spec/support/vcr.rb +30 -0
  24. data/spec/web_purify/methods/filters_spec.rb +154 -0
  25. data/web_purify.gemspec +4 -2
  26. metadata +74 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c707414ce2a466ece2257184332ae8b0f01f521
4
- data.tar.gz: dae8c7e08f2a7223d3731734b0773cfb5ed5668e
3
+ metadata.gz: f44313e4a832d95a9949fb6545dfdcaa23039353
4
+ data.tar.gz: 229427f973bfe390c5da33d5f17a2097a180c09c
5
5
  SHA512:
6
- metadata.gz: ab4ab468cdc84cab0b1c2e7550a5fc1d665acef20fa73621cc856e0ffe8da03d150ab23a7d257b6cc20e9a808f9d47177eae1311b96d0edac85fa9e31b1342aa
7
- data.tar.gz: 78f5889a7feda0501de88453c3649dcfcaed2b5d64a4901a27acf46224511a92938a1f21548f22276de4523820e72e1dac7f1a7ed0368a91ebc555b92db17a3e
6
+ metadata.gz: 8e1cbe1fd09fbd8f6f2a912530ae2b47b67de9dea20f0d3e6a941234abc2d9577e659ffe5c6ff79be22488bddb3f0f1f059b3a67edf279244480e6eb96652864
7
+ data.tar.gz: cbb20a28de8a62527cb99b9d23db16c6173f8ca4075a8c7f6b5fb19d134759e3909366ad93d3f9eeb49e9fecc4261e416ce3e2fc34e6e05a6b700f1e0cb6872f
data/.gitignore CHANGED
@@ -17,4 +17,8 @@ tmp
17
17
  _yardoc
18
18
  doc/
19
19
 
20
- test.rb
20
+ test.rb
21
+ Gemfile.lock
22
+ .ruby-version
23
+ .ruby-gemset
24
+ spec/support/webpurify_api_key.rb
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -63,10 +63,10 @@ module WebPurify
63
63
  :text => text
64
64
  }
65
65
  parsed = WebPurify::Request.query(@request_base, @query_base, params.merge(options))
66
- if parsed[:expletive]
66
+ if parsed[:expletive].is_a?(String)
67
67
  return [] << parsed[:expletive]
68
68
  else
69
- return []
69
+ return parsed.fetch(:expletive, [])
70
70
  end
71
71
  end
72
72
 
@@ -1,3 +1,3 @@
1
1
  module WebPurify
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.check&text=safe%20text
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Mon, 27 Apr 2015 22:29:03 GMT
29
+ Content-Length:
30
+ - '142'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.check","format":"rest","found":"0","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Mon, 27 Apr 2015 22:27:51 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.check&text=text%20with%20www.example.com
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Mon, 27 Apr 2015 22:31:53 GMT
29
+ Content-Length:
30
+ - '142'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.check","format":"rest","found":"0","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Mon, 27 Apr 2015 22:31:03 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.check&slink=1&text=text%20with%20www.example.com
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Mon, 27 Apr 2015 22:31:38 GMT
29
+ Content-Length:
30
+ - '142'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.check","format":"rest","found":"1","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Mon, 27 Apr 2015 22:31:03 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.check&text=text%20with%20555-555-5555
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Mon, 27 Apr 2015 22:35:37 GMT
29
+ Content-Length:
30
+ - '142'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.check","format":"rest","found":"0","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Mon, 27 Apr 2015 22:34:25 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.check&sphone=1&text=text%20with%20555-555-5555
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Mon, 27 Apr 2015 22:35:14 GMT
29
+ Content-Length:
30
+ - '142'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.check","format":"rest","found":"1","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Mon, 27 Apr 2015 22:34:25 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.check&text=text%20with%20name@example.com
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Mon, 27 Apr 2015 22:30:40 GMT
29
+ Content-Length:
30
+ - '142'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.check","format":"rest","found":"0","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Mon, 27 Apr 2015 22:29:50 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.check&semail=1&text=text%20with%20name@example.com
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Mon, 27 Apr 2015 22:30:26 GMT
29
+ Content-Length:
30
+ - '142'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.check","format":"rest","found":"1","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Mon, 27 Apr 2015 22:29:51 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.check&text=text%20with%20damn
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Mon, 27 Apr 2015 22:29:03 GMT
29
+ Content-Length:
30
+ - '142'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.check","format":"rest","found":"1","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Mon, 27 Apr 2015 22:27:51 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.checkcount&text=safe%20text
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Tue, 28 Apr 2015 14:33:26 GMT
29
+ Content-Length:
30
+ - '147'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.checkcount","format":"rest","found":"0","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Tue, 28 Apr 2015 14:32:51 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.checkcount&text=text%20with%20damn
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Tue, 28 Apr 2015 14:33:26 GMT
29
+ Content-Length:
30
+ - '147'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.checkcount","format":"rest","found":"1","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Tue, 28 Apr 2015 14:32:51 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.checkcount&text=text%20with%20damn%20and%20hell
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Tue, 28 Apr 2015 14:34:04 GMT
29
+ Content-Length:
30
+ - '147'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.checkcount","format":"rest","found":"2","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Tue, 28 Apr 2015 14:32:51 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,37 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.replace&replacesymbol=*&text=safe%20text
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Tue, 28 Apr 2015 14:45:43 GMT
29
+ Content-Length:
30
+ - '163'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.replace","format":"rest","found":"0","text":"safe
34
+ text","api_key":"<WEBPURIFY_API_KEY>"}}'
35
+ http_version:
36
+ recorded_at: Tue, 28 Apr 2015 14:44:53 GMT
37
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,37 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.replace&replacesymbol=*&text=text%20with%20damn%20and%20hell
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Tue, 28 Apr 2015 15:04:27 GMT
29
+ Content-Length:
30
+ - '177'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.replace","format":"rest","found":"2","text":"text
34
+ with **** and ****","api_key":"<WEBPURIFY_API_KEY>"}}'
35
+ http_version:
36
+ recorded_at: Tue, 28 Apr 2015 15:03:14 GMT
37
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.return&text=safe%20text
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Tue, 28 Apr 2015 15:04:05 GMT
29
+ Content-Length:
30
+ - '143'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.return","format":"rest","found":"0","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Tue, 28 Apr 2015 15:03:29 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.return&text=text%20with%20damn
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Tue, 28 Apr 2015 15:04:15 GMT
29
+ Content-Length:
30
+ - '162'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.return","format":"rest","found":"1","expletive":"damn","api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Tue, 28 Apr 2015 15:03:30 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api1.webpurify.com/services/rest/?api_key=<WEBPURIFY_API_KEY>&format=json&method=webpurify.live.return&text=text%20with%20damn%20and%20hell
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
+ - api1.webpurify.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Powered-By:
26
+ - HPHP
27
+ Date:
28
+ - Tue, 28 Apr 2015 15:04:43 GMT
29
+ Content-Length:
30
+ - '171'
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rsp":{"@attributes":{"stat":"ok"},"method":"webpurify.live.return","format":"rest","found":"2","expletive":["hell","damn"],"api_key":"<WEBPURIFY_API_KEY>"}}'
34
+ http_version:
35
+ recorded_at: Tue, 28 Apr 2015 15:03:30 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'web_purify'
4
+
5
+ Dir['spec/support/**/*.rb'].each { |f| require_relative "../#{f}" }
@@ -0,0 +1,30 @@
1
+ require 'vcr'
2
+
3
+ VCR.configure do |c|
4
+ c.cassette_library_dir = File.join("spec", "fixtures", "vcr")
5
+ c.hook_into :webmock
6
+ c.filter_sensitive_data("<WEBPURIFY_API_KEY>") { ENV["WEBPURIFY_API_KEY"] }
7
+ end
8
+
9
+ # This wraps RSpec examples with vcr: true in a VCR#use_cassette block and creates
10
+ # a cassette using the name of the example the first time an HTTP request is made.
11
+ module VcrHelper
12
+ def with_vcr_cassette example, name = nil, options = {}, &block
13
+ name ||= default_cassette_name_for_example(example)
14
+ VCR.use_cassette name, options, &block
15
+ end
16
+
17
+ def default_cassette_name_for_example(example)
18
+ example.full_description.sub(/\s/, '/').sub('#', '/').gsub(/[^\w\/]+/, "_")
19
+ end
20
+ end
21
+
22
+ RSpec.configuration.include VcrHelper, vcr: true
23
+
24
+ RSpec.configure do |config|
25
+ config.around(:each, vcr: true) do |example|
26
+ with_vcr_cassette(example) do
27
+ example.call
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,154 @@
1
+ require 'spec_helper'
2
+
3
+ describe WebPurify::Filters, "#check", vcr: true do
4
+ let(:client) { WebPurify::Client.new(ENV["WEBPURIFY_API_KEY"]) }
5
+ let(:options) { {} }
6
+ subject { client.check(text, options) }
7
+
8
+ context "safe text" do
9
+ let(:text) { "safe text" }
10
+
11
+ it "returns false" do
12
+ expect(subject).to eq(false)
13
+ end
14
+ end
15
+
16
+ context "text with profanity" do
17
+ let(:text) { "text with damn" }
18
+
19
+ it "returns true" do
20
+ expect(subject).to eq(true)
21
+ end
22
+ end
23
+
24
+ context "text with an email" do
25
+ let(:text) { "text with name@example.com"}
26
+
27
+ it "returns false by default" do
28
+ expect(subject).to eq(false)
29
+ end
30
+
31
+ context "when emails are prohibited" do
32
+ let(:options) { { semail: 1 } }
33
+
34
+ it "returns true" do
35
+ expect(subject).to eq(true)
36
+ end
37
+ end
38
+ end
39
+
40
+ context "text with a phone number" do
41
+ let(:text) { "text with 555-555-5555" }
42
+
43
+ it "returns false by default" do
44
+ expect(subject).to eq(false)
45
+ end
46
+
47
+ context "when phone numbers are prohibited" do
48
+ let(:options) { { sphone: 1 } }
49
+
50
+ it "returns true" do
51
+ expect(subject).to eq(true)
52
+ end
53
+ end
54
+ end
55
+
56
+ context "text with a URL" do
57
+ let(:text) { "text with www.example.com" }
58
+
59
+ it "returns false by default" do
60
+ expect(subject).to eq(false)
61
+ end
62
+
63
+ context "when URLs are prohibited" do
64
+ let(:options) { { slink: 1 } }
65
+
66
+ it "returns true" do
67
+ expect(subject).to eq(true)
68
+ end
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ describe WebPurify::Filters, "#check_count", vcr: true do
75
+ let(:client) { WebPurify::Client.new(ENV["WEBPURIFY_API_KEY"]) }
76
+ subject { client.check_count(text) }
77
+
78
+ context "no profanities" do
79
+ let(:text) { "safe text" }
80
+
81
+ it "returns 0" do
82
+ expect(subject).to eq(0)
83
+ end
84
+ end
85
+
86
+ context "one profanity" do
87
+ let(:text) { "text with damn" }
88
+
89
+ it "returns 1" do
90
+ expect(subject).to eq(1)
91
+ end
92
+ end
93
+
94
+ context "two profanities" do
95
+ let(:text) { "text with damn and hell" }
96
+
97
+ it "returns 2" do
98
+ expect(subject).to eq(2)
99
+ end
100
+ end
101
+
102
+ end
103
+
104
+ describe WebPurify::Filters, "#replace", vcr: true do
105
+ let(:client) { WebPurify::Client.new(ENV["WEBPURIFY_API_KEY"]) }
106
+ subject { client.replace(text, "*") }
107
+
108
+ context "safe text" do
109
+ let(:text) { "safe text" }
110
+
111
+ it "returns the text with no changes" do
112
+ expect(subject).to eq(text)
113
+ end
114
+ end
115
+
116
+ context "text with profanity" do
117
+ let(:text) { "text with damn and hell" }
118
+
119
+ it "returns the text with profanities replaced by symbols" do
120
+ expect(subject).to eq("text with **** and ****")
121
+ end
122
+ end
123
+
124
+ end
125
+
126
+ describe WebPurify::Filters, "#return", vcr: true do
127
+ let(:client) { WebPurify::Client.new(ENV["WEBPURIFY_API_KEY"]) }
128
+ subject { client.return(text) }
129
+
130
+ context "no profanities" do
131
+ let(:text) { "safe text" }
132
+
133
+ it "returns an empty array" do
134
+ expect(subject).to eq([])
135
+ end
136
+ end
137
+
138
+ context "one profanity" do
139
+ let(:text) { "text with damn" }
140
+
141
+ it "returns an array with one profanity" do
142
+ expect(subject).to eq(["damn"])
143
+ end
144
+ end
145
+
146
+ context "two profanities" do
147
+ let(:text) { "text with damn and hell" }
148
+
149
+ it "returns an array with two profanities" do
150
+ expect(subject).to contain_exactly("damn", "hell")
151
+ end
152
+ end
153
+
154
+ end
data/web_purify.gemspec CHANGED
@@ -13,10 +13,12 @@ Gem::Specification.new do |s|
13
13
  s.summary = %q{A RubyGem for interfacing with the WebPurify API.}
14
14
  s.description = %q{A RubyGem for interfacing with the WebPurify API.}
15
15
 
16
- s.add_development_dependency "rspec", "~>2.5.0"
17
-
18
16
  s.add_dependency "json"
19
17
 
18
+ s.add_development_dependency "rspec", "~> 3.2.0"
19
+ s.add_development_dependency "vcr"
20
+ s.add_development_dependency "webmock"
21
+
20
22
  s.files = `git ls-files`.split("\n")
21
23
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
24
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
metadata CHANGED
@@ -1,37 +1,65 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpurify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Zimmerman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-22 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: 2.5.0
33
+ version: 3.2.0
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: 2.5.0
40
+ version: 3.2.0
27
41
  - !ruby/object:Gem::Dependency
28
- name: json
42
+ name: vcr
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
- type: :runtime
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
@@ -46,6 +74,7 @@ extensions: []
46
74
  extra_rdoc_files: []
47
75
  files:
48
76
  - ".gitignore"
77
+ - Gemfile
49
78
  - README.md
50
79
  - lib/web_purify.rb
51
80
  - lib/web_purify/client.rb
@@ -55,6 +84,25 @@ files:
55
84
  - lib/web_purify/methods/whitelist.rb
56
85
  - lib/web_purify/request.rb
57
86
  - lib/web_purify/version.rb
87
+ - spec/fixtures/vcr/WebPurify_Filters/check/safe_text_returns_false.yml
88
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_URL_returns_false_by_default.yml
89
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_URL_when_URLs_are_prohibited_returns_true.yml
90
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_phone_number_returns_false_by_default.yml
91
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_phone_number_when_phone_numbers_are_prohibited_returns_true.yml
92
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_an_email_returns_false_by_default.yml
93
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_an_email_when_emails_are_prohibited_returns_true.yml
94
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_profanity_returns_true.yml
95
+ - spec/fixtures/vcr/WebPurify_Filters/check_count/no_profanities_returns_0.yml
96
+ - spec/fixtures/vcr/WebPurify_Filters/check_count/one_profanity_returns_1.yml
97
+ - spec/fixtures/vcr/WebPurify_Filters/check_count/two_profanities_returns_2.yml
98
+ - spec/fixtures/vcr/WebPurify_Filters/replace/safe_text_returns_the_text_with_no_changes.yml
99
+ - spec/fixtures/vcr/WebPurify_Filters/replace/text_with_profanity_returns_the_text_with_profanities_replaced_by_symbols.yml
100
+ - spec/fixtures/vcr/WebPurify_Filters/return/no_profanities_returns_an_empty_array.yml
101
+ - spec/fixtures/vcr/WebPurify_Filters/return/one_profanity_returns_an_array_with_one_profanity.yml
102
+ - spec/fixtures/vcr/WebPurify_Filters/return/two_profanities_returns_an_array_with_two_profanities.yml
103
+ - spec/spec_helper.rb
104
+ - spec/support/vcr.rb
105
+ - spec/web_purify/methods/filters_spec.rb
58
106
  - web_purify.gemspec
59
107
  homepage: https://github.com/mileszim/webpurify-gem
60
108
  licenses: []
@@ -79,4 +127,23 @@ rubygems_version: 2.2.2
79
127
  signing_key:
80
128
  specification_version: 4
81
129
  summary: A RubyGem for interfacing with the WebPurify API.
82
- test_files: []
130
+ test_files:
131
+ - spec/fixtures/vcr/WebPurify_Filters/check/safe_text_returns_false.yml
132
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_URL_returns_false_by_default.yml
133
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_URL_when_URLs_are_prohibited_returns_true.yml
134
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_phone_number_returns_false_by_default.yml
135
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_a_phone_number_when_phone_numbers_are_prohibited_returns_true.yml
136
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_an_email_returns_false_by_default.yml
137
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_an_email_when_emails_are_prohibited_returns_true.yml
138
+ - spec/fixtures/vcr/WebPurify_Filters/check/text_with_profanity_returns_true.yml
139
+ - spec/fixtures/vcr/WebPurify_Filters/check_count/no_profanities_returns_0.yml
140
+ - spec/fixtures/vcr/WebPurify_Filters/check_count/one_profanity_returns_1.yml
141
+ - spec/fixtures/vcr/WebPurify_Filters/check_count/two_profanities_returns_2.yml
142
+ - spec/fixtures/vcr/WebPurify_Filters/replace/safe_text_returns_the_text_with_no_changes.yml
143
+ - spec/fixtures/vcr/WebPurify_Filters/replace/text_with_profanity_returns_the_text_with_profanities_replaced_by_symbols.yml
144
+ - spec/fixtures/vcr/WebPurify_Filters/return/no_profanities_returns_an_empty_array.yml
145
+ - spec/fixtures/vcr/WebPurify_Filters/return/one_profanity_returns_an_array_with_one_profanity.yml
146
+ - spec/fixtures/vcr/WebPurify_Filters/return/two_profanities_returns_an_array_with_two_profanities.yml
147
+ - spec/spec_helper.rb
148
+ - spec/support/vcr.rb
149
+ - spec/web_purify/methods/filters_spec.rb