wialon_api 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 837b4373fd4679f2e4ff1836a4a0e5539a13e938
4
- data.tar.gz: 2546fbb21ba7c2485bcec73cafebcccbff59e742
3
+ metadata.gz: d72ca701951b4320cfe86fe0fb0096b7bb16b4d0
4
+ data.tar.gz: a0849a823b9c6f61769f055e1452c6719682cec9
5
5
  SHA512:
6
- metadata.gz: 0428f8f6cff58ff21817135e088a0270bbeec42c153f956fd99526c1d6bab64337a1c94e0b77d46c74556a8b5daad2fcaceb380b9251244ecfbc9b6c2aa5b4c2
7
- data.tar.gz: b599c28dd28a925035335516c51cd28d5f6ff0aac93de75c224cb6ac210571137dbd20b7818bfda5bd550c400732ee85d253e3474ae3f57f38d87851ceebd64f
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
 
@@ -2,7 +2,6 @@
2
2
  module WialonApi
3
3
  class Error < StandardError
4
4
  attr_reader :error_code
5
- attr_reader :error_messages
6
5
  attr_reader :message
7
6
 
8
7
  def initialize(data)
@@ -31,6 +30,3 @@ module WialonApi
31
30
  end
32
31
  end
33
32
  end
34
-
35
-
36
-
@@ -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?
@@ -10,7 +10,7 @@ module WialonApi
10
10
  end
11
11
 
12
12
  def self.extract_result(response)
13
- if response.error
13
+ if response.respond_to?(:error) && response.error
14
14
  fail WialonApi::Error.new(response)
15
15
  else
16
16
  response
@@ -1,3 +1,3 @@
1
1
  module WialonApi
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -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 WialonPro API client. http://sdk.wialon.com/wiki/ru/pro/pro}
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.6
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-04-07 00:00:00.000000000 Z
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 WialonPro API client. http://sdk.wialon.com/wiki/ru/pro/pro
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