zabbixapi 0.5.1b12 → 0.5.1b13

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.
@@ -13,5 +13,9 @@ class ZabbixApi
13
13
  delete(data)
14
14
  end
15
15
 
16
+ def method_name
17
+
18
+ end
19
+
16
20
  end
17
21
  end
@@ -1,22 +1,39 @@
1
1
  class ZabbixApi
2
2
  class Basic
3
3
 
4
- def hash_equals?(a, b)
5
- hash1 = a.merge(b)
6
- hash2 = b.merge(a)
7
- hash1 == hash2
8
- end
9
-
10
4
  def log(message)
11
5
  puts "#{message}" if @client.options[:debug]
12
6
  end
13
7
 
8
+ def hash_equals?(a, b)
9
+ a_new = normalize_hash(a)
10
+ b_new = normalize_hash(b)
11
+ hash1 = a_new.merge(b_new)
12
+ hash2 = b_new.merge(a_new)
13
+ log("hash1 == #{hash1}")
14
+ log("hash2 == #{hash2}")
15
+ hash1 == hash2
16
+ end
17
+
14
18
  def symbolize_keys(obj)
15
19
  return obj.inject({}){|memo,(k,v)| memo[k.to_sym] = symbolize_keys(v); memo} if obj.is_a? Hash
16
20
  return obj.inject([]){|memo,v | memo << symbolize_keys(v); memo} if obj.is_a? Array
17
21
  obj
18
22
  end
19
23
 
24
+ def normalize_hash(hash)
25
+ result = hash.dup
26
+ result.each do |key, value|
27
+ case value
28
+ when Hash
29
+ result[key] = value.to_s
30
+ when Array
31
+ result.delete(key)
32
+ end
33
+ end
34
+ result
35
+ end
36
+
20
37
  def parse_keys(data)
21
38
  case data
22
39
  when Hash
@@ -26,6 +26,7 @@ class ZabbixApi
26
26
  end
27
27
 
28
28
  def update(data)
29
+
29
30
  log "[DEBUG] Call update with parametrs: #{data.inspect}"
30
31
 
31
32
  dump = {}
@@ -34,11 +35,8 @@ class ZabbixApi
34
35
  dump = symbolize_keys(item) if item[key].to_i == data[key.to_sym].to_i
35
36
  end
36
37
 
37
- puts "dump: #{dump}"
38
- puts "data: #{data}"
39
-
40
38
  if hash_equals?(dump, data) #dump.deep_include?(data)
41
- puts "eq keys!"
39
+ log "equal keys #{dump} and #{data}, skip update"
42
40
  item_id
43
41
  else
44
42
  data_update = array_flag ? [data] : data
@@ -1,3 +1,3 @@
1
1
  class ZabbixApi
2
- VERSION = "0.5.1b12"
2
+ VERSION = "0.5.1b13"
3
3
  end
data/spec/localhost.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #encoding: utf-8
2
-
2
+ require 'rspec'
3
3
  require 'zabbixapi'
4
4
 
5
5
  # settings
@@ -13,7 +13,7 @@ zbx = ZabbixApi.connect(
13
13
  :url => api_url,
14
14
  :user => api_login,
15
15
  :password => api_password,
16
- :debug => false
16
+ :debug => true
17
17
  )
18
18
 
19
19
  hostgroup = "hostgroup______1"
@@ -21,7 +21,7 @@ template = "template______1"
21
21
  application = "application_____1"
22
22
  item = "item_____1"
23
23
  host = "hostname____1"
24
- trigger = "trigger____1"
24
+ trigger = "trigger____1" #TODO !saDSASDAS
25
25
  user = "user____1"
26
26
  user2 = "user____2"
27
27
  usergroup = "SomeUserGroup"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbixapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1b12
4
+ version: 0.5.1b13
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-21 00:00:00.000000000 Z
12
+ date: 2012-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -79,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  segments:
81
81
  - 0
82
- hash: 2277446654334313109
82
+ hash: 2834936151065301027
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements: