isporn 0.1.0 → 0.2.1
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/Gemfile +0 -1
- data/README.md +11 -0
- data/lib/isporn.rb +34 -10
- data/lib/isporn/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79a2a943e2519615d4509089c7a0d12e83bb2c3d
|
4
|
+
data.tar.gz: be4ab68ba2ca141a669306fce6e83d59d5ad403e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d766b5e9157e9faeafbc42d97a6189b96b39ce13cac84bd594ce74ac76547a40d65f5de583d204613e2166511b0bd6dfa438354b957f16ae40405294da744c60
|
7
|
+
data.tar.gz: 5abf5307a825d341d0b7ff037cbbd4183e79bfe6f581015ac040c77952763561b3cb5a8a2af4d079aa97daf29ad9894984db896badc38b189056923788ab1674
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -23,12 +23,23 @@ Or install it yourself as:
|
|
23
23
|
require 'isporn'
|
24
24
|
|
25
25
|
puts '/path/to/test.jpg'.isporn?
|
26
|
+
or
|
27
|
+
|
28
|
+
puts 'http://example.com/image.jpg'.isporn?
|
26
29
|
|
27
30
|
returns:
|
28
31
|
|
29
32
|
# or => normal
|
30
33
|
# or => sexy
|
31
34
|
# or => porn
|
35
|
+
# or => car_normal (cartoon)
|
36
|
+
# or => car_porn (cartoon)
|
37
|
+
|
38
|
+
## CLI mode Usage:
|
39
|
+
|
40
|
+
$> isporn "/path/to/file.jpg".isporn?
|
41
|
+
or
|
42
|
+
$> isporn http://example.com/image.jpg
|
32
43
|
|
33
44
|
## Limited free use
|
34
45
|
|
data/lib/isporn.rb
CHANGED
@@ -25,28 +25,52 @@ module Isporn
|
|
25
25
|
})
|
26
26
|
request.execute
|
27
27
|
end
|
28
|
+
|
29
|
+
def self.exadeep_api_rest_urls urls
|
30
|
+
debug = false
|
31
|
+
|
32
|
+
if urls.class == String
|
33
|
+
urls=[urls]
|
34
|
+
elsif urls.class == Array
|
35
|
+
else
|
36
|
+
return nil
|
37
|
+
end
|
38
|
+
host = "https://exadeep.com"
|
39
|
+
RestClient.log = 'stdout' if debug
|
40
|
+
request = RestClient::Request.new(
|
41
|
+
:method => :post,
|
42
|
+
:url => "#{host}/api/v1",
|
43
|
+
:payload => {
|
44
|
+
:api_key => 'exadeep_ruby_demo_key',
|
45
|
+
:urls => urls
|
46
|
+
})
|
47
|
+
request.execute
|
48
|
+
end
|
28
49
|
end
|
29
50
|
|
30
51
|
class String
|
31
|
-
|
32
52
|
def isporn?
|
33
53
|
is_porn?
|
34
54
|
end
|
35
55
|
|
36
56
|
def is_porn?
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
57
|
+
test_url = self
|
58
|
+
if (test_url =~ /\A#{URI::regexp}\z/)==0 and test_url.length<4096
|
59
|
+
res = Isporn.exadeep_api_rest_urls [self]
|
60
|
+
else
|
61
|
+
temp_fn = "_temp.jpeg"
|
62
|
+
image = MiniMagick::Image.open(self)
|
63
|
+
image.resize "270x270"
|
64
|
+
image.format "jpeg"
|
65
|
+
image.write temp_fn
|
66
|
+
res = Isporn.exadeep_api_rest_post temp_fn
|
67
|
+
File.delete temp_fn
|
68
|
+
end
|
69
|
+
|
45
70
|
j=JSON.parse(res)
|
46
71
|
j["results"].first["scores"].first["label"]
|
47
72
|
end
|
48
73
|
|
49
|
-
|
50
74
|
def is_porn_json
|
51
75
|
Isporn.exadeep_api_rest_post self
|
52
76
|
end
|
data/lib/isporn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isporn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yiling Cao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|