zbx 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +2 -2
  2. data/lib/zbx.rb +29 -2
  3. data/lib/zbx/version.rb +1 -1
  4. metadata +1 -1
data/README.md CHANGED
@@ -39,12 +39,12 @@ end
39
39
 
40
40
 
41
41
  ZBX.client do
42
- set username: 'username', password: password
42
+ set user: user, password: password
43
43
  set api_url: 'http://api_url'
44
44
  host.get hostids: 10160
45
45
  end
46
46
 
47
- client = ZBX.client(username, password, api_url)
47
+ client = ZBX.client(user, password, api_url)
48
48
  client.host.get hostids: 10160
49
49
 
50
50
  host_api = client.host
data/lib/zbx.rb CHANGED
@@ -7,7 +7,34 @@ require 'json'
7
7
  require 'net/http'
8
8
 
9
9
  module ZBX
10
- def self.client user=nil, password=nil, api_url=nil, &block
11
- API.new user, password, api_url, &block
10
+ class << self
11
+ # zbx module API, user should call this method to initialize a
12
+ # zabbxi-api client.
13
+ def client user=nil, password=nil, api_url=nil, &block
14
+ API.new(user || configuration.user,
15
+ password || configuration.password,
16
+ api_url || configuration.api_url,
17
+ &block)
18
+ end
19
+
20
+ # configuration
21
+ def config
22
+ yield(configuration)
23
+ configuration
24
+ end
25
+
26
+ def reset_configuration!
27
+ @configuration = nil
28
+ end
29
+
30
+ private
31
+
32
+ def configuration
33
+ @configuration ||= Struct.new(:user, :password, :api_url) {
34
+ def [] option
35
+ __send__ option
36
+ end
37
+ }.new
38
+ end
12
39
  end
13
40
  end
@@ -1,3 +1,3 @@
1
1
  module ZBX
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zbx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: