keepcon 0.2.2 → 0.2.3
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 +8 -8
- data/README.md +1 -1
- data/lib/keepcon/client.rb +11 -1
- data/lib/keepcon/config/urls.yml +1 -0
- data/lib/keepcon/integration.rb +4 -1
- data/lib/keepcon/version.rb +1 -1
- data/spec/client_spec.rb +27 -0
- data/spec/entity/response_spec.rb +38 -14
- data/spec/integration_spec.rb +13 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzY3Mzc4Y2YxZmIwNzM2YjQyNGM5NGQ2YTQxNmQ2NzhiZjdhNjk4Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmM0MjhlODRiMDU0NjU4MDg3MWVhZjlkZGVjNTBkNzcwZWU5MGRhYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmE4ZTgyNGMyZDhlZGQ3ZTZjNjBkZmFhMmRiNWI3M2Y3MGQwNzM2NGY0NmYw
|
10
|
+
OTZjYmU5NmQ2MThmZDE3MzFjMWQ1M2I4MmVhZTFkMjJkMWQzMDJjYjg4ZDI2
|
11
|
+
OTEzYmVjYjU4OTZmODk4YmY0ZWNlMzU4YWRlZjc3ZjM0OWIxYmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTVjMGM5OGU1MjFkM2M1YzdhYTYwYzQwMjEwYjY4ZGZjY2M1NWU4ZjQxYmNh
|
14
|
+
ZTgwNTFiMTNmMjA3NDM3OTc5ZWY2ODIwOTNmMzFmNzdlZGU5NWM3ZGJkMmUy
|
15
|
+
YzBjMDM4NGZhM2JkMDJlMTczZGVmZDc4MmVlZjEyOWRiNTkzY2Q=
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Keepcon
|
2
2
|
|
3
|
-
|
4
3
|
[](https://travis-ci.org/LoveMondays/keepcon)
|
5
4
|
[](https://codeclimate.com/github/LoveMondays/keepcon)
|
6
5
|
[](https://codeclimate.com/github/LoveMondays/keepcon)
|
6
|
+
[](http://badge.fury.io/rb/keepcon)
|
7
7
|
[](https://gemnasium.com/LoveMondays/keepcon)
|
8
8
|
|
9
9
|
This is a Ruby wrapper for the [Keepcon](http://keepcon.com) API.
|
data/lib/keepcon/client.rb
CHANGED
@@ -25,6 +25,13 @@ module Keepcon
|
|
25
25
|
request(:put, url)
|
26
26
|
end
|
27
27
|
|
28
|
+
def async_ack(setId)
|
29
|
+
url = config['urls']['content']['response']['ack']
|
30
|
+
url = url % { setId: setId }
|
31
|
+
|
32
|
+
request(:put, url)
|
33
|
+
end
|
34
|
+
|
28
35
|
private
|
29
36
|
|
30
37
|
def request(method, path, data = '', mode = :async)
|
@@ -43,7 +50,10 @@ module Keepcon
|
|
43
50
|
end
|
44
51
|
|
45
52
|
def headers
|
46
|
-
{
|
53
|
+
{
|
54
|
+
'User-Agent' => user_agent,
|
55
|
+
'Content-Type' => 'text/plain; charset=utf-8'
|
56
|
+
}
|
47
57
|
end
|
48
58
|
|
49
59
|
def user_agent
|
data/lib/keepcon/config/urls.yml
CHANGED
data/lib/keepcon/integration.rb
CHANGED
@@ -26,7 +26,10 @@ module Keepcon
|
|
26
26
|
context = find_context(context_name)
|
27
27
|
|
28
28
|
results = context.client.async_results_request
|
29
|
-
Entity::Response.new(results)
|
29
|
+
response = Entity::Response.new(results)
|
30
|
+
context.client.async_ack(response.data['setId'])
|
31
|
+
|
32
|
+
response
|
30
33
|
end
|
31
34
|
|
32
35
|
private
|
data/lib/keepcon/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -93,4 +93,31 @@ describe Keepcon::Client do
|
|
93
93
|
it { expect(subject.status).to eq(200) }
|
94
94
|
it { expect(subject.body).to eq('all-results-body') }
|
95
95
|
end
|
96
|
+
|
97
|
+
describe '#async_ack' do
|
98
|
+
subject { client.async_ack('my_set_id') }
|
99
|
+
|
100
|
+
let!(:faraday) { Faraday.new { |f| f.adapter :test, adapter } }
|
101
|
+
let(:adapter) do
|
102
|
+
Faraday::Adapter::Test::Stubs.new do |stub|
|
103
|
+
uri = '/ack/my_set_id'
|
104
|
+
stub.put(uri, '', headers) do |_env|
|
105
|
+
[200, {}, 'ack_response_body']
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
let(:headers) do
|
110
|
+
{
|
111
|
+
'User-Agent' => 'Keepcon Client API REST v1.0 - Context Name: [user]',
|
112
|
+
'Authorization' => 'Basic dXNlcjpwYXNzd29yZA=='
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
before do
|
117
|
+
allow(Faraday).to receive(:new).and_return(faraday)
|
118
|
+
end
|
119
|
+
|
120
|
+
it { expect(subject.status).to eq(200) }
|
121
|
+
it { expect(subject.body).to eq('ack_response_body') }
|
122
|
+
end
|
96
123
|
end
|
@@ -16,24 +16,48 @@ describe Keepcon::Entity::Response do
|
|
16
16
|
describe '#data' do
|
17
17
|
subject { response.data }
|
18
18
|
|
19
|
-
let(:set_id) { '1d523f7e-f430-46dd-b126-980e385130ca' }
|
20
|
-
let(:body) do
|
21
|
-
<<-XML
|
22
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
23
|
-
<response>
|
24
|
-
<status>OK</status>
|
25
|
-
<setId>#{set_id}</setId>
|
26
|
-
</response>
|
27
|
-
XML
|
28
|
-
end
|
29
|
-
|
30
|
-
it { is_expected.to include('status' => 'OK') }
|
31
|
-
it { is_expected.to include('setId' => set_id) }
|
32
|
-
|
33
19
|
context 'when the body is empty' do
|
34
20
|
let(:body) { '' }
|
35
21
|
|
36
22
|
it { is_expected.to eq({}) }
|
37
23
|
end
|
24
|
+
|
25
|
+
context 'when the body is a sample of send data to process' do
|
26
|
+
let(:body) do
|
27
|
+
<<-XML
|
28
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
29
|
+
<response>
|
30
|
+
<status>OK</status>
|
31
|
+
<setId>b126-980e385130ca</setId>
|
32
|
+
</response>
|
33
|
+
XML
|
34
|
+
end
|
35
|
+
|
36
|
+
it { is_expected.to include('status' => 'OK') }
|
37
|
+
it { is_expected.to include('setId' => 'b126-980e385130ca') }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when the body is a sample of send data to process' do
|
41
|
+
let(:body) do
|
42
|
+
<<-XML
|
43
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
44
|
+
<export setId="b537-35642fb84114">
|
45
|
+
<contents>
|
46
|
+
<content id="159407">
|
47
|
+
<moderatorName>AutomaticModerator</moderatorName>
|
48
|
+
<moderationDate>1440533232819</moderationDate>
|
49
|
+
<moderationDecision>UNKNOWN</moderationDecision>
|
50
|
+
<tagging>
|
51
|
+
<tag>02_PercepcaoEmotiva_qualidadeDeVida_neg</tag>
|
52
|
+
<tag>sa_Negativo</tag>
|
53
|
+
</tagging>
|
54
|
+
</content>
|
55
|
+
</contents>
|
56
|
+
</export>
|
57
|
+
XML
|
58
|
+
end
|
59
|
+
|
60
|
+
it { expect(subject['setId']).to eq('b537-35642fb84114') }
|
61
|
+
end
|
38
62
|
end
|
39
63
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -99,7 +99,15 @@ describe Keepcon::Integration do
|
|
99
99
|
describe '.fetch_keepcon_results' do
|
100
100
|
subject { dummy_class.fetch_keepcon_results(context) }
|
101
101
|
|
102
|
-
let(:results) { double status: 200, body:
|
102
|
+
let(:results) { double status: 200, body: body }
|
103
|
+
let(:body) do
|
104
|
+
<<-XML
|
105
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
106
|
+
<export setId="b537-35642fb84114">
|
107
|
+
<contents></contents>
|
108
|
+
</export>
|
109
|
+
XML
|
110
|
+
end
|
103
111
|
|
104
112
|
context 'when context do not exists' do
|
105
113
|
let(:context) { :missing_context }
|
@@ -109,12 +117,12 @@ describe Keepcon::Integration do
|
|
109
117
|
|
110
118
|
context 'when context exists' do
|
111
119
|
let(:context) { :context }
|
120
|
+
let(:client) { added_context.client }
|
112
121
|
|
113
122
|
it 'calls client async_results_request for that context' do
|
114
|
-
expect(
|
115
|
-
|
116
|
-
|
117
|
-
subject
|
123
|
+
expect(client).to receive(:async_results_request) { results }
|
124
|
+
expect(client).to receive(:async_ack).with('b537-35642fb84114')
|
125
|
+
is_expected.to be_a(Keepcon::Entity::Response)
|
118
126
|
end
|
119
127
|
end
|
120
128
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keepcon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane O'Grady
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: retryable-rb
|