ingenia_api 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +379 -0
- data/Rakefile +2 -0
- data/examples/bundles.rb +74 -0
- data/examples/classify.rb +9 -0
- data/examples/console.rb +13 -0
- data/examples/helper.rb +15 -0
- data/examples/items.rb +124 -0
- data/examples/run_all_examples.rb +7 -0
- data/examples/similar_to.rb +23 -0
- data/examples/summarize.rb +11 -0
- data/examples/tag_sets.rb +75 -0
- data/examples/tags.rb +80 -0
- data/examples/train_classify_similar_to.rb +42 -0
- data/ingenia-api.gemspec +21 -0
- data/lib/ingenia_api.rb +126 -0
- data/lib/ingenia_api/bundle.rb +62 -0
- data/lib/ingenia_api/html_extractor.rb +24 -0
- data/lib/ingenia_api/item.rb +99 -0
- data/lib/ingenia_api/remote.rb +131 -0
- data/lib/ingenia_api/tag.rb +72 -0
- data/lib/ingenia_api/tag_set.rb +59 -0
- data/spec/fixtures/empty_array.json +1 -0
- data/spec/fixtures/empty_hash.json +1 -0
- data/spec/fixtures/five_knowledge_items_index.json +1 -0
- data/spec/fixtures/knowledge_item.json +2 -0
- data/spec/fixtures/knowledge_items.json +1 -0
- data/spec/fixtures/status.json +1 -0
- data/spec/fixtures/success.json +1 -0
- data/spec/fixtures/user_tags.json +1 -0
- data/spec/ingenia_api/api_spec.rb +126 -0
- data/spec/ingenia_api/bundle_spec.rb +78 -0
- data/spec/ingenia_api/html_extractor_spec.rb +29 -0
- data/spec/ingenia_api/item_spec.rb +115 -0
- data/spec/ingenia_api/tag_set_spec.rb +78 -0
- data/spec/ingenia_api/tag_spec.rb +72 -0
- data/spec/spec_helper.rb +66 -0
- metadata +167 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ingenia::Tag do
|
4
|
+
let(:empty_api_response) { { 'status' => 'okay', 'data' => {} } }
|
5
|
+
|
6
|
+
|
7
|
+
describe '#create' do
|
8
|
+
let(:name) { 'this is a test tag' }
|
9
|
+
let(:path) { '/tags' }
|
10
|
+
let(:request) { { json: "{\"name\":\"#{name}\",\"tag_set_id\":1}", api_key: "1234" } }
|
11
|
+
|
12
|
+
specify do
|
13
|
+
expect(Ingenia::Api::Remote).to receive(:post).with(path, request) { empty_api_response }
|
14
|
+
described_class.create(name: name, tag_set_id: 1)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
describe '#update' do
|
20
|
+
let(:name) { 'this is an updated test tag' }
|
21
|
+
let(:path) { '/tags/1' }
|
22
|
+
let(:request) { { json: "{\"name\":\"#{name}\",\"tag_set_id\":1}", api_key: "1234" } }
|
23
|
+
|
24
|
+
specify do
|
25
|
+
expect(Ingenia::Api::Remote).to receive(:put).with(path, request) { empty_api_response }
|
26
|
+
described_class.update(1, name: name, tag_set_id: 1)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#merge' do
|
31
|
+
let(:tag_ids) { [1, 2, 3] }
|
32
|
+
let(:path) { '/tags/1/merge' }
|
33
|
+
let(:request) { { tag_ids: "[1,2,3]", api_key: "1234" } }
|
34
|
+
|
35
|
+
specify do
|
36
|
+
expect(Ingenia::Api::Remote).to receive(:post).with(path, request) { empty_api_response }
|
37
|
+
described_class.merge(1, tag_ids: tag_ids)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#get' do
|
42
|
+
let(:path) { '/tags/1' }
|
43
|
+
let(:request) { { api_key: "1234" } }
|
44
|
+
|
45
|
+
specify do
|
46
|
+
expect(Ingenia::Api::Remote).to receive(:get).with(path, request) { empty_api_response }
|
47
|
+
described_class.get(1)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#all' do
|
52
|
+
let(:path) { '/tags' }
|
53
|
+
let(:request) { { :offset => 0, :limit => 50, :api_key => "1234" } }
|
54
|
+
|
55
|
+
it 'calls get' do
|
56
|
+
expect(Ingenia::Api::Remote).to receive(:get).with(path, request) { empty_api_response }
|
57
|
+
described_class.all(offset: 0, limit: 50)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#delete' do
|
62
|
+
let(:path) { '/tags/1' }
|
63
|
+
let(:request) { { :params => { :api_key => "1234" } } }
|
64
|
+
|
65
|
+
it 'calls delete' do
|
66
|
+
expect(Ingenia::Api::Remote).to receive(:delete).with(path, request) { empty_api_response }
|
67
|
+
described_class.destroy(1)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
|
2
|
+
require 'ingenia_api'
|
3
|
+
require 'webmock/rspec'
|
4
|
+
|
5
|
+
RSpec.configure do |conf|
|
6
|
+
conf.color = true
|
7
|
+
end
|
8
|
+
|
9
|
+
def stub_json_get(path, fixture, opts = {})
|
10
|
+
|
11
|
+
if fixture
|
12
|
+
fixture_file = File.join(File.dirname(__FILE__), 'fixtures', fixture)
|
13
|
+
|
14
|
+
returns = {
|
15
|
+
:body => File.open(fixture_file).read,
|
16
|
+
:headers => { :content_type => "application/json; charset=utf-8" }
|
17
|
+
}
|
18
|
+
else
|
19
|
+
returns = {
|
20
|
+
:body => '',
|
21
|
+
:headers => { :content_type => "" }
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
opts[:endpoint] = Ingenia::Api.endpoint unless opts.has_key? :endpoint
|
26
|
+
|
27
|
+
url = URI.parse('http://' + opts[:endpoint] + path)
|
28
|
+
|
29
|
+
if opts.has_key? :auth_token
|
30
|
+
url.user = opts[:auth_token]
|
31
|
+
url.password = ''
|
32
|
+
end
|
33
|
+
|
34
|
+
url.query = "api_version=1.0"
|
35
|
+
|
36
|
+
stub_request(:get, url.to_s).to_return(returns)
|
37
|
+
end
|
38
|
+
|
39
|
+
def stub_json_put(path, fixture, opts = {})
|
40
|
+
|
41
|
+
if fixture
|
42
|
+
fixture_file = File.join(File.dirname(__FILE__), 'fixtures', fixture)
|
43
|
+
|
44
|
+
returns = {
|
45
|
+
:body => File.open(fixture_file).read,
|
46
|
+
:headers => { :content_type => "application/json; charset=utf-8" }
|
47
|
+
}
|
48
|
+
else
|
49
|
+
returns = {
|
50
|
+
:body => '',
|
51
|
+
:headers => { :content_type => "" }
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
opts[:endpoint] = Ingenia::Api.endpoint unless opts.has_key? :endpoint
|
56
|
+
|
57
|
+
url = URI.parse('http://' + opts[:endpoint] + path)
|
58
|
+
|
59
|
+
if opts.has_key? :auth_token
|
60
|
+
url.user = opts[:auth_token]
|
61
|
+
url.password = ''
|
62
|
+
end
|
63
|
+
|
64
|
+
stub_request(:put, url.to_s).to_return(returns)
|
65
|
+
end
|
66
|
+
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ingenia_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Retechnica Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.8.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.8.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.7.7
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.7.7
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.3.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.3.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.21.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.21.0
|
83
|
+
description: A Ruby API client for Ingenia
|
84
|
+
email:
|
85
|
+
- ingenia-devs@retechnica.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- examples/bundles.rb
|
96
|
+
- examples/classify.rb
|
97
|
+
- examples/console.rb
|
98
|
+
- examples/helper.rb
|
99
|
+
- examples/items.rb
|
100
|
+
- examples/run_all_examples.rb
|
101
|
+
- examples/similar_to.rb
|
102
|
+
- examples/summarize.rb
|
103
|
+
- examples/tag_sets.rb
|
104
|
+
- examples/tags.rb
|
105
|
+
- examples/train_classify_similar_to.rb
|
106
|
+
- ingenia-api.gemspec
|
107
|
+
- lib/ingenia_api.rb
|
108
|
+
- lib/ingenia_api/bundle.rb
|
109
|
+
- lib/ingenia_api/html_extractor.rb
|
110
|
+
- lib/ingenia_api/item.rb
|
111
|
+
- lib/ingenia_api/remote.rb
|
112
|
+
- lib/ingenia_api/tag.rb
|
113
|
+
- lib/ingenia_api/tag_set.rb
|
114
|
+
- spec/fixtures/empty_array.json
|
115
|
+
- spec/fixtures/empty_hash.json
|
116
|
+
- spec/fixtures/five_knowledge_items_index.json
|
117
|
+
- spec/fixtures/knowledge_item.json
|
118
|
+
- spec/fixtures/knowledge_items.json
|
119
|
+
- spec/fixtures/status.json
|
120
|
+
- spec/fixtures/success.json
|
121
|
+
- spec/fixtures/user_tags.json
|
122
|
+
- spec/ingenia_api/api_spec.rb
|
123
|
+
- spec/ingenia_api/bundle_spec.rb
|
124
|
+
- spec/ingenia_api/html_extractor_spec.rb
|
125
|
+
- spec/ingenia_api/item_spec.rb
|
126
|
+
- spec/ingenia_api/tag_set_spec.rb
|
127
|
+
- spec/ingenia_api/tag_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
homepage: http://www.ingeniapi.com
|
130
|
+
licenses: []
|
131
|
+
metadata: {}
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 2.2.2
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: A Ruby API client for Ingenia
|
152
|
+
test_files:
|
153
|
+
- spec/fixtures/empty_array.json
|
154
|
+
- spec/fixtures/empty_hash.json
|
155
|
+
- spec/fixtures/five_knowledge_items_index.json
|
156
|
+
- spec/fixtures/knowledge_item.json
|
157
|
+
- spec/fixtures/knowledge_items.json
|
158
|
+
- spec/fixtures/status.json
|
159
|
+
- spec/fixtures/success.json
|
160
|
+
- spec/fixtures/user_tags.json
|
161
|
+
- spec/ingenia_api/api_spec.rb
|
162
|
+
- spec/ingenia_api/bundle_spec.rb
|
163
|
+
- spec/ingenia_api/html_extractor_spec.rb
|
164
|
+
- spec/ingenia_api/item_spec.rb
|
165
|
+
- spec/ingenia_api/tag_set_spec.rb
|
166
|
+
- spec/ingenia_api/tag_spec.rb
|
167
|
+
- spec/spec_helper.rb
|