indico 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/indico/helper.rb +13 -6
- data/lib/indico/image.rb +79 -74
- data/lib/indico/settings.rb +9 -9
- data/lib/indico/version.rb +1 -1
- data/lib/indico.rb +22 -18
- data/spec/data/dog.jpg +0 -0
- data/spec/imagerecognition_spec.rb +28 -0
- data/spec/indico_spec.rb +11 -5
- data/spec/settings_spec.rb +2 -0
- data/spec/versioning_spec.rb +18 -0
- metadata +20 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24341b66e960ef4cdd9e36ecf862b2b710948797
|
4
|
+
data.tar.gz: 0425f72fb76f39185f36e15d9b41c975d31dc8a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db04ca7b5c47e177d5fe4deea09c08e6be93dab650e78eb056926928e8f09d940dbf7870243299eaa5fdc00d42ae83ec5fab6261c7f0c2c28def0769bc763b94
|
7
|
+
data.tar.gz: 04e0f72440cb63422a8f4c847593a99fa666d11b3156893b7977063483e554419a49e288881ec59b88a48efdd3795fda4c36b8b91eb9250441520c68d798c34f
|
data/lib/indico/helper.rb
CHANGED
@@ -14,6 +14,7 @@ module Indico
|
|
14
14
|
def self.api_handler(data, api, config)
|
15
15
|
server = nil
|
16
16
|
api_key = nil
|
17
|
+
version = nil
|
17
18
|
|
18
19
|
d = {}
|
19
20
|
d['data'] = data
|
@@ -28,15 +29,24 @@ module Indico
|
|
28
29
|
server = config.delete('cloud')
|
29
30
|
api_key = config.delete('api_key')
|
30
31
|
apis = config.delete(:apis)
|
32
|
+
version = config.delete(:version)
|
31
33
|
d = d.merge(config)
|
32
34
|
end
|
33
35
|
|
36
|
+
api_key = (api_key or Indico.config['auth'])
|
37
|
+
server = (server or Indico.config['cloud'])
|
34
38
|
|
35
|
-
|
39
|
+
if api_key.nil?
|
40
|
+
raise ArgumentError, 'api key is required'
|
41
|
+
end
|
42
|
+
|
43
|
+
url = url_join(server, api) + \
|
44
|
+
("?key=" + api_key) + \
|
45
|
+
(apis ? "&apis=" + apis.join(",") : "") + \
|
46
|
+
(version ? "&version=" + version : "")
|
36
47
|
|
37
|
-
url = url_join(server, api) + (apis ? "?apis=" + apis.join(",") : "")
|
38
48
|
response = make_request(url, JSON.dump(d),
|
39
|
-
add_api_key_to_header(
|
49
|
+
add_api_key_to_header(api_key))
|
40
50
|
|
41
51
|
|
42
52
|
results = JSON.parse(response.body)
|
@@ -67,9 +77,6 @@ module Indico
|
|
67
77
|
end
|
68
78
|
|
69
79
|
def self.add_api_key_to_header(api_key)
|
70
|
-
if api_key.nil?
|
71
|
-
raise ArgumentError, 'api key is required'
|
72
|
-
end
|
73
80
|
headers = HEADERS
|
74
81
|
headers['X-ApiKey'] = api_key
|
75
82
|
headers
|
data/lib/indico/image.rb
CHANGED
@@ -2,92 +2,97 @@ require 'oily_png'
|
|
2
2
|
require 'base64'
|
3
3
|
|
4
4
|
module Indico
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
elsif image.class == Array
|
10
|
-
# Batch Request
|
11
|
-
im_array = Array.new
|
5
|
+
def self.preprocess(image, size, min_axis)
|
6
|
+
if image.class == Array
|
7
|
+
# Batch Request
|
8
|
+
im_array = Array.new
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
# process each image
|
11
|
+
image.each do |_image|
|
12
|
+
im_array.push(preprocess(_image, size, min_axis))
|
13
|
+
end
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
return im_array
|
16
|
+
elsif image.class != String
|
17
|
+
raise Exception.new("Image input must be filename or base64 string")
|
18
|
+
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
image = self.min_resize(decoded_image, size)
|
26
|
-
else
|
27
|
-
image = decoded_image.resize(size, size)
|
28
|
-
end
|
29
|
-
else
|
30
|
-
image = decoded_image
|
20
|
+
# Resize and export base64 encoded string
|
21
|
+
return handle_image_input(image, size, min_axis)
|
31
22
|
end
|
32
23
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
24
|
+
def self.min_resize(decoded_image, size)
|
25
|
+
img_size = [decoded_image.width, decoded_image.height]
|
26
|
+
min_idx, max_idx = img_size[0] < img_size[1] ? [0, 1] : [1, 0]
|
27
|
+
aspect = img_size[max_idx] / Float(img_size[min_idx])
|
28
|
+
if aspect > 10
|
29
|
+
warn("An aspect ratio greater than 10:1 is not recommended")
|
30
|
+
end
|
31
|
+
size_arr = [0, 0]
|
32
|
+
size_arr[min_idx] = size
|
33
|
+
size_arr[max_idx] = Integer(size * aspect)
|
34
|
+
image = decoded_image.resize(size_arr[0], size_arr[1])
|
35
|
+
return image
|
43
36
|
end
|
44
|
-
size_arr = [0, 0]
|
45
|
-
size_arr[min_idx] = size
|
46
|
-
size_arr[max_idx] = Integer(size * aspect)
|
47
|
-
image = decoded_image.resize(size_arr[0], size_arr[1])
|
48
|
-
return image
|
49
|
-
end
|
50
37
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
38
|
+
def self.handle_image_input(str, size, min_axis)
|
39
|
+
# Handles string input
|
40
|
+
if File.file?(str)
|
41
|
+
# Handling File Inputs
|
42
|
+
begin
|
43
|
+
image = ChunkyPNG::Image.from_file(str)
|
44
|
+
if min_axis
|
45
|
+
image = self.min_resize(image, size)
|
46
|
+
else
|
47
|
+
image = image.resize(size, size)
|
48
|
+
end
|
49
|
+
image = image.to_data_url.gsub("data:image/png;base64," ,"")
|
50
|
+
rescue
|
51
|
+
File.open(str, 'r') do |file|
|
52
|
+
image = Base64.encode64(file.read)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
else
|
56
|
+
begin
|
57
|
+
image = ChunkyPNG::Image.from_data_url("data:image/png;base64," + str.gsub("data:image/png;base64," ,""))
|
58
|
+
if min_axis
|
59
|
+
image = self.min_resize(image, size)
|
60
|
+
else
|
61
|
+
image = image.resize(size, size)
|
62
|
+
end
|
63
|
+
image = image.to_data_url.gsub("data:image/png;base64," ,"")
|
64
|
+
rescue
|
65
|
+
image = str
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
return image
|
56
70
|
end
|
57
71
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
raise Exception.new("String is not a valid absolute filepath or base64 string")
|
62
|
-
else
|
63
|
-
return ChunkyPNG::Image.from_data_url("data:image/png;base64," + str.gsub("data:image/png;base64," ,""))
|
72
|
+
def self.get_dimension(array)
|
73
|
+
return [] unless array.is_a?(Array)
|
74
|
+
return [array.size] + get_dimension(array[0])
|
64
75
|
end
|
65
|
-
end
|
66
76
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
77
|
+
def self.array_contains_float(array, dimens)
|
78
|
+
# Determines whether or not the array contains floats
|
79
|
+
if not array.is_a?(Array)
|
80
|
+
return array.class == Float
|
81
|
+
end
|
82
|
+
elem = array[0]
|
83
|
+
(0..dimens.size - 2).each do |i|
|
84
|
+
elem = elem[0]
|
85
|
+
end
|
71
86
|
|
72
|
-
|
73
|
-
# Determines whether or not the array contains floats
|
74
|
-
if not array.is_a?(Array)
|
75
|
-
return array.class == Float
|
87
|
+
return elem.class == Float
|
76
88
|
end
|
77
|
-
elem = array[0]
|
78
|
-
(0..dimens.size - 2).each do |i|
|
79
|
-
elem = elem[0]
|
80
|
-
end
|
81
|
-
|
82
|
-
return elem.class == Float
|
83
|
-
end
|
84
89
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
90
|
+
def self.get_rgb(value)
|
91
|
+
# Returns Integer encoding of RGB value used by ChunkyPNG
|
92
|
+
return [
|
93
|
+
ChunkyPNG::Color.r(value),
|
94
|
+
ChunkyPNG::Color.g(value),
|
95
|
+
ChunkyPNG::Color.b(value)
|
96
|
+
]
|
97
|
+
end
|
93
98
|
end
|
data/lib/indico/settings.rb
CHANGED
@@ -7,20 +7,20 @@ HEADERS = { 'Content-Type' => 'application/json',
|
|
7
7
|
'version-number' => Indico::VERSION }
|
8
8
|
# APIS
|
9
9
|
TEXT_APIS = [
|
10
|
-
"political",
|
11
|
-
"sentiment",
|
12
|
-
"sentiment_hq",
|
10
|
+
"political",
|
11
|
+
"sentiment",
|
12
|
+
"sentiment_hq",
|
13
13
|
"language",
|
14
|
-
"text_tags",
|
15
|
-
"twitter_engagement",
|
16
|
-
"keywords",
|
14
|
+
"text_tags",
|
15
|
+
"twitter_engagement",
|
16
|
+
"keywords",
|
17
17
|
"named_entities"
|
18
18
|
]
|
19
19
|
IMAGE_APIS = [
|
20
|
-
"fer",
|
21
|
-
"facial_features",
|
20
|
+
"fer",
|
21
|
+
"facial_features",
|
22
22
|
"facial_localization",
|
23
|
-
"image_features",
|
23
|
+
"image_features",
|
24
24
|
"content_filtering"
|
25
25
|
]
|
26
26
|
|
data/lib/indico/version.rb
CHANGED
data/lib/indico.rb
CHANGED
@@ -30,7 +30,7 @@ module Indico
|
|
30
30
|
|
31
31
|
def self.batch_political(text, config = nil)
|
32
32
|
warn(
|
33
|
-
"The `batch_political` function will be deprecated in the next major upgrade. " +
|
33
|
+
"The `batch_political` function will be deprecated in the next major upgrade. " +
|
34
34
|
"Please call `political` instead with the same arguments"
|
35
35
|
)
|
36
36
|
self.political(text, config)
|
@@ -42,7 +42,7 @@ module Indico
|
|
42
42
|
|
43
43
|
def self.batch_posneg(text, config = nil)
|
44
44
|
warn(
|
45
|
-
"The `batch_posneg` function will be deprecated in the next major upgrade. " +
|
45
|
+
"The `batch_posneg` function will be deprecated in the next major upgrade. " +
|
46
46
|
"Please call `posneg` instead with the same arguments"
|
47
47
|
)
|
48
48
|
self.posneg(text, config)
|
@@ -54,7 +54,7 @@ module Indico
|
|
54
54
|
|
55
55
|
def self.batch_sentiment(text, config = nil)
|
56
56
|
warn(
|
57
|
-
"The `batch_sentiment` function will be deprecated in the next major upgrade. " +
|
57
|
+
"The `batch_sentiment` function will be deprecated in the next major upgrade. " +
|
58
58
|
"Please call `sentiment` instead with the same arguments"
|
59
59
|
)
|
60
60
|
self.sentiment(text, config)
|
@@ -67,7 +67,7 @@ module Indico
|
|
67
67
|
|
68
68
|
def self.batch_twitter_engagement(text, config = nil)
|
69
69
|
warn(
|
70
|
-
"The `batch_twitter_engagement` function will be deprecated in the next major upgrade. " +
|
70
|
+
"The `batch_twitter_engagement` function will be deprecated in the next major upgrade. " +
|
71
71
|
"Please call `twitter_engagement` instead with the same arguments"
|
72
72
|
)
|
73
73
|
self.twitter_engagement(text, config)
|
@@ -79,7 +79,7 @@ module Indico
|
|
79
79
|
|
80
80
|
def self.batch_sentiment_hq(text, config = nil)
|
81
81
|
warn(
|
82
|
-
"The `batch_sentiment_hq` function will be deprecated in the next major upgrade. " +
|
82
|
+
"The `batch_sentiment_hq` function will be deprecated in the next major upgrade. " +
|
83
83
|
"Please call `sentiment_hq` instead with the same arguments"
|
84
84
|
)
|
85
85
|
self.sentiment_hq(text, config)
|
@@ -92,7 +92,7 @@ module Indico
|
|
92
92
|
|
93
93
|
def self.batch_language(text, config = nil)
|
94
94
|
warn(
|
95
|
-
"The `batch_language` function will be deprecated in the next major upgrade. " +
|
95
|
+
"The `batch_language` function will be deprecated in the next major upgrade. " +
|
96
96
|
"Please call `language` instead with the same arguments"
|
97
97
|
)
|
98
98
|
self.language(text, config)
|
@@ -105,7 +105,7 @@ module Indico
|
|
105
105
|
|
106
106
|
def self.batch_text_tags(text, config = nil)
|
107
107
|
warn(
|
108
|
-
"The `batch_text_tags` function will be deprecated in the next major upgrade. " +
|
108
|
+
"The `batch_text_tags` function will be deprecated in the next major upgrade. " +
|
109
109
|
"Please call `text_tags` instead with the same arguments"
|
110
110
|
)
|
111
111
|
self.text_tags(text, config)
|
@@ -118,7 +118,7 @@ module Indico
|
|
118
118
|
|
119
119
|
def self.batch_keywords(text, config = nil)
|
120
120
|
warn(
|
121
|
-
"The `batch_keywords` function will be deprecated in the next major upgrade. " +
|
121
|
+
"The `batch_keywords` function will be deprecated in the next major upgrade. " +
|
122
122
|
"Please call `keywords` instead with the same arguments"
|
123
123
|
)
|
124
124
|
self.keywords(text, config)
|
@@ -131,7 +131,7 @@ module Indico
|
|
131
131
|
|
132
132
|
def self.batch_named_entities(text, config = nil)
|
133
133
|
warn(
|
134
|
-
"The `batch_named_entities` function will be deprecated in the next major upgrade. " +
|
134
|
+
"The `batch_named_entities` function will be deprecated in the next major upgrade. " +
|
135
135
|
"Please call `named_entities` instead with the same arguments"
|
136
136
|
)
|
137
137
|
self.named_entities(text, config)
|
@@ -144,7 +144,7 @@ module Indico
|
|
144
144
|
|
145
145
|
def self.batch_fer(image, config = nil)
|
146
146
|
warn(
|
147
|
-
"The `batch_fer` function will be deprecated in the next major upgrade. " +
|
147
|
+
"The `batch_fer` function will be deprecated in the next major upgrade. " +
|
148
148
|
"Please call `fer` instead with the same arguments"
|
149
149
|
)
|
150
150
|
self.fer(image, config)
|
@@ -157,31 +157,35 @@ module Indico
|
|
157
157
|
|
158
158
|
def self.batch_facial_features(image, config = nil)
|
159
159
|
warn(
|
160
|
-
"The `batch_facial_features` function will be deprecated in the next major upgrade. " +
|
160
|
+
"The `batch_facial_features` function will be deprecated in the next major upgrade. " +
|
161
161
|
"Please call `facial_features` instead with the same arguments"
|
162
162
|
)
|
163
163
|
self.facial_features(image, config)
|
164
164
|
end
|
165
165
|
|
166
166
|
def self.facial_localization(image, config = nil)
|
167
|
-
api_handler(preprocess(image,
|
167
|
+
api_handler(preprocess(image, false, false), 'faciallocalization', config)
|
168
168
|
end
|
169
169
|
|
170
170
|
def self.batch_facial_localization(image, config = nil)
|
171
171
|
warn(
|
172
|
-
"The `batch_facial_localization` function will be deprecated in the next major upgrade. " +
|
172
|
+
"The `batch_facial_localization` function will be deprecated in the next major upgrade. " +
|
173
173
|
"Please call `facial_localization` instead with the same arguments"
|
174
174
|
)
|
175
175
|
self.facial_localization(image, config)
|
176
176
|
end
|
177
177
|
|
178
178
|
def self.image_features(image, config = nil)
|
179
|
-
api_handler(preprocess(image,
|
179
|
+
api_handler(preprocess(image, 144, true), 'imagefeatures', config)
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.image_recognition(image, config = nil)
|
183
|
+
api_handler(preprocess(image, 144, true), 'imagerecognition', config)
|
180
184
|
end
|
181
185
|
|
182
186
|
def self.batch_image_features(image, config = nil)
|
183
187
|
warn(
|
184
|
-
"The `batch_image_features` function will be deprecated in the next major upgrade. " +
|
188
|
+
"The `batch_image_features` function will be deprecated in the next major upgrade. " +
|
185
189
|
"Please call `image_features` instead with the same arguments"
|
186
190
|
)
|
187
191
|
self.image_features(image, config)
|
@@ -193,7 +197,7 @@ module Indico
|
|
193
197
|
|
194
198
|
def self.batch_content_filtering(image, config = nil)
|
195
199
|
warn(
|
196
|
-
"The `batch_content_filtering` function will be deprecated in the next major upgrade. " +
|
200
|
+
"The `batch_content_filtering` function will be deprecated in the next major upgrade. " +
|
197
201
|
"Please call `content_filtering` instead with the same arguments"
|
198
202
|
)
|
199
203
|
self.content_filtering(image, config)
|
@@ -206,7 +210,7 @@ module Indico
|
|
206
210
|
|
207
211
|
def self.batch_analyze_image(image, apis = IMAGE_APIS, config = nil)
|
208
212
|
warn(
|
209
|
-
"The `batch_analyze_image` function will be deprecated in the next major upgrade. " +
|
213
|
+
"The `batch_analyze_image` function will be deprecated in the next major upgrade. " +
|
210
214
|
"Please call `analyze_image` instead with the same arguments"
|
211
215
|
)
|
212
216
|
self.analyze_image(image, apis, config)
|
@@ -219,7 +223,7 @@ module Indico
|
|
219
223
|
|
220
224
|
def self.batch_analyze_text(text, apis = TEXT_APIS, config = nil)
|
221
225
|
warn(
|
222
|
-
"The `batch_analyze_text` function will be deprecated in the next major upgrade. " +
|
226
|
+
"The `batch_analyze_text` function will be deprecated in the next major upgrade. " +
|
223
227
|
"Please call `analyze_text` instead with the same arguments"
|
224
228
|
)
|
225
229
|
self.analyze_text(text, apis, config)
|
data/spec/data/dog.jpg
ADDED
Binary file
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Indico do
|
4
|
+
before do
|
5
|
+
api_key = ENV['INDICO_API_KEY']
|
6
|
+
private_cloud = 'indico-test'
|
7
|
+
@config = { api_key: api_key, cloud: private_cloud}
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'single image recognition should return the right response' do
|
11
|
+
data = File.dirname(__FILE__) + "/data/happy.png"
|
12
|
+
|
13
|
+
config = @config.clone
|
14
|
+
config["top_n"] = 3
|
15
|
+
response = Indico.image_recognition(data, config)
|
16
|
+
expect(response.keys.length).to eql(3)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'batch image recognition should return the right response' do
|
20
|
+
data = File.dirname(__FILE__) + "/data/happy.png"
|
21
|
+
|
22
|
+
config = @config.clone
|
23
|
+
config["top_n"] = 3
|
24
|
+
response = Indico.image_recognition([data, data], config)
|
25
|
+
expect(response.length).to eql(2)
|
26
|
+
expect(response[0].keys.length).to eql(3)
|
27
|
+
end
|
28
|
+
end
|
data/spec/indico_spec.rb
CHANGED
@@ -6,8 +6,6 @@ describe Indico do
|
|
6
6
|
before do
|
7
7
|
api_key = ENV['INDICO_API_KEY']
|
8
8
|
private_cloud = 'indico-test'
|
9
|
-
# FIXME - REMOVE WHEN SENTIMENTHQ RELEASE
|
10
|
-
TEXT_APIS.delete("sentiment_hq")
|
11
9
|
@config = { api_key: api_key, cloud: private_cloud}
|
12
10
|
end
|
13
11
|
|
@@ -117,14 +115,14 @@ describe Indico do
|
|
117
115
|
it 'should tag text with correct keywords for auto detect language' do
|
118
116
|
text = "La semaine suivante, il remporte sa premiere victoire, dans la descente de Val Gardena en Italie, près de cinq ans après la dernière victoire en Coupe du monde d'un Français dans cette discipline, avec le succès de Nicolas Burtin à Kvitfjell."
|
119
117
|
config = { "language" => "detect" }
|
120
|
-
response = Indico.keywords(text)
|
118
|
+
response = Indico.keywords(text, config)
|
121
119
|
|
122
120
|
expect Set.new(response.keys).subset?(Set.new(text.gsub(/\s+/m, ' ').strip.split(" ")))
|
123
121
|
end
|
124
122
|
it 'should tag text with correct keywords for specified language' do
|
125
123
|
text = "La semaine suivante, il remporte sa premiere victoire, dans la descente de Val Gardena en Italie, près de cinq ans après la dernière victoire en Coupe du monde d'un Français dans cette discipline, avec le succès de Nicolas Burtin à Kvitfjell."
|
126
124
|
config = { "language" => "French" }
|
127
|
-
response = Indico.keywords(text)
|
125
|
+
response = Indico.keywords(text, config)
|
128
126
|
|
129
127
|
expect Set.new(response.keys).subset?(Set.new(text.gsub(/\s+/m, ' ').strip.split(" ")))
|
130
128
|
end
|
@@ -186,6 +184,14 @@ describe Indico do
|
|
186
184
|
end
|
187
185
|
end
|
188
186
|
|
187
|
+
it 'should tag image with correct image features with jpg files' do
|
188
|
+
test_image= File.dirname(__FILE__) + "/data/dog.jpg"
|
189
|
+
silent_warnings do
|
190
|
+
response = Indico.image_features(test_image)
|
191
|
+
expect(response.length).to eql(2048)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
189
195
|
it "should tag rgb image with correct image features" do
|
190
196
|
test_image = File.open(File.dirname(__FILE__) + "/data/happy64.txt", 'rb') { |f| f.read }
|
191
197
|
silent_warnings do
|
@@ -277,7 +283,7 @@ describe Indico do
|
|
277
283
|
# response = Indico.image_features('http://icons.iconarchive.com/icons/' +
|
278
284
|
# 'oxygen-icons.org/oxygen/48/' +
|
279
285
|
# 'Emotes-face-smile-icon.png')
|
280
|
-
|
286
|
+
#
|
281
287
|
# expect(response.length).to eql(2048)
|
282
288
|
# end
|
283
289
|
end
|
data/spec/settings_spec.rb
CHANGED
@@ -75,6 +75,7 @@ describe Indico do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'should set api key with a call to set_api_key' do
|
78
|
+
saved_key = Indico.api_key
|
78
79
|
Indico.api_key = nil
|
79
80
|
begin
|
80
81
|
Indico.political('Guns don\'t kill people. People kill people.')
|
@@ -91,5 +92,6 @@ describe Indico do
|
|
91
92
|
else
|
92
93
|
fail('api_key was not null')
|
93
94
|
end
|
95
|
+
Indico.api_key = saved_key
|
94
96
|
end
|
95
97
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
describe Indico do
|
2
|
+
before do
|
3
|
+
api_key = ENV['INDICO_API_KEY']
|
4
|
+
private_cloud = 'indico-test'
|
5
|
+
@config = { api_key: api_key, cloud: private_cloud}
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should tag text with correct political tags' do
|
9
|
+
expected_keys = Set.new(%w(Conservative Green Liberal Libertarian))
|
10
|
+
data = 'Guns don\'t kill people. People kill people.'
|
11
|
+
|
12
|
+
# for mocking: use http to redirect requests to our public cloud endpoint
|
13
|
+
config = @config.clone
|
14
|
+
config["version"] = 1
|
15
|
+
response = Indico.political(data, config)
|
16
|
+
expect(Set.new(response.keys)).to eql(expected_keys)
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Slater Victoroff
|
@@ -11,76 +11,76 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: inifile
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
|
-
- -
|
20
|
+
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 3.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.0.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: oily_png
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- -
|
34
|
+
- - ~>
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: 1.2.0
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: 1.2.0
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: bundler
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- -
|
48
|
+
- - ~>
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '1.6'
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- -
|
55
|
+
- - ~>
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '1.6'
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
|
-
- -
|
62
|
+
- - '>='
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- -
|
69
|
+
- - '>='
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '0'
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: rspec
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
|
-
- -
|
76
|
+
- - '>='
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - '>='
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
description: A simple Ruby Wrapper for the indico set of APIs.
|
@@ -93,8 +93,8 @@ executables: []
|
|
93
93
|
extensions: []
|
94
94
|
extra_rdoc_files: []
|
95
95
|
files:
|
96
|
-
-
|
97
|
-
-
|
96
|
+
- .gitignore
|
97
|
+
- .rspec
|
98
98
|
- Gemfile
|
99
99
|
- LICENSE.txt
|
100
100
|
- README.md
|
@@ -109,12 +109,15 @@ files:
|
|
109
109
|
- lib/indico/version.rb
|
110
110
|
- spec/config/.indicorc.test
|
111
111
|
- spec/config/.indicorc.test.2
|
112
|
+
- spec/data/dog.jpg
|
112
113
|
- spec/data/happy.png
|
113
114
|
- spec/data/happy64.txt
|
115
|
+
- spec/imagerecognition_spec.rb
|
114
116
|
- spec/indico_batch_spec.rb
|
115
117
|
- spec/indico_spec.rb
|
116
118
|
- spec/settings_spec.rb
|
117
119
|
- spec/spec_helper.rb
|
120
|
+
- spec/versioning_spec.rb
|
118
121
|
homepage: https://github.com/IndicoDataSolutions/IndicoIo-ruby
|
119
122
|
licenses:
|
120
123
|
- MIT
|
@@ -125,17 +128,17 @@ require_paths:
|
|
125
128
|
- lib
|
126
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
127
130
|
requirements:
|
128
|
-
- -
|
131
|
+
- - '>='
|
129
132
|
- !ruby/object:Gem::Version
|
130
133
|
version: '0'
|
131
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
135
|
requirements:
|
133
|
-
- -
|
136
|
+
- - '>='
|
134
137
|
- !ruby/object:Gem::Version
|
135
138
|
version: '0'
|
136
139
|
requirements: []
|
137
140
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.0.14
|
139
142
|
signing_key:
|
140
143
|
specification_version: 4
|
141
144
|
summary: A simple Ruby Wrapper for the indico set of APIs.
|