brocade_vrouter 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95b01654d13e2c586c63b23c88832d18dc2e2409
4
- data.tar.gz: d21ba7fdec1315490e781e5f414c8bae454c3525
3
+ metadata.gz: ef53271d6a9246b8a7d44226fef34ae5d1ce9c07
4
+ data.tar.gz: 24a9872b93b4f3525d4de76921fe9f3ca571b411
5
5
  SHA512:
6
- metadata.gz: a2d9fdf73b35f68c43cf213b9f49a964745ed3012f48559ef5d3ec6e372ffd5a8296ac7998560cffb28475265791db806812fdb36b1eadb9afe370af2194860c
7
- data.tar.gz: d5c121c518facc4f9c8132c1e353b39e28efb5ac6e8ad32358229357772f902c050afef86c3396d6228264aceb79e50016e129a01b0654bfa50f8603c5a62a24
6
+ metadata.gz: 115b06d623eb34a11c73a6364c15358c97715b29a9da748fe48bcd9b26f1cfa8153ede27c036aa428e1ab25c25872e275120ad06a559fafedc7187751b5dbb1d
7
+ data.tar.gz: 3868121ef70e5fd11fd75af22f5536ab01d81f5d0e61e77f9ca2a8d38dedee1de025fbd3648cd13d17cbe06b17a12cc3217015c2fbd3f98fbb5c9e0cd59a52ec
@@ -1,8 +1,8 @@
1
1
  module BrocadeVRouter
2
2
  class Client
3
- attr_reader :connection
3
+ attr_reader :connection, :logger
4
4
 
5
- def initialize(url: nil, connection_options: nil, basic_auth: nil)
5
+ def initialize(url: nil, connection_options: nil, basic_auth: nil, logger: nil)
6
6
  config = BrocadeVRouter.config
7
7
  url ||= config.url
8
8
  connection_options ||= config.connection_options
@@ -12,10 +12,12 @@ module BrocadeVRouter
12
12
  f.adapter config.adapter
13
13
  f.basic_auth(*basic_auth) if basic_auth
14
14
  end
15
+
16
+ @logger = logger || config.logger
15
17
  end
16
18
 
17
19
  def configuration(&blk)
18
- @current_conf ||= Configuration.new connection
20
+ @current_conf ||= Configuration.new connection, logger: logger
19
21
  block_given? ? @current_conf.perform(&blk) : @current_conf
20
22
  end
21
23
 
@@ -2,11 +2,12 @@ module BrocadeVRouter
2
2
  class Configuration
3
3
  CONF_PATH = '/rest/conf'.freeze
4
4
 
5
- attr_reader :connection, :last_response
5
+ attr_reader :connection, :last_response, :logger
6
6
 
7
- def initialize(connection, base_path = nil)
7
+ def initialize(connection, base_path: nil, logger: nil)
8
8
  @connection = connection
9
9
  @base_path = base_path
10
+ @logger = logger
10
11
  end
11
12
 
12
13
  def base_path
@@ -73,12 +74,12 @@ module BrocadeVRouter
73
74
 
74
75
  def handle_response(resp)
75
76
  @last_response = resp
76
- if BrocadeVRouter.config.logger
77
- BrocadeVRouter.config.logger.info "#{resp.env.method} #{resp.env.url} #{resp.env.status}\n#{resp.body}"
78
- end
79
- if BrocadeVRouter.config.raise_on_fail && !resp.success?
80
- raise RequestError.new "Request #{resp.env.method.upcase} #{resp.env.url} failed with code #{resp.status}: #{resp.body}"
81
- end
77
+
78
+ message = "#{resp.env.method} #{resp.env.url} #{resp.env.status}\n#{resp.body}"
79
+ logger.info message if logger
80
+
81
+ raise RequestError.new message if BrocadeVRouter.config.raise_on_fail && !resp.success?
82
+
82
83
  resp
83
84
  end
84
85
 
@@ -1,3 +1,3 @@
1
1
  module BrocadeVRouter
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brocade_vrouter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Kosmatov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-24 00:00:00.000000000 Z
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday