wialon_api 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/wialon_api/error.rb +0 -4
- data/lib/wialon_api/logger.rb +1 -1
- data/lib/wialon_api/result.rb +1 -1
- data/lib/wialon_api/version.rb +1 -1
- data/spec/wialon_api/logger_spec.rb +10 -0
- data/spec/wialon_api/result_spec.rb +6 -0
- data/wialon_api.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d72ca701951b4320cfe86fe0fb0096b7bb16b4d0
|
4
|
+
data.tar.gz: a0849a823b9c6f61769f055e1452c6719682cec9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cba1431f43dba8f078cd0d93ca7c9e8ba5cd7cff19ccfa39d3afe8e009f3b92ff05fd3a93115713a83be388fa5496588dfc75b3fb2283fc61fd136a2d67df4d8
|
7
|
+
data.tar.gz: 3db5f7898de551d781baf8f90e54b665db82bc0759838c3de6563e3068f91536d19496bb5037f973e2cf915fc89eecd8e2343695d50f5c3f1361de386ae6480e
|
data/README.md
CHANGED
@@ -153,7 +153,7 @@ Note that `Wialon Pro` edition uses different parameters in requests, e.g. `ssid
|
|
153
153
|
|
154
154
|
`Net::HTTP` is used by default for a HTTP requests. One can choose any [other adapter](https://github.com/technoweenie/faraday/blob/master/lib/faraday/adapter.rb) suported by `faraday`.
|
155
155
|
|
156
|
-
Options for faraday connection (e.g. proxy settings or SSL certificates path) could be set through `faraday_options` when configuring `wialon_api
|
156
|
+
Options for faraday connection (e.g. proxy settings or SSL certificates path) could be set through `faraday_options` when configuring `wialon_api`.
|
157
157
|
|
158
158
|
The default configuration could be generated in a Rails application using `wialon_api:install` command:
|
159
159
|
|
data/lib/wialon_api/error.rb
CHANGED
data/lib/wialon_api/logger.rb
CHANGED
@@ -24,7 +24,7 @@ module WialonApi
|
|
24
24
|
# Logs the response (successful or not) if needed.
|
25
25
|
# @param [Hash] env Response data.
|
26
26
|
def on_complete(env)
|
27
|
-
if env[:body].error?
|
27
|
+
if env[:body].respond_to?(:error) && env[:body].error?
|
28
28
|
@logger.warn env[:raw_body] if WialonApi.log_errors?
|
29
29
|
else
|
30
30
|
@logger.debug env[:raw_body] if WialonApi.log_responses?
|
data/lib/wialon_api/result.rb
CHANGED
data/lib/wialon_api/version.rb
CHANGED
@@ -10,6 +10,7 @@ describe WialonApi::Logger do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
let(:success_response) { Oj.dump('a' => 1, 'b' => 2) }
|
13
|
+
let(:success_array_response) { Oj.dump(['a' => 1, 'b' => 2])}
|
13
14
|
let(:fail_response) { Oj.dump('error' => 404) }
|
14
15
|
|
15
16
|
let(:connection) do
|
@@ -28,6 +29,10 @@ describe WialonApi::Logger do
|
|
28
29
|
[200, {}, success_response]
|
29
30
|
end
|
30
31
|
|
32
|
+
stub.get('/array_success') do
|
33
|
+
[200, {}, success_array_response]
|
34
|
+
end
|
35
|
+
|
31
36
|
stub.get('/fail') do
|
32
37
|
[200, {}, fail_response]
|
33
38
|
end
|
@@ -45,6 +50,11 @@ describe WialonApi::Logger do
|
|
45
50
|
connection.get('/success')
|
46
51
|
end
|
47
52
|
|
53
|
+
it 'logs the request URL with array response' do
|
54
|
+
expect(WialonApi.logger).to receive(:debug).with('GET http://example.com/array_success')
|
55
|
+
connection.get('/array_success')
|
56
|
+
end
|
57
|
+
|
48
58
|
context 'with a POST request' do
|
49
59
|
it 'logs the request URL and the request body' do
|
50
60
|
expect(WialonApi.logger).to receive(:debug).with('POST http://example.com/success')
|
@@ -74,9 +74,15 @@ describe WialonApi::Result do
|
|
74
74
|
|
75
75
|
context 'with a success response' do
|
76
76
|
let(:result) { Hashie::Mash.new(result_response) }
|
77
|
+
let(:result_array) { [Hashie::Mash.new(result_response)] }
|
78
|
+
|
77
79
|
it 'returns plain result' do
|
78
80
|
expect(WialonApi::Result.send(:extract_result, result)).to eq(result)
|
79
81
|
end
|
82
|
+
|
83
|
+
it 'returns plain array result' do
|
84
|
+
expect(WialonApi::Result.send(:extract_result, result_array)).to eq(result_array)
|
85
|
+
end
|
80
86
|
end
|
81
87
|
|
82
88
|
context 'with an error response' do
|
data/wialon_api.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = WialonApi::VERSION
|
9
9
|
spec.authors = ["Arsen Shamkhalov"]
|
10
10
|
spec.email = ["thornu731@gmail.com"]
|
11
|
-
spec.summary = %q{Simple to use
|
11
|
+
spec.summary = %q{Simple to use Wialon API client. http://sdk.wialon.com/wiki/}
|
12
12
|
spec.description = %q{}
|
13
13
|
spec.homepage = "https://github.com/thorn/wialon_api"
|
14
14
|
spec.license = "MIT"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wialon_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arsen Shamkhalov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -251,7 +251,7 @@ rubyforge_project:
|
|
251
251
|
rubygems_version: 2.4.5
|
252
252
|
signing_key:
|
253
253
|
specification_version: 4
|
254
|
-
summary: Simple to use
|
254
|
+
summary: Simple to use Wialon API client. http://sdk.wialon.com/wiki/
|
255
255
|
test_files:
|
256
256
|
- spec/spec_helper.rb
|
257
257
|
- spec/wialon_api/api_spec.rb
|