horizon_client 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06b84f8009e74940b022cfb6c7feb583e068d51c
4
- data.tar.gz: b2670e249a5646c5b68c23343ff62b0f2beaf6d7
3
+ metadata.gz: a7c21225a65811cbf379c2ffdc95cda48899ba9f
4
+ data.tar.gz: 5c7a368fb38adee65510e6e4201ddba0b028e11a
5
5
  SHA512:
6
- metadata.gz: 00ca8cad1ed53bf68bb309a446adcaff7dfddd124b572b3c8a6dbbb38e496ba9fdd984cb7036419fa79f2a8562ecc257ca88d52bce774835c830d8124dba47d7
7
- data.tar.gz: 1cd29b3ef83dfd52158d679dd1693cd84a14cc296499ac7320ff89415959e36715fbcd078b609d2e8e645b456b4cc696d486bd42291730100caaba13332cb0d8
6
+ metadata.gz: 0791f4f98d51f6de68f063c4d5bd005efbf5523cd6195ca405440b054e86f19d9fed8c3f4db7c9de55419c965332e00ef9ea9f2aff61e503de1ccd17aa93a833
7
+ data.tar.gz: 89a9973737c804a89ae4c34c2f1cee1016190ed4293ea175c242884f1e829ba64829df6b1f43975f46832287f6954f91d5e70e51136c5830cff64b04c4b6e435
data/README.md CHANGED
@@ -2,10 +2,31 @@
2
2
 
3
3
  Client to use with Horizon REST xml API.
4
4
 
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'horizon_client'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ $ gem install horizon_client
23
+ ```
24
+
5
25
  ## Usage
6
26
 
7
27
  ```ruby
8
28
  client = HorizonClient.new
29
+ client.logger = Logger.new(STDOUT)
9
30
 
10
31
  # incoming xml:
11
32
  # <?xml version="1.0" encoding="UTF-8" standalone="no"?>
@@ -15,6 +15,8 @@ module HorizonClient
15
15
  end
16
16
 
17
17
  class Connection
18
+ attr_accessor :logger
19
+
18
20
  def initialize(url = nil)
19
21
  url ||= ENV['HORIZON_REST_URL']
20
22
 
@@ -32,18 +34,31 @@ module HorizonClient
32
34
  end
33
35
 
34
36
  def get(path = '', params = {})
35
- response = @connection.get path, params
36
- response.body
37
+ log "GET #{path}", params do
38
+ response = @connection.get path, params
39
+ response.body
40
+ end
37
41
  end
38
42
 
39
43
  def post(path = '', body)
40
- response = @connection.post do |req|
41
- req.url path
42
- req.headers['Content-Type'] = 'application/xml;charset=UTF-8'
43
- req.body = body
44
+ log "GET #{path}", {body: body} do
45
+ response = @connection.post do |req|
46
+ req.url path
47
+ req.headers['Content-Type'] = 'application/xml;charset=UTF-8'
48
+ req.body = body
49
+ end
50
+
51
+ response.body
44
52
  end
53
+ end
45
54
 
46
- response.body
55
+ def log(message, params = {})
56
+ t1 = Time.now
57
+ yield
58
+ ensure
59
+ t2 = Time.now
60
+ duration = (t2 - t1) / 1000
61
+ logger.info "Horizon (#{duration}ms) #{message} #{params.inspect}" if logger
47
62
  end
48
63
  end
49
64
  end
@@ -1,3 +1,3 @@
1
1
  module HorizonClient
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: horizon_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MAK IT
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-17 00:00:00.000000000 Z
11
+ date: 2017-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler